Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions src/System.Management.Automation/engine/debugger/debugger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3013,7 +3013,6 @@ private void AddToJobRunningList(PSJobStartEventArgs jobArgs, DebuggerResumeActi

_runningJobs.Add(jobArgs.Job.InstanceId, jobArgs);
jobArgs.Debugger.DebuggerStop += HandleMonitorRunningJobsDebuggerStop;
jobArgs.Debugger.BreakpointUpdated += HandleBreakpointUpdated;

newJob = true;
}
Expand Down Expand Up @@ -3090,7 +3089,6 @@ private void RemoveFromRunningJobList(Job job)
if (_runningJobs.TryGetValue(job.InstanceId, out jobArgs))
{
jobArgs.Debugger.DebuggerStop -= HandleMonitorRunningJobsDebuggerStop;
jobArgs.Debugger.BreakpointUpdated -= HandleBreakpointUpdated;
_runningJobs.Remove(job.InstanceId);
}
}
Expand Down Expand Up @@ -3308,28 +3306,6 @@ private bool IsJobDebuggingMode()
(((DebugMode & DebugModes.RemoteScript) == DebugModes.RemoteScript) && !IsLocalSession));
}

private void HandleBreakpointUpdated(object sender, BreakpointUpdatedEventArgs e)
{
switch (e.UpdateType)
{
case BreakpointUpdateType.Set:
AddNewBreakpoint(e.Breakpoint);
break;

case BreakpointUpdateType.Removed:
RemoveBreakpoint(e.Breakpoint);
break;

case BreakpointUpdateType.Enabled:
EnableBreakpoint(e.Breakpoint);
break;

case BreakpointUpdateType.Disabled:
DisableBreakpoint(e.Breakpoint);
break;
}
}

private bool IsRunningWFJobsDebugger(Debugger debugger)
{
lock (_syncObject)
Expand Down Expand Up @@ -3528,7 +3504,6 @@ private void RemoveFromRunningRunspaceList(Runspace runspace)
if (nestedDebugger != null)
{
nestedDebugger.DebuggerStop -= HandleMonitorRunningRSDebuggerStop;
nestedDebugger.BreakpointUpdated -= HandleBreakpointUpdated;
nestedDebugger.Dispose();

// If current active debugger, then pop.
Expand Down Expand Up @@ -3698,7 +3673,6 @@ private bool SetUpDebuggerOnRunspace(Runspace runspace)
runspaceInfo.NestedDebugger = nestedDebugger;

nestedDebugger.DebuggerStop += HandleMonitorRunningRSDebuggerStop;
nestedDebugger.BreakpointUpdated += HandleBreakpointUpdated;

if (((_lastActiveDebuggerAction == DebuggerResumeAction.StepInto) || (_currentDebuggerAction == DebuggerResumeAction.StepInto)) &&
!nestedDebugger.IsActive)
Expand Down
15 changes: 8 additions & 7 deletions test/powershell/SDK/Breakpoint.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,6 @@ Describe 'Breakpoint SDK Unit Tests' -Tags 'CI' {

Context 'Managing breakpoints in a remote runspace via the SDK' {

AfterAll {
# Get rid of any breakpoints that were created in the default runspace.
# This is necessary due to a known bug that causes breakpoints with the
# same id to be created or updated in the default runspace.
Get-PSBreakpoint | Remove-PSBreakpoint
}

It 'Can set command breakpoints' {
$jobRunspace.Debugger.SetCommandBreakpoint('Write-Verbose', { break }) | Should -BeOfType [System.Management.Automation.CommandBreakpoint]
}
Expand Down Expand Up @@ -115,6 +108,14 @@ Describe 'Breakpoint SDK Unit Tests' -Tags 'CI' {
}
}

It 'Doesn''t manipulate any breakpoints in the default runspace' {
# Issue https://github.com/PowerShell/PowerShell/issues/10167 fix:
# Ensure that breakpoints were not created in the default runspace.
# Prior to this issue being fixed, breakpoints with the same id
# would be created or updated in the default runspace.
$host.Runspace.Debugger.GetBreakpoints() | Should -BeNullOrEmpty
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test cases should be independent.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But this is not blocking.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TravisEz13 A question about this for my own knowledge: by independent do you mean that the specific test for that issue should be in a different Describe or Context invocation? Or do you mean that the comments shouldn't be there, because they infer a dependency between that test and the issue it resolves?

}

It 'Can remove breakpoints' {
foreach ($bp in $jobRunspace.Debugger.GetBreakpoints()) {
$jobRunspace.Debugger.RemoveBreakpoint($bp) | Should -BeTrue
Expand Down