/// <summary> /// Step is called /// </summary> private Jint.Runtime.Debugger.StepMode JreStep(object sender, Jint.Runtime.Debugger.DebugInformation e) { if (this.m_stepMode.HasValue && (this.m_stepMode == StepMode.Over || this.m_stepMode == StepMode.Into) || this.m_isStepRegistered || this.Breakpoints.Contains(e.CurrentStatement.Location.Start.Line)) { var col = Console.ForegroundColor; Console.ForegroundColor = this.GetResponseColor(); this.m_prompt = $"{e.CurrentStatement.LabelSet?.Name ?? this.m_loadFile} @ {e.CurrentStatement.Location.Start.Line} (step) >"; this.m_currentDebug = e; int l = Console.CursorLeft; Console.CursorLeft = 0; Console.Write(new string(' ', l)); Console.CursorLeft = 0; if (this.m_blocPrint) { this.PrintBlock(); } else { this.PrintLoc(); } Console.ForegroundColor = col; this.Prompt(); this.m_resetEvent.Wait(); this.m_resetEvent.Reset(); this.m_currentDebug = null; return(this.m_stepMode ?? StepMode.Into); } else { return(StepMode.Into); } }
internal StepMode? InvokeBreakEvent(DebugInformation info) { if (Break != null) { return Break(this, info); } return null; }
internal StepMode? InvokeStepEvent(DebugInformation info) { if (Step != null) { return Step(this, info); } return null; }
private StepMode EngineStepVerifyDebugInfo(object sender, DebugInformation debugInfo) { Assert.NotNull(sender); Assert.IsType(typeof(Engine), sender); Assert.NotNull(debugInfo); Assert.NotNull(debugInfo.CallStack); Assert.NotNull(debugInfo.CurrentStatement); Assert.NotNull(debugInfo.Locals); Assert.Equal(1, debugInfo.CallStack.Count); Assert.Equal("func1()", debugInfo.CallStack.Peek()); Assert.Contains(debugInfo.Globals, kvp => kvp.Key.Equals("global", StringComparison.Ordinal) && kvp.Value.AsBoolean() == true); Assert.Contains(debugInfo.Globals, kvp => kvp.Key.Equals("local", StringComparison.Ordinal) && kvp.Value.AsBoolean() == false); Assert.Contains(debugInfo.Locals, kvp => kvp.Key.Equals("local", StringComparison.Ordinal) && kvp.Value.AsBoolean() == false); Assert.DoesNotContain(debugInfo.Locals, kvp => kvp.Key.Equals("global", StringComparison.Ordinal)); countBreak++; return stepMode; }
private StepMode EngineStepOutWhenInsideFunction(object sender, DebugInformation debugInfo) { Assert.NotNull(sender); Assert.IsType(typeof(Engine), sender); Assert.NotNull(debugInfo); countBreak++; if (debugInfo.CallStack.Count > 0) return StepMode.Out; return StepMode.Into; }
private StepMode EngineStep(object sender, DebugInformation debugInfo) { Assert.NotNull(sender); Assert.IsType(typeof(Engine), sender); Assert.NotNull(debugInfo); countBreak++; return stepMode; }
private DebugInformation CreateDebugInformation(Statement statement) { var info = new DebugInformation { CurrentStatement = statement, CallStack = _debugCallStack }; if (_engine.ExecutionContext != null && _engine.ExecutionContext.LexicalEnvironment != null) { var lexicalEnvironment = _engine.ExecutionContext.LexicalEnvironment; info.Locals = GetLocalVariables(lexicalEnvironment); info.Globals = GetGlobalVariables(lexicalEnvironment); } return info; }