PowerShell / PowerShell/PowerShell
Debugging: `Set-PSBreakpoint -Command` is triggered for each invocation of a `ForEach-Object` script block inside a targeted function
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 55.5k
- Forks
- 8.5k
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 88
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
Run the following:
function foo {
1..3 | ForEach-Object { '#' + $i }
}
$bp = Set-PSBreakpoint -Command foo
foo
$bp | Remove-PSBreakpoint
-
The debugger is entered and execution stops before the first statement of the
foofunction. -
Submit
oto step out of the function.
Expected behavior
The debugger should step out of the function.
Actual behavior
Instead of exiting the function, execution breaks at the start of the ForEach-Object script block, preceded by message Hit Command breakpoint on 'foo', as if the function had been invoked again.
Error details
No response
Environment data
PowerShell 7.5.0-preview.3
Visuals
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the reproduction steps with Set-PSBreakpoint, ForEach-Object, and the debugger's step-out command. The issue names no source file, test, or entry point, so locate the command-breakpoint and stepping implementation from the debugger behavior. Done means stepping out of foo no longer triggers a breakpoint inside its ForEach-Object script block.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- powershell
- Domain
- cli, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100