Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Add a way to see if a remote debugger has attached #21392

Copy link
Copy link
@SeeminglyScience

Description

@SeeminglyScience
Issue body actions

Summary of the new feature / enhancement

As a user who may want to attach to an otherwise unattended process to debug it, I want to be able to pause execution in said unattended process until I'm able to attach to it.

Proposed technical implementation details (optional)

A common pattern in C# for this would be something like

while (!Debugger.IsAttached) Thread.Sleep(200);
RestOfCodeHere(); // breakpoint on this line

Currently in PowerShell there's no supported way to tell if a debugger is attached to the current runspace. A minimal way to enable this scenario would be a property on Runspace:

public partial abstract class Runspace
{
+   public bool IsRemoteDebuggerAttached { get; }
}

This would allow the user to write the code

while (-not $Host.Runspace.IsRemoteDebuggerAttached) { Start-Sleep -Milliseconds 200 }
Invoke-RestOfCodeHere # breakpoint on this line, or just make it `Wait-Debugger`

If there is sufficient demand for it, a command or method to wait for attach can also be considered, but to start off the proposal I'd recommend this as an MVP.

One question that I would suggest be answered in the WG decision is: "What should a remote runspace do for this parameter? Throw? Or always return false?"

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugWG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtimeWG-ReviewedA Working Group has reviewed this and made a recommendationA Working Group has reviewed this and made a recommendation

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.