Skip to content

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

@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.

@microsoft-github-policy-service microsoft-github-policy-service bot added the Review - Needed The PR is being reviewed label Aug 6, 2025
@SeeminglyScience SeeminglyScience added the WG-NeedsReview Needs a review by the labeled Working Group label Oct 1, 2025
@SeeminglyScience
Copy link
Collaborator

Thanks Jordan! Gonna add this to the Engine WG queue just to 👍 the public API and new engine event.

@iSazonov
Copy link
Collaborator

iSazonov commented Oct 2, 2025

/azp run PowerShell-Windows-Packaging-CI, PowerShell-CI-linux-packaging

@azure-pipelines
Copy link

Azure Pipelines could not run because the pipeline triggers exclude this branch/path.

@microsoft-github-policy-service microsoft-github-policy-service bot removed the Review - Needed The PR is being reviewed label Oct 2, 2025
@kilasuit
Copy link
Collaborator

kilasuit commented Oct 6, 2025

The Engine WG was able to review this today & have signed off on adding this behaviour. We however would like additional code review to happen prior to merging.

@kilasuit kilasuit added WG-Engine core PowerShell engine, interpreter, and runtime WG-Reviewed A Working Group has reviewed this and made a recommendation and removed WG-NeedsReview Needs a review by the labeled Working Group labels Oct 6, 2025
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
Copy link
Collaborator

iSazonov commented Oct 7, 2025

/azp run PowerShell-Windows-Packaging-CI, PowerShell-CI-linux-packaging

@azure-pipelines
Copy link

Azure Pipelines could not run because the pipeline triggers exclude this branch/path.

Copy link
Collaborator

@SeeminglyScience SeeminglyScience left a comment

Choose a reason for hiding this comment

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

Thanks Jordan! Just two minor suggestions. Feel free to ping me on discord when resolved and I'll merge after tests finish

@microsoft-github-policy-service microsoft-github-policy-service bot added the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label Oct 7, 2025
Co-authored-by: Patrick Meinecke <SeeminglyScience@users.noreply.github.com>
@microsoft-github-policy-service microsoft-github-policy-service bot removed the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label Oct 7, 2025
Copy link
Collaborator

@SeeminglyScience SeeminglyScience left a comment

Choose a reason for hiding this comment

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

LGTM!

@SeeminglyScience
Copy link
Collaborator

/azp run PowerShell-CI-linux-packaging, PowerShell-Windows-Packaging-CI

@azure-pipelines
Copy link

Azure Pipelines could not run because the pipeline triggers exclude this branch/path.

@SeeminglyScience SeeminglyScience merged commit 0ef738b into PowerShell:master Oct 7, 2025
37 checks passed
@microsoft-github-policy-service
Copy link
Contributor

microsoft-github-policy-service bot commented Oct 7, 2025

📣 Hey @@jborean93, how did we do? We would love to hear your feedback with the link below! 🗣️

🔗 https://aka.ms/PSRepoFeedback

@jborean93 jborean93 deleted the debug-attach branch October 7, 2025 22:48
@jborean93
Copy link
Collaborator Author

Thanks for the reviews!

SIRMARGIN pushed a commit to SIRMARGIN/PowerShell that referenced this pull request Dec 12, 2025
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.
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 WG-Engine core PowerShell engine, interpreter, and runtime WG-Reviewed A Working Group has reviewed this and made a recommendation

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