private void EnterScriptFunction(FunctionContext functionContext) { InvocationInfo automaticVariable = (InvocationInfo)functionContext._localsTuple.GetAutomaticVariable(AutomaticVariable.MyInvocation); ScriptBlock block = functionContext._scriptBlock; CallStackInfo item = new CallStackInfo { InvocationInfo = automaticVariable, ScriptBlock = block, FunctionContext = functionContext, IsFrameHidden = block.DebuggerHidden }; this._callStack.Add(item); if (this._context._debuggingMode > 0) //TODO: REVIEW: Why was 0?? { ExternalScriptInfo myCommand = automaticVariable.MyCommand as ExternalScriptInfo; if (myCommand != null) { this.RegisterScriptFile(myCommand); } bool flag = this.CheckCommand(automaticVariable); this.SetupBreakpoints(functionContext); if ((block.DebuggerStepThrough && (this._overOrOutFrame == null)) && (this._steppingMode == SteppingMode.StepIn)) { this.ResumeExecution(DebuggerResumeAction.StepOut); } if (flag) { this.OnSequencePointHit(functionContext); } if (((this._context.PSDebugTraceLevel > 1) && !block.DebuggerStepThrough) && !block.DebuggerHidden) { this.TraceScriptFunctionEntry(functionContext); } } }
internal void ExitScriptFunction() { if (this._callStack.Last <CallStackInfo>() == this._overOrOutFrame) { this._overOrOutFrame = null; } this._callStack.RemoveAt(this._callStack.Count - 1); if (this._callStack.Count == 0) { this._steppingMode = SteppingMode.None; } }
internal void OnSequencePointHit(FunctionContext functionContext) { Func <LineBreakpoint, bool> predicate = null; if ((this._context.ShouldTraceStatement && !this._callStack.Last <CallStackInfo>().IsFrameHidden) && !functionContext._scriptBlock.DebuggerStepThrough) { this.TraceLine(functionContext.CurrentPosition); } if ((this._steppingMode == SteppingMode.StepIn) && ((this._overOrOutFrame == null) || (this._callStack.Last <CallStackInfo>() == this._overOrOutFrame))) { if (!this._callStack.Last <CallStackInfo>().IsFrameHidden) { this._overOrOutFrame = null; this.StopOnSequencePoint(functionContext, _emptyBreakpointList); } else if (this._overOrOutFrame == null) { this.ResumeExecution(DebuggerResumeAction.StepOut); } } else { if (functionContext._breakPoints == null) { this.SetupBreakpoints(functionContext); } if (functionContext._breakPoints[functionContext._currentSequencePointIndex]) { if (predicate == null) { predicate = breakpoint => (breakpoint.SequencePointIndex == functionContext._currentSequencePointIndex) && breakpoint.Enabled; } List <Breakpoint> breakpoints = functionContext._boundBreakpoints.Where <LineBreakpoint>(predicate).ToList <Breakpoint>(); breakpoints = this.TriggerBreakpoints(breakpoints); if (breakpoints.Any <Breakpoint>()) { this.StopOnSequencePoint(functionContext, breakpoints); } } } }
private void ResumeExecution(DebuggerResumeAction action) { switch (action) { case DebuggerResumeAction.Continue: break; case DebuggerResumeAction.StepInto: this._steppingMode = SteppingMode.StepIn; this._overOrOutFrame = null; return; case DebuggerResumeAction.StepOut: if (this._callStack.Count <= 1) { break; } this._steppingMode = SteppingMode.StepIn; this._overOrOutFrame = this._callStack[this._callStack.Count - 2]; return; case DebuggerResumeAction.StepOver: this._steppingMode = SteppingMode.StepIn; this._overOrOutFrame = this._callStack.Last <CallStackInfo>(); return; case DebuggerResumeAction.Stop: this._steppingMode = SteppingMode.None; this._overOrOutFrame = null; throw new TerminateException(); default: return; } this._steppingMode = SteppingMode.None; this._overOrOutFrame = null; }
private void ResumeExecution(DebuggerResumeAction action) { switch (action) { case DebuggerResumeAction.Continue: break; case DebuggerResumeAction.StepInto: this._steppingMode = SteppingMode.StepIn; this._overOrOutFrame = null; return; case DebuggerResumeAction.StepOut: if (this._callStack.Count <= 1) { break; } this._steppingMode = SteppingMode.StepIn; this._overOrOutFrame = this._callStack[this._callStack.Count - 2]; return; case DebuggerResumeAction.StepOver: this._steppingMode = SteppingMode.StepIn; this._overOrOutFrame = this._callStack.Last<CallStackInfo>(); return; case DebuggerResumeAction.Stop: this._steppingMode = SteppingMode.None; this._overOrOutFrame = null; throw new TerminateException(); default: return; } this._steppingMode = SteppingMode.None; this._overOrOutFrame = null; }
internal void ExitScriptFunction() { if (this._callStack.Last<CallStackInfo>() == this._overOrOutFrame) { this._overOrOutFrame = null; } this._callStack.RemoveAt(this._callStack.Count - 1); if (this._callStack.Count == 0) { this._steppingMode = SteppingMode.None; } }
internal void OnSequencePointHit(FunctionContext functionContext) { Func<LineBreakpoint, bool> predicate = null; if ((this._context.ShouldTraceStatement && !this._callStack.Last<CallStackInfo>().IsFrameHidden) && !functionContext._scriptBlock.DebuggerStepThrough) { this.TraceLine(functionContext.CurrentPosition); } if ((this._steppingMode == SteppingMode.StepIn) && ((this._overOrOutFrame == null) || (this._callStack.Last<CallStackInfo>() == this._overOrOutFrame))) { if (!this._callStack.Last<CallStackInfo>().IsFrameHidden) { this._overOrOutFrame = null; this.StopOnSequencePoint(functionContext, _emptyBreakpointList); } else if (this._overOrOutFrame == null) { this.ResumeExecution(DebuggerResumeAction.StepOut); } } else { if (functionContext._breakPoints == null) { this.SetupBreakpoints(functionContext); } if (functionContext._breakPoints[functionContext._currentSequencePointIndex]) { if (predicate == null) { predicate = breakpoint => (breakpoint.SequencePointIndex == functionContext._currentSequencePointIndex) && breakpoint.Enabled; } List<Breakpoint> breakpoints = functionContext._boundBreakpoints.Where<LineBreakpoint>(predicate).ToList<Breakpoint>(); breakpoints = this.TriggerBreakpoints(breakpoints); if (breakpoints.Any<Breakpoint>()) { this.StopOnSequencePoint(functionContext, breakpoints); } } } }
// Called from generated code on entering the script function, called once for each dynamicparam, begin, or end // block, and once for each object written to the pipeline. Also called when entering a trap. internal void EnterScriptFunction(FunctionContext functionContext) { Diagnostics.Assert(functionContext._executionContext == _context, "Wrong debugger is being used."); var invocationInfo = (InvocationInfo)functionContext._localsTuple.GetAutomaticVariable(AutomaticVariable.MyInvocation); var newCallStackInfo = new CallStackInfo { InvocationInfo = invocationInfo, File = functionContext._file, DebuggerStepThrough = functionContext._debuggerStepThrough, FunctionContext = functionContext, IsFrameHidden = functionContext._debuggerHidden, }; _callStack.Add(newCallStackInfo); if (_context._debuggingMode > 0) { var scriptCommandInfo = invocationInfo.MyCommand as ExternalScriptInfo; if (scriptCommandInfo != null) { RegisterScriptFile(scriptCommandInfo); } bool checkLineBp = CheckCommand(invocationInfo); SetupBreakpoints(functionContext); if (functionContext._debuggerStepThrough && _overOrOutFrame == null && _steppingMode == SteppingMode.StepIn) { // Treat like step out, but only if we're not already stepping out ResumeExecution(DebuggerResumeAction.StepOut); } if (checkLineBp) { OnSequencePointHit(functionContext); } if (_context.PSDebugTraceLevel > 1 && !functionContext._debuggerStepThrough && !functionContext._debuggerHidden) { TraceScriptFunctionEntry(functionContext); } } }
private void EnterScriptFunction(FunctionContext functionContext) { InvocationInfo automaticVariable = (InvocationInfo) functionContext._localsTuple.GetAutomaticVariable(AutomaticVariable.MyInvocation); ScriptBlock block = functionContext._scriptBlock; CallStackInfo item = new CallStackInfo { InvocationInfo = automaticVariable, ScriptBlock = block, FunctionContext = functionContext, IsFrameHidden = block.DebuggerHidden }; this._callStack.Add(item); if (this._context._debuggingMode > 0) //TODO: REVIEW: Why was 0?? { ExternalScriptInfo myCommand = automaticVariable.MyCommand as ExternalScriptInfo; if (myCommand != null) { this.RegisterScriptFile(myCommand); } bool flag = this.CheckCommand(automaticVariable); this.SetupBreakpoints(functionContext); if ((block.DebuggerStepThrough && (this._overOrOutFrame == null)) && (this._steppingMode == SteppingMode.StepIn)) { this.ResumeExecution(DebuggerResumeAction.StepOut); } if (flag) { this.OnSequencePointHit(functionContext); } if (((this._context.PSDebugTraceLevel > 1) && !block.DebuggerStepThrough) && !block.DebuggerHidden) { this.TraceScriptFunctionEntry(functionContext); } } }
private void RestoreCallStack(CallStackInfo item) { if (item != null) { _callStack.Add(item); } }
private Debugger PopActiveDebugger() { Debugger poppedDebugger = null; if (_activeDebuggers.TryPop(out poppedDebugger)) { int runningJobCount; lock (_syncObject) { runningJobCount = _runningJobs.Count; } if (runningJobCount == 0) { // If we are back to the root debugger and are in step mode, ensure // that the root debugger is in step mode to continue stepping. switch (_lastActiveDebuggerAction) { case DebuggerResumeAction.StepInto: case DebuggerResumeAction.StepOver: case DebuggerResumeAction.StepOut: // Set script debugger to step mode after the WF running // script completes. _steppingMode = SteppingMode.StepIn; _overOrOutFrame = _nestedRunningFrame; _nestedRunningFrame = null; break; case DebuggerResumeAction.Stop: _nestedDebuggerStop = true; break; default: ResumeExecution(DebuggerResumeAction.Continue); break; } // Allow script debugger to continue in debugging mode. _processingOutputCount = 0; SetInternalDebugMode(InternalDebugMode.Enabled); _currentDebuggerAction = _lastActiveDebuggerAction; _lastActiveDebuggerAction = DebuggerResumeAction.Continue; } } return poppedDebugger; }
private bool PushActiveDebugger(Debugger debugger, int callstackOffset) { // Don't push active debugger if script debugger disabled debugging. if (_context._debuggingMode == -1) { return false; } // Disable script debugging while another debugger is running. // -1 - Indicates script debugging is disabled from script debugger. // -2 - Indicates script debugging is disabled from pushed active debugger. SetInternalDebugMode(InternalDebugMode.InPushedStop); // Save running calling frame. _nestedRunningFrame = _callStack[_callStack.Count - callstackOffset]; _commandProcessor.Reset(); // Make active debugger. _activeDebuggers.Push(debugger); return true; }
/// <summary> /// Resumes execution after a breakpoint/step event has been handled /// </summary> private void ResumeExecution(DebuggerResumeAction action) { _previousDebuggerAction = _currentDebuggerAction; _currentDebuggerAction = action; switch (action) { case DebuggerResumeAction.StepInto: _steppingMode = SteppingMode.StepIn; _overOrOutFrame = null; break; case DebuggerResumeAction.StepOut: if (_callStack.Count > 1) { // When we pop to the parent frame, we'll clear _overOrOutFrame (so OnSequencePointHit // will stop) and continue with a step. _steppingMode = SteppingMode.StepIn; _overOrOutFrame = _callStack[_callStack.Count - 2]; } else { // Stepping out of the top frame is just like continue (allow hitting // breakpoints in the current frame, but otherwise just go.) goto case DebuggerResumeAction.Continue; } break; case DebuggerResumeAction.StepOver: _steppingMode = SteppingMode.StepIn; _overOrOutFrame = _callStack.Last(); break; case DebuggerResumeAction.Continue: // nothing to do, just continue _steppingMode = SteppingMode.None; _overOrOutFrame = null; break; case DebuggerResumeAction.Stop: _steppingMode = SteppingMode.None; _overOrOutFrame = null; throw new TerminateException(); default: Debug.Assert(false, "Received an unknown action: " + action); break; } }
internal void Add(CallStackInfo item) { lock (_callStackList) { _callStackList.Add(item); } }