Skip to content

Add property and event for debug attach #25788

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jborean93
Copy link
Collaborator

PR Summary

Adds the IsRemoteDebuggerAttached property to Runspace that indicates whether a debugger is attached to the Runspace through the Debug-Runspace cmdlet. Also adds a new engine event PowerShell.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 before Debug-Runspace has set itself up. We cannot send an event after because the runspace will be busy running Debug-Runspace.

PR Checklist

Adds the `IsRemoteDebuggerAttached` property to `Runspace` that
indicates whether a debugger is attached to the Runspace through the
`Debug-Runspace` cmdlet. Also adds a new engine event
`PowerShell.OnDebugAttach` that is emitted when the debugger is
attached.
@iSazonov iSazonov added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label Jul 29, 2025
Copy link
Collaborator

@kilasuit kilasuit 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 & only minor thought, can you see benefit in also adding a OnDebugDetach event too?

@jborean93
Copy link
Collaborator Author

Looks good & only minor thought, can you see benefit in also adding a OnDebugDetach event too?

I debated adding it internally and I couldn't think of a scenario where an end user would want to wait for a detach before continuing. But in saying that if there is something I haven't thought off I can definitely add it.

@kilasuit
Copy link
Collaborator

Lets leave adding that as a future enhancement for now as it seems to be small enough a change that should be a good win for someone else coming to the repo looking to contribute.

Copy link
Contributor

This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days.
Maintainer, please provide feedback and/or mark it as Waiting on Author

@microsoft-github-policy-service microsoft-github-policy-service bot added the Review - Needed The PR is being reviewed label Aug 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log Review - Needed The PR is being reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a way to see if a remote debugger has attached
4 participants