PowerShell / PowerShell/PowerShell

Debugging: `Set-PSBreakpoint -Command` is triggered for each invocation of a `ForEach-Object` script block inside a targeted function

Open
#24,251 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Needs-Triage
Dominant language
C#
Stars
55.5k
Forks
8.5k
Avg merge
1d 2h
Merged PRs (30d)
88

Description

Prerequisites
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 foo function.

  • Submit o to 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
image

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.