Skip to content

Breakpoints set in UI while script is running are never hit #854

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rkeithhill opened this issue Jun 10, 2017 · 5 comments
Closed

Breakpoints set in UI while script is running are never hit #854

rkeithhill opened this issue Jun 10, 2017 · 5 comments
Labels

Comments

@rkeithhill
Copy link
Contributor

System Details

  • Operating system name and version: Windows 10 CU
  • VS Code version: 1.13.0
  • PowerShell extension version: 5.1.15063.296

Issue Description

Open the Examples folder and then open DebugTest.ps1. Set debug config to launch the current file then press F5. Before the script terminates, set a breakpoint on line 12. This used to work i.e. on the next iteration through the loop the newly set breakpoint would be hit. Now it is not.

I think I also was able to set the breakpoint in the UI while the script was running (didn't hit it) and was able to unset it before the script stopped. On the next iteration, the breakpoint was hit even though it appeared to be removed. After that my debugger got into a hung state.

Attached Logs

Follow the instructions in the README
about capturing and sending logs.
1497062619-9642196a-f1c8-435c-803d-50e4d7d5ce701497062616431.zip

@daviwil
Copy link
Contributor

daviwil commented Jun 10, 2017

Hmmm, I don't think PowerShell allows you to call Set-PSBreakpoint while execution is running, or at least the PowerShell ISE explicitly disallows it. I could be wrong about that, though.

@daviwil daviwil added Area-Debugging Issue-Bug A bug to squash. labels Jun 10, 2017
@daviwil daviwil added this to the July 2017 milestone Jun 10, 2017
@nightroman
Copy link

nightroman commented Jun 10, 2017

PowerShell itself allows setting breakpoints while running. Try this script in a usual console:

# just out of curiosity
[runspace]::DefaultRunspace.Debugger.add_BreakpointUpdated({
	Write-Host ($_ | Out-String)
})

Set-PSBreakpoint -Variable test

$test = 1 # breaks into the debugger

BTW, I looked for BreakpointUpdated in this repo and did find any reference (I rather expected). Is it not useful?
UPDATE: Please, ignore, I found it in PowerShellEditorServices.

@rkeithhill
Copy link
Contributor Author

I would have sworn that I used to be able to start DebugTest.ps1 in the debugger, then set a breakpoint and it would stop.

@daviwil daviwil modified the milestones: July 2017, Future Oct 26, 2017
@BjornNordblom
Copy link

Can't reproduce. Tested with this script and let it run for a couple of iterations, and then set breakpoint while still running and it triggered.

while ($true) { sleep 3 }

Tested on VSCode 1.44.1 with Powershell extension 2020.3.0. Tested on both PS7 and PS5.1.

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Apr 15, 2020
@rjmholt
Copy link
Contributor

rjmholt commented Apr 15, 2020

Just as a note, due to the way we're forced to implement this in PS 5.1, it's likely some form of this will always exist in 5.1. See #1494.

In PS 7, an API was added that allows us to add breakpoints concurrently to script execution, meaning this is solved there.

@SydneyhSmith SydneyhSmith added Community-Help and removed Needs: Maintainer Attention Maintainer attention needed! labels Apr 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants