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

Unable to set breakpoints in PowerShell function #2204

Closed
yobyot opened this issue Jul 2, 2020 · 4 comments
Closed

Unable to set breakpoints in PowerShell function #2204

yobyot opened this issue Jul 2, 2020 · 4 comments

Comments

@yobyot
Copy link

yobyot commented Jul 2, 2020

I am unable to set breakpoints in a PowerShell function using VS Code with the Azure Functions extension. Debugging the same function script in a console debugging session works fine.

The machine environment is:

  • macOS 10.15.5
  • pwsh 7.02
  • VS Code 1.46.1
  • ms-azuretools.vscode-azurefunctions 0.22.1

Linked below are two animated gifs showing the same script on the same machine in debug mode. In both cases, the attempt is to set a breakpoint on line 19 of the function script and when the debugger stops inspect a variable named $subGuid

As you can see in the console session, this works.

However, in the VS Code debug session, the script first stops at the "wrong" place. This is described in the doc which then says you can set the proper breakpoints.

In my case, it doesn't matter if the breakpoints are set before attaching the debugger or after the first pause, continuing the debugging session in VS Code does not stop at the breakpoints set. The script does run to completion but it produces no console output on any pwsh stream (I am using 6 -- Information).

Here's a link the to successful console debugging session.

And here's a link to the unsuccessful console debugging session

@ejizba
Copy link
Member

ejizba commented Jul 7, 2020

Dupe of #1661. At the moment, you have to use Wait-Debugger instead of a breakpoint

@ejizba ejizba closed this as completed Jul 7, 2020
@yobyot
Copy link
Author

yobyot commented Jul 7, 2020

Based on #1661, I'm not sure this is a dupe. What you can't see in the recordings is that there is a Wait-Debugger statement in the function code. What happens is that when the session attaches to the runspace, the debugger stops in odd places (documented but a disaster of its own) and then whether or not there are breakpoints in the function script, as soon as you hit F11 (step in) or F5 (run) all it does is hang.

All in all, with odd debugging directives required in the code, stopping where it isn't supposed to, not stopping where it is, lousy doc/examples and just generally being hard to use you could label PowerShell function local debugging a hot mess, IMHO.

@ejizba
Copy link
Member

ejizba commented Jul 7, 2020

the debugger stops in odd places

Like this? #1660

All in all, with odd statements debugging directive required in the code, stopping where it isn't supposed to, not stopping where it is, lousy doc/examples and just generally being hard to use you could label PowerShell function local debugging a hot mess, IMHO.

I 100% agree. That's why it's the only language labeled "Preview" when creating a project through our extension:
Screen Shot 2020-07-07 at 2 25 43 PM

Unfortunately, most of the problems stem from PowerShell itself, so we had very little control over on the VS Code side. They are supposed to be fixed in PowerShell 7, which Azure Functions should officially support soon.

@yobyot
Copy link
Author

yobyot commented Jul 8, 2020

$endlessPreview = $true
while ($endlessPreview) {
    $useability = $null
    $reliability = $null
    $documentation = $null
    Write-Host "Blame the other product"
}

@vscodebot vscodebot bot locked and limited conversation to collaborators Aug 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants