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

Improve debugger's variable population mechanism #1630

Merged
merged 12 commits into from
Nov 23, 2021

Conversation

andyleejordan
Copy link
Member

@andyleejordan andyleejordan commented Nov 19, 2021

This is take two on #1620, with it rebased and commits somewhat split apart, as well as additional fixes.

Fixes PowerShell/vscode-powershell#3667
Fixes PowerShell/vscode-powershell#3673

JustinGrote and others added 4 commits November 18, 2021 16:10
Thanks to PowerShell idiosyncracies around scopes, it is impossible for
the debug service to get the "local variables" for each stack frame. The
prior behavior used an assumption that from the 0 index, each increment
to the stack frame corresponded 1-to-1 to an increment in scope, and
that at each of those frames we could get local variables. This does not
work because that 1-to-1 assumption does not hold, as evidenced by
crashes exhibited in the preview extension because there are often more
stack frames than there are scopes. Since this was but a guess, it was
decided that it is worse to provide inaccurate information than a "best
guess" and so each stack frame now only gets auto variables.

In the process of fixing this, the variable detection mechanism was
improved to rely on the raw results of `Get-PSCallStack` when available
locally, and only pass it through a serialization and deserialization
process when necessary for remote debugging.

Finally, the `StackFrameDetails.Create` method had an ancient TODO from
2019 that we decided to drop the skeleton support for, namely passing
the workspace root path and processing the invoation information.

Co-authored-by: Andy Schwartzmeyer <andrew@schwartzmeyer.com>
Co-authored-by: Patrick Meinecke <SeeminglyScience@users.noreply.github.com>
While it would be nice to only present `$PSItem` to encourage people to
use it, that may confuse people who still use `$_` and don't know that
they are the same.

Co-authored-by: Patrick Meinecke <SeeminglyScience@users.noreply.github.com>
Co-authored-by: Patrick Meinecke <SeeminglyScience@users.noreply.github.com>
Co-authored-by: Andy Schwartzmeyer <andrew@schwartzmeyer.com>
@andyleejordan andyleejordan force-pushed the andschwa/debugger branch 2 times, most recently from b38b1c1 to 491cd9d Compare November 19, 2021 00:25
@andyleejordan andyleejordan marked this pull request as ready for review November 19, 2021 01:04
Copy link
Collaborator

@JustinGrote JustinGrote left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, we can modify the AddToAutoVariables in a future PR as to what Auto should be defined as, maybe have a mini-RFC issue :)

@JustinGrote
Copy link
Collaborator

@andschwa please merge these changes, I feel pretty good about this change set. See Discord for details.
https://github.com/justingrote/powershelleditorservices/tree/debugVariables

@andyleejordan
Copy link
Member Author

@andschwa please merge these changes, I feel pretty good about this change set. See Discord for details.
https://github.com/justingrote/powershelleditorservices/tree/debugVariables

Literally just got to the top of the conversation starting 11/19, reading through!

We want this container to hold everything that is most likely
contextually relevant to the user while debugging. It is specifically
NOT analagous to PowerShell's automatic variables, but to Visual
Studio's "auto" view of a debugger's variables. This means that for the
top of the callstack, we merge the local scope's variables with those in
the frame and filter to our own curated list.

We also cleaned up our variable property rehydration path.
@andyleejordan andyleejordan merged commit 15650c3 into master Nov 23, 2021
@andyleejordan andyleejordan deleted the andschwa/debugger branch November 23, 2021 00:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Null Stack if debugging in separate process Debugging with active breakpoint crashes Powershell session
2 participants