Skip to content

[Regression] Difference in behavior when using Debug-Runspace from Windows PowerShell and PowerShell 7 #13567

@TylerLeonhardt

Description

@TylerLeonhardt

Steps to reproduce

Open 2 PowerShell windows of the same version

create a file foo.ps1 that looks like this:

"hello"
Start-Sleep -Seconds 20
"boo"

In PowerShell one

PS > $pid | scb

In PowerShell two

PS > Enter-PSHostProcess -Id <PASTE>

In PowerShell one

PS > . .\foo.ps1

Hurry up and run In PowerShell two:

[Process: 2345] PS > Debug-Runspace 1

Expected behavior

This happens in Windows PowerShell

Debugging Runspace: Runspace1
To end the debugging session type the 'Detach' command at the debugger prompt, or type 'Ctrl+C' otherwise.

At C:\Users\tyleonha\Downloads\foo.ps1:3 char:1
+ "boo"
+ ~~~~~
[DBG]: [Process:30956]: [Runspace1]: PS C:\Users\tyleonha\Downloads>>

Actual behavior

This happens in PowerShell 7. Note it does not break into a debug prompt.

Debugging Runspace: Runspace1
To end the debugging session type the 'Detach' command at the debugger prompt, or type 'Ctrl+C' otherwise.


Command or script completed.
To end the debugging session type the 'Detach' command at the debugger prompt, or type 'Ctrl+C' otherwise.

Thoughts

Frankly I'm suspicious of my own PR way back when #11312 that changed this behavior. This parameter -BreakAll mentioned here:
#13527

should probably be -NoBreakAll or have some way to have it on by default and allow you to opt out. This will allow for backcompat for Windows PowerShell and the ability to toggle BreakAll.

Environment data

Name                           Value
----                           -----
GitCommitId                    7.1.0-daily.20200430
PSVersion                      7.1.0-daily.20200430
WSManStackVersion              3.0
Platform                       Unix
SerializationVersion           1.1.0.1
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
OS                             Darwin 19.6.0 Darwin Kernel Version 19.6.0: Thu Jun 18 20:49:00 PDT 2020; root:xnu-6153.141.1~1/RELEASE_X86_64
PSRemotingProtocolVersion      2.3
PSEdition                      Core

Although this bug existed in 7.0...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-BugIssue has been identified as a bug in the productResolution-No ActivityIssue has had no activity for 6 months or moreWG-Interactive-Debuggingdebugging PowerShell script

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions