debugging an external host should break at any statement · Issue #5073 · PowerShell/vscode-powershell · GitHub
Skip to content

debugging an external host should break at any statement #5073

Open

Description

@jjsmeets

Prerequisites

  • I have written a descriptive issue title.
  • I have searched all issues to ensure it has not already been reported.

Summary

I have seen video's of vcode/powershell where when attaching to a host powershell process (running any script) using an attach configuration that script stops where it currently was executing.

This does not happen in the current powershell version (7.4.6). It also does not happen when doing the attach manually using enter-psHostProcess followed by debug-runspace. But it works when using debug-runspace -breakall.

I have seen that breakAll is new sinds powershell 7.2. I expect that in the powershell extension when using an attach configuration the old version "debug-runspace" is used and not the new version "debug-runspace -breakall".

Proposed Design

Can this be changed back to it was before powershell 7.2 (or configured in the launch configuration)?

Activity

  1. JustinGrote commented on Oct 30, 2024

    @JustinGrote
    Collaborator

    Thanks for your submission!

    The external debugging, especially around breakpoints, is very finicky at the moment. I'm going to peg this as dependent on #4065 and once that breakpointing sync problem is solved we can look more into the remothing issue there.

  2. jjsmeets commented on Oct 31, 2024

    @jjsmeets
    Author

    I have created a temporary solution . It involves 2 launch configurations. A powershell function called D03_FacilitateDebug and a procedure explaining how to use them.
    Because that all takes quit some lines I will add them as an attachment
    solution to debug.txt

  3. jjsmeets commented on Oct 31, 2024

    @jjsmeets
    Author

    Forgot to meantion that D03_FacilitateDebug can not directly used inside the job. First you have to convert it to a string and the use that string to dynamicaly define the function (with the same or as done in the next example with a new name and then call that function. So the statements immediately befor the start-treadjob and the first statements inside the job are:
    he following statements at the start of the thread job:

    [String]$f_FunctionNoHeader_Str=${function:D03_FacilitateDebug}.toString()
    
    [ThreadJob.ThreadJob]$Job1 = start-threadjob -ScriptBlock {
        write-output "JOB: FIRST LINE"
        # bring the functions definition (as string) to this scope
        # define the function with a new name in this scope
        ${function:J03_FacilitateDebug}=$using:f_FunctionNoHeader_Str
        J03_FacilitateDebug -p_TypeOfScript "JOB"
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions