Add property and event for debug attach #25788
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Summary
Adds the
IsRemoteDebuggerAttached
property toRunspace
that indicates whether a debugger is attached to the Runspace through theDebug-Runspace
cmdlet. Also adds a new engine eventPowerShell.OnDebugAttach
that is emitted when the debugger is attached.PR Context
Fixes: #21392
Also see PowerShell/PowerShellEditorServices#2250 which is the driver behind the new event. Unfortunately the only safe way to notify that code is safe to continue and a debugger is attached is through PowerShell. Sending our own event before calling
Debug-Runspace
won't work because the code could continue beforeDebug-Runspace
has set itself up. We cannot send an event after because the runspace will be busy runningDebug-Runspace
.PR Checklist
.h
,.cpp
,.cs
,.ps1
and.psm1
files have the correct copyright header