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
19 changes: 15 additions & 4 deletions src/System.Management.Automation/engine/debugger/debugger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1237,9 +1237,8 @@ internal void RemoveBreakpoint(Breakpoint breakpoint)

breakpoint.RemoveSelf(this);

if (_idToBreakpoint.Count == 0)
if (CanDisableDebugger)
{
// The last breakpoint was removed, turn off debugging.
SetInternalDebugMode(InternalDebugMode.Disabled);
}

Expand Down Expand Up @@ -2099,6 +2098,19 @@ private bool CanEnableDebugger
}
}

private bool CanDisableDebugger
{
get
{
// The debugger can be disbled if there are no breakpoints
// left and if we are not currently stepping in the debugger.
return _idToBreakpoint.Count == 0 &&
_currentDebuggerAction != DebuggerResumeAction.StepInto &&
_currentDebuggerAction != DebuggerResumeAction.StepOver &&
_currentDebuggerAction != DebuggerResumeAction.StepOut;
}
}

private static bool IsSystemLockedDown
{
get
Expand Down Expand Up @@ -3857,9 +3869,8 @@ internal void DisableTracing()
_context.IgnoreScriptDebug = _savedIgnoreScriptDebug;
_context.PSDebugTraceLevel = 0;
_context.PSDebugTraceStep = false;
if (!_idToBreakpoint.Any())
if (CanDisableDebugger)
{
// Only disable debug mode if there are no breakpoints.
SetInternalDebugMode(InternalDebugMode.Disabled);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public static ScriptBlock Create(string script) => Create(
fileContents: script);

internal static ScriptBlock CreateDelayParsedScriptBlock(string script, bool isProductCode)
=> new ScriptBlock(new CompiledScriptBlockData(script, isProductCode));
=> new ScriptBlock(new CompiledScriptBlockData(script, isProductCode)) { DebuggerHidden = true };

/// <summary>
/// Returns a new scriptblock bound to a module. Any local variables in the
Expand Down
Loading