Skip to content
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

debugging an external host should break at any statement #5073

Open
2 tasks done
jjsmeets opened this issue Oct 30, 2024 · 3 comments
Open
2 tasks done

debugging an external host should break at any statement #5073

jjsmeets opened this issue Oct 30, 2024 · 3 comments
Labels
Area-Debugging Issue-Enhancement A feature request (enhancement).

Comments

@jjsmeets
Copy link

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)?

@jjsmeets jjsmeets added Issue-Enhancement A feature request (enhancement). Needs: Triage Maintainer attention needed! labels Oct 30, 2024
@JustinGrote
Copy link
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.

@JustinGrote JustinGrote added Area-Debugging and removed Needs: Triage Maintainer attention needed! labels Oct 30, 2024
@jjsmeets
Copy link
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

@jjsmeets
Copy link
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
Labels
Area-Debugging Issue-Enhancement A feature request (enhancement).
Projects
None yet
Development

No branches or pull requests

2 participants