internal Debugger(ExecutionContext context) { this._context = context; this._runningScriptStack = new Stack <Debugger.ScriptBlockInfo>(); this._scriptPathToBreakpointInfo = new Dictionary <string, ScriptBreakpointInfo>((IEqualityComparer <string>)StringComparer.OrdinalIgnoreCase); this._scriptPathToDebugInfo = new Dictionary <string, ScriptDebugInfo>((IEqualityComparer <string>)StringComparer.OrdinalIgnoreCase); this._statementStack = new Stack <ParseTreeNode>(); this._globalScriptBreakpointInfo = new ScriptBreakpointInfo(context, (string)null); this._currentScriptDebugInfo = (ScriptDebugInfo)null; this._inBreakpoint = false; this._idToBreakpoint = new Dictionary <int, Breakpoint>(); this._steppingMode = Debugger.SteppingMode.None; this._callStack = new Stack <Debugger.CallStackInfo>(); this._evaluatingBreakpointAction = false; }
internal void PushMethodCall(InvocationInfo invocationInfo, ScriptBlock scriptBlock) { this._callStack.Push(new Debugger.CallStackInfo() { InvocationInfo = invocationInfo, ScriptBlock = scriptBlock }); if (scriptBlock.IsScriptBlockForExceptionHandler && this._steppingMode == Debugger.SteppingMode.StepOver) { this._steppingMode = Debugger.SteppingMode.StepIn; } if (invocationInfo.InvocationName == "") { this._steppingMode = Debugger.SteppingMode.None; } if (this._steppingMode == Debugger.SteppingMode.None || this._steppingMode != Debugger.SteppingMode.StepOut && this._steppingMode != Debugger.SteppingMode.StepOver) { return; } ++this._stepCallDepth; }
internal void PopRunning() { Debugger.ScriptBlockInfo scriptBlockInfo1 = this._runningScriptStack.Pop(); if (scriptBlockInfo1.DebugInfo != null) { --scriptBlockInfo1.DebugInfo.NumReferences; if (scriptBlockInfo1.DebugInfo.NumReferences == 0) { if (scriptBlockInfo1.DebugInfo.FromScript) { this._scriptPathToDebugInfo.Remove(scriptBlockInfo1.DebugInfo.BreakpointInfo.ScriptPath); } if (scriptBlockInfo1.DebugInfo.BreakpointInfo.NumBreakpoints == 0) { this._scriptPathToBreakpointInfo.Remove(scriptBlockInfo1.DebugInfo.BreakpointInfo.ScriptPath); } } } if (!this.IsOn) { return; } if (this._runningScriptStack.Count > 0) { Debugger.ScriptBlockInfo scriptBlockInfo2 = this._runningScriptStack.Peek(); if (scriptBlockInfo2.DebugInfo != null && scriptBlockInfo2.DebugInfo.IsRecursive) { scriptBlockInfo2.DebugInfo.SetBreakpoints(scriptBlockInfo2.ScriptBlock); } this._currentScriptDebugInfo = scriptBlockInfo2.DebugInfo; } else { this._currentScriptDebugInfo = (ScriptDebugInfo)null; this._steppingMode = Debugger.SteppingMode.None; } }
private void OnDebuggerStop(InvocationInfo invocationInfo, List <Breakpoint> breakpoints) { LocalRunspace currentRunspace = this._context.CurrentRunspace as LocalRunspace; if (currentRunspace.PulsePipeline != null && currentRunspace.PulsePipeline == currentRunspace.GetCurrentlyRunningPipeline()) { if (breakpoints.Count > 0) { this._context.EngineHostInterface.UI.WriteWarningLine(ResourceManagerCache.FormatResourceString("DebuggerStrings", "WarningBreakpointWillNotBeHit", (object)breakpoints[0])); } else { this._context.EngineHostInterface.UI.WriteWarningLine(new InvalidOperationException().Message); } } else { this._steppingMode = Debugger.SteppingMode.None; EventHandler <DebuggerStopEventArgs> debuggerStop = this.DebuggerStop; if (debuggerStop == null) { return; } this._inBreakpoint = true; if (invocationInfo != null) { this._callStack.Push(new Debugger.CallStackInfo() { InvocationInfo = invocationInfo }); } this._context.SetVariable("PSDebugContext", (object)new PSDebugContext(invocationInfo, breakpoints)); PSLanguageMode languageMode = this._context.LanguageMode; bool flag = languageMode != PSLanguageMode.FullLanguage && this._context.UseFullLanguageModeInDebugger; if (flag) { this._context.LanguageMode = PSLanguageMode.FullLanguage; } RunspaceAvailability runspaceAvailability = this._context.CurrentRunspace.RunspaceAvailability; this._context.CurrentRunspace.UpdateRunspaceAvailability(this._context.CurrentRunspace.GetCurrentlyRunningPipeline() != null ? RunspaceAvailability.AvailableForNestedCommand : RunspaceAvailability.Available, true); try { DebuggerStopEventArgs e = new DebuggerStopEventArgs(invocationInfo, breakpoints); debuggerStop((object)this, e); this.ResumeExecution(e); } finally { this._context.CurrentRunspace.UpdateRunspaceAvailability(runspaceAvailability, true); if (flag) { this._context.LanguageMode = languageMode; } this._context.RemoveVariable("PSDebugContext"); if (invocationInfo != null) { this._callStack.Pop(); } this._inBreakpoint = false; } } }
private void SetStep(string name, Debugger.SteppingMode mode, int stepCallDepth) { this._steppingMode = mode; this._stepCallDepth = stepCallDepth; }