mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Remove the event handler that was causing breakpoint changes to be erroneously replicated to the host runspace debugger (#10503)
* fix #10167 * Update test/powershell/SDK/Breakpoint.Tests.ps1 Co-Authored-By: Ilya <darpa@yandex.ru>
This commit is contained in:
committed by
msftbot[bot]
co-authored by
Ilya
parent
139cd942b2
commit
096a78fbe3
@@ -3013,7 +3013,6 @@ namespace System.Management.Automation
|
||||
|
||||
_runningJobs.Add(jobArgs.Job.InstanceId, jobArgs);
|
||||
jobArgs.Debugger.DebuggerStop += HandleMonitorRunningJobsDebuggerStop;
|
||||
jobArgs.Debugger.BreakpointUpdated += HandleBreakpointUpdated;
|
||||
|
||||
newJob = true;
|
||||
}
|
||||
@@ -3090,7 +3089,6 @@ namespace System.Management.Automation
|
||||
if (_runningJobs.TryGetValue(job.InstanceId, out jobArgs))
|
||||
{
|
||||
jobArgs.Debugger.DebuggerStop -= HandleMonitorRunningJobsDebuggerStop;
|
||||
jobArgs.Debugger.BreakpointUpdated -= HandleBreakpointUpdated;
|
||||
_runningJobs.Remove(job.InstanceId);
|
||||
}
|
||||
}
|
||||
@@ -3308,28 +3306,6 @@ namespace System.Management.Automation
|
||||
(((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)
|
||||
@@ -3528,7 +3504,6 @@ namespace System.Management.Automation
|
||||
if (nestedDebugger != null)
|
||||
{
|
||||
nestedDebugger.DebuggerStop -= HandleMonitorRunningRSDebuggerStop;
|
||||
nestedDebugger.BreakpointUpdated -= HandleBreakpointUpdated;
|
||||
nestedDebugger.Dispose();
|
||||
|
||||
// If current active debugger, then pop.
|
||||
@@ -3698,7 +3673,6 @@ namespace System.Management.Automation
|
||||
runspaceInfo.NestedDebugger = nestedDebugger;
|
||||
|
||||
nestedDebugger.DebuggerStop += HandleMonitorRunningRSDebuggerStop;
|
||||
nestedDebugger.BreakpointUpdated += HandleBreakpointUpdated;
|
||||
|
||||
if (((_lastActiveDebuggerAction == DebuggerResumeAction.StepInto) || (_currentDebuggerAction == DebuggerResumeAction.StepInto)) &&
|
||||
!nestedDebugger.IsActive)
|
||||
|
||||
@@ -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]
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
|
||||
It 'Can remove breakpoints' {
|
||||
foreach ($bp in $jobRunspace.Debugger.GetBreakpoints()) {
|
||||
$jobRunspace.Debugger.RemoveBreakpoint($bp) | Should -BeTrue
|
||||
|
||||
Reference in New Issue
Block a user