-
Notifications
You must be signed in to change notification settings - Fork 223
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
Conversation
df3665a
to
e73dbc0
Compare
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>
b38b1c1
to
491cd9d
Compare
Mostly so we can use const interpolated strings.
491cd9d
to
26f978c
Compare
There was a problem hiding this 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 :)
src/PowerShellEditorServices/Services/DebugAdapter/DebugService.cs
Outdated
Show resolved
Hide resolved
@andschwa please merge these changes, I feel pretty good about this change set. See Discord for details. |
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.
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