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

Cannot attach debugger to PS 7.4.0 processes #4843

Closed
6 tasks done
nightroman opened this issue Nov 20, 2023 · 18 comments · Fixed by #4888
Closed
6 tasks done

Cannot attach debugger to PS 7.4.0 processes #4843

nightroman opened this issue Nov 20, 2023 · 18 comments · Fixed by #4888
Assignees
Labels

Comments

@nightroman
Copy link

nightroman commented Nov 20, 2023

Prerequisites

  • I have written a descriptive issue title.
  • I have searched all open and closed issues to ensure it has not already been reported.
  • I have read the troubleshooting guide.
  • I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
  • I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
  • If this is a security issue, I have read the security issue reporting guidance.

Summary

Cannot attach debugger to an interactively selected PS 7.4.0 processes.
This operation takes long time, then results in this error

image

PowerShell Version

PS C:\ROM\SET\VSCode\debug-psf> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.4.0
PSEdition                      Core
GitCommitId                    7.4.0
OS                             Microsoft Windows 10.0.19045
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visual Studio Code Version

1.84.2
1a5daa3a0231a0fbba4f14db7ec463cf99d7768e
x64

Extension Version

ms-vscode.powershell@2023.8.0
I have also tried the latest pre-release, same issue.

Steps to Reproduce

  • Select launch profile "PowerShell attach" (below)
  • Hit F5
  • Select one of PS 7.4.0 choices

Launch profile:

{
  "launch": {
    "version": "0.2.0",
    "configurations": [
      {
        "type": "PowerShell",
        "request": "attach",
        "name": "PowerShell attach",
        "processId": "${command:PickPSHostProcess}",
        "runspaceId": 1
      }
    ]
  }
}

Visuals

No response

Logs

No response

@nightroman nightroman added Issue-Bug A bug to squash. Needs: Triage Maintainer attention needed! labels Nov 20, 2023
@nightroman
Copy link
Author

Bump...

@SydneyhSmith
Copy link
Collaborator

Thanks for the issue @nightroman we will need to do some more investigation into this

@SydneyhSmith SydneyhSmith added Needs: Maintainer Attention Maintainer attention needed! and removed Needs: Triage Maintainer attention needed! labels Dec 5, 2023
@SydneyhSmith SydneyhSmith moved this to Wishlist in Flying Fox Dec 5, 2023
@andyleejordan
Copy link
Member

Are you perhaps using the Windows Store installed version of PowerShell? I can never seem to attach to that installation, but can attach to 7.4 installed in pretty any other manner.

@andyleejordan andyleejordan added Needs: Fix Verification Please verify the fix for us! Needs: Author Feedback Please give us the requested feedback! and removed Needs: Maintainer Attention Maintainer attention needed! Needs: Fix Verification Please verify the fix for us! labels Jan 5, 2024
@nightroman
Copy link
Author

I use the PowerShell-7.4.0-win-x64.zip from Releases -- https://github.com/PowerShell/PowerShell/releases/tag/v7.4.0

@github-actions github-actions bot added Needs: Maintainer Attention Maintainer attention needed! and removed Needs: Author Feedback Please give us the requested feedback! labels Jan 5, 2024
@nightroman
Copy link
Author

Here is the latest status, changed with new versions, still not working but differently

image

VSCode version:
1.85.1
0ee08df0cf4527e40edc9aa28f4b5bd38bbff2b2
x64

ms-vscode.powershell version:
ms-vscode.powershell@2024.0.0

$PSVersionTable; $Host

Name                           Value
----                           -----
PSVersion                      7.4.1
PSEdition                      Core
GitCommitId                    7.4.1
OS                             Microsoft Windows 10.0.22631
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Name             : Visual Studio Code Host
Version          : 2024.0.0
InstanceId       : 8b608c97-927c-4d67-abc2-488fec552269
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : en-GB
CurrentUICulture : en-US
PrivateData      : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
DebuggerEnabled  : True
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace

@andyleejordan
Copy link
Member

Thanks for the update, that's very helpful and has led me to find a bug (or two).

@andyleejordan andyleejordan added Area-Debugging and removed Needs: Maintainer Attention Maintainer attention needed! labels Jan 12, 2024
@andyleejordan andyleejordan moved this from Wishlist to In Progress in Flying Fox Jan 12, 2024
@andyleejordan
Copy link
Member

So I think VS Code got stricter about type matching in variable substitutions, and these were mismatched. The original design allowed the PID to be an int or a string (which was just a special case for "current") but that led to a lot of unnecessary complication.

@nightroman
Copy link
Author

When can we try the fix?

@JustinGrote
Copy link
Collaborator

@nightroman every commit has a build, here is the one for the PR:
https://github.com/PowerShell/vscode-powershell/actions/runs/7549834396/artifacts/1173960040

Extract the VSIX and use "install with VSIX" in vscode and then reload your vscode.

@nightroman
Copy link
Author

Thank you. Same result so far, maybe the fix is not in this VSIX yet
image

@JustinGrote
Copy link
Collaborator

JustinGrote commented Jan 22, 2024

Can confirm I reproduced on the VSIX after choosing host process 80488.

@andyleejordan surprised type checking didn't catch this but I think this needs to be Promise<number> instead of Promise<string>

private async pickPSHostProcess(): Promise<string | undefined> {

@andyleejordan
Copy link
Member

Can confirm I reproduced on the VSIX after choosing host process 80488.

@andyleejordan surprised type checking didn't catch this but I think this needs to be Promise<number> instead of Promise<string>

private async pickPSHostProcess(): Promise<string | undefined> {

I definitely changed that so either I lost it in a rebase or that's the wrong build.

@andyleejordan
Copy link
Member

Yup, it is fixed in the PR: https://github.com/PowerShell/vscode-powershell/pull/4888/files#r1462216399 which build did you guys grab?

@JustinGrote
Copy link
Collaborator

I thought I grabbed the PR build so I probably screwed up, let me double check

@andyleejordan
Copy link
Member

Well you did grab the right artifact...but when I build locally I go from being able to repro to not.

@andyleejordan
Copy link
Member

image

Now with the changes made, the input to "processId" in the JSON should be an int so it does throw a squiggly warning about it being "${command:PickPSHostProcess}". This way of doing it continues to work, but I set it up so just not setting "processId" at all for an attach configuration will run PickPSHostProcess. So you can delete the whole line.

@nightroman
Copy link
Author

nightroman commented Jan 22, 2024

Removing the line with processId seems to be doing the trick, it's a very good news and progress, thank you.
Looking forward to the official update. Any ETA? Sometimes debugging helps :)

NB I believe this attached debugger flow was not well documented. But it's formally a breaking change. Please mention this in release notes. For your consideration.

@JustinGrote
Copy link
Collaborator

@nightroman the goal is to not break existing configs, we are working on it in the linked PR and will note back here if we find it.

@github-project-automation github-project-automation bot moved this from In Progress to Done in Flying Fox Jan 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

5 participants