Set-PSBreakpoint allows you to set the same breakpoint again, and again, and again
See original GitHub issueThe Set-PSBreakpoint
command allows you to set a breakpoint multiple times. Most users never encounter this because if they debug and use breakpoints, they do so from Visual Studio Code or PowerShell ISE. For users who use the command line and set breakpoints that way, this behavior leads to additional breakpoints being created that are not necessary and do not add any value to their debugging experience.
Steps to reproduce
Set-PSBreakpoint -Command Get-Process
Set-PSBreakpoint -Command Get-Process
Set-PSBreakpoint -Command Get-Process
Expected behavior
ID Script Line Command Variable Action
-- ------ ---- ------- -------- ------
0 Get-Process
Actual behavior
ID Script Line Command Variable Action
-- ------ ---- ------- -------- ------
0 Get-Process
ID Script Line Command Variable Action
-- ------ ---- ------- -------- ------
1 Get-Process
ID Script Line Command Variable Action
-- ------ ---- ------- -------- ------
2 Get-Process
Environment data
Name Value
---- -----
PSVersion 6.2.1
PSEdition Core
GitCommitId 6.2.1
OS Microsoft Windows 10.0.17763
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Desired outcome
I would like to change this behavior such that Set-PSBreakpoint
does not create duplicates, by having it look at existing breakpoints when a breakpoint is set. If an exact match is found, that breakpoint is returned to the caller. Otherwise, the new breakpoint is set and returned to the caller. There is no value in allowing multiple breakpoints that are 100% identical to be set in a debugger. In fact, graphical debuggers don’t allow you to do this, so the command line shouldn’t either.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:6 (4 by maintainers)
In my example it breaks once, but shows three triggering breakpoints that only differ by their ID when it does.
Here’s exactly what is shown in the console:
@KirkMunro Don’t forget about actions. Each breakpoint object can have it’s own action q.e.d multiple breakpoints are necessary.