Skip to content
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

Calling Set-PSBreakpoint in console doesn't cause breakpoint icon to appear in file #660

Closed
daviwil opened this issue Apr 7, 2017 · 14 comments
Labels

Comments

@daviwil
Copy link
Contributor

daviwil commented Apr 7, 2017

We need to send a BreakpointEvent back to the debugger client when new breakpoints are added in the session via the Set-PSBreakpoint cmdlet. I've got an implementation working but it's currently blocked by a bug in VS Code (microsoft/vscode#24164) which causes all other breakpoints in the file to be cleared when the BreakpointEvent is received.

@daviwil daviwil added Area-Debugging Issue-Bug A bug to squash. labels Apr 7, 2017
@daviwil daviwil added this to the April 2017 milestone Apr 7, 2017
daviwil added a commit to daviwil/PowerShellEditorServices that referenced this issue Apr 7, 2017
This change adds the BreakpointEvent message type to the debug adapter
and wires it up to be sent anytime breakpoints change in the editing
session.  This allows the user to call Set-PSBreakpoint in the
integrated console to add new breakpoints and then see them be set in
the editor UI.

Resolves PowerShell/vscode-powershell#660
@daviwil
Copy link
Contributor Author

daviwil commented Apr 7, 2017

Here's the commit with the current work: daviwil/PowerShellEditorServices@5beeba1

@daviwil daviwil modified the milestones: April 2017, May 2017 May 8, 2017
@nightroman
Copy link

And the opposite is true, in a way. Namely,

  • set a breakpoint by F9 is a script
  • in the terminal invoke Get-PSBreakpoint

As a result, the BP is not in the output.
Also, if I invoke this script from the terminal then the BP is not hit.

Is it the related issue or should I open another?

@daviwil
Copy link
Contributor Author

daviwil commented May 19, 2017

I don't think there's an issue for it specifically right now, but this is actually a problem with VS Code's debugger model. When you click a breakpoint in a file when the debugger isn't running, they don't send me any notification that the breakpoint was created. They wait until the user starts the debugger before sending the breakpoints to my debug server. I'm trying to get them to expand their model to support scenarios like this but it's a slow process.

@nightroman
Copy link

I am looking forward to this development. It's probably too early to file all hiccups in debugging.

I am playing with some useful scenarios in VS Code debugger, e.g. automatically breaking into the debugger and opening scripts on terminating errors at the point of failure. It's promising but not quite reliable yet.

@daviwil
Copy link
Contributor Author

daviwil commented May 19, 2017

Definitely not too early! File everything that you run across that doesn't work well for you, I'm hoping to polish out most of the issues over the next couple of months.

@nightroman
Copy link

All right, I will create some issues then after a while when I get more facts.

@daviwil
Copy link
Contributor Author

daviwil commented May 19, 2017

Thanks Roman!

@nightroman
Copy link

Here is the just published little debugging tool with the steps described in its comments:
https://www.powershellgallery.com/packages/Debug-Error

It works. But sometimes with some combination of factors it does not...

@daviwil
Copy link
Contributor Author

daviwil commented May 19, 2017

That's really clever! You know, VS Code has a setting to break on exceptions that we can plug into. Would you be interested in contributing this approach as a feature in PSES and the PowerShell extension?

@nightroman
Copy link

nightroman commented May 19, 2017

Why not? Let see how it works (hoping for some feedback). I am still playing with this and trying to use in Invoke-Build tasks troubleshooting in VSCode. To be honest, I started to use VSCode just recently because I was happy with my own sort of script IDE, PowerShellFar for Far Manager.

@rkeithhill
Copy link
Contributor

I've been waiting on @PaulHigin to add the ability to break on unhandled terminating error and it hasn't happened yet AFAIK. This could be interesting way point until we get the built-in support in the debugger.

@daviwil
Copy link
Contributor Author

daviwil commented May 19, 2017

Yep, I think this could work in enough scenarios to satisfy the need in the short term, and on older PowerShell versions.

Roman, feel free to send an e-mail anytime with questions about how to get this hooked up. I'm looking for the docs on the high level details right now, I'll pass them along to you soon.

@daviwil
Copy link
Contributor Author

daviwil commented May 19, 2017

Looks like the debug adapter protocol wants us to return the exceptionBreakpointFilters capability when it asks us to initialize so that it shows an exception breakpoint option in the UI:

We're returning this capabilities object here:

https://github.com/PowerShell/PowerShellEditorServices/blob/master/src/PowerShellEditorServices.Protocol/Server/DebugAdapterBase.cs#L59

Looks like we'd need to specify an ExceptionBreakpointsFilter, possibly called "Unhandled Script Errors", which would enable an additional checkbox in the "Breakpoints" UI with that name.

If the user checks it, VS Code will send us the SetExceptionBreakpointsRequest which we haven't added to our message classes yet.

Once we receive that message, we could run your breakpoint code inside of the runspace to enable the variable breakpoint on StackFrame. When we hit that type of breakpoint we'll need to be aware of it so that we can return a reason value of exception in the StoppedEvent.

That was a fast overview, feel free to ask questions about any of those steps :)

@daviwil daviwil modified the milestones: May 2017, June 2017 Jun 1, 2017
@daviwil daviwil modified the milestones: June 2017, July 2017 Jul 11, 2017
@daviwil
Copy link
Contributor Author

daviwil commented Aug 14, 2017

Also related to #625.

@daviwil daviwil modified the milestones: July 2017, Future, 1.5.0 Oct 26, 2017
daviwil added a commit to daviwil/PowerShellEditorServices that referenced this issue Oct 26, 2017
This change adds the BreakpointEvent message type to the debug adapter
and wires it up to be sent anytime breakpoints change in the editing
session.  This allows the user to call Set-PSBreakpoint in the
integrated console to add new breakpoints and then see them be set in
the editor UI.

Resolves PowerShell/vscode-powershell#660
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

3 participants