private bool BpTest(Statement statement, BreakPoint breakpoint) { bool afterStart, beforeEnd; //afterStart = (breakpoint.Line == statement.Location.Start.Line && // breakpoint.Char >= statement.Location.Start.Column); //our breakpoint column always start with zero,so it don't need to compare the start column afterStart = (breakpoint.Line == statement.Location.Start.Line); if (!afterStart) { return(false); } beforeEnd = breakpoint.Line < statement.Location.End.Line || (breakpoint.Line == statement.Location.End.Line && breakpoint.Char <= statement.Location.End.Column); if (!beforeEnd) { return(false); } if (!string.IsNullOrEmpty(breakpoint.Condition)) { return(_engine.Execute(breakpoint.Condition).GetCompletionValue().AsBoolean()); } return(true); }
private bool BpTest(Statement statement, BreakPoint breakpoint) { bool afterStart, beforeEnd; afterStart = (breakpoint.Line == statement.Location.Start.Line && breakpoint.Char >= statement.Location.Start.Column); if (!afterStart) { return(false); } beforeEnd = breakpoint.Line < statement.Location.End.Line || (breakpoint.Line == statement.Location.End.Line && breakpoint.Char <= statement.Location.End.Column); if (!beforeEnd) { return(false); } if (!string.IsNullOrEmpty(breakpoint.Condition)) { return(_engine.Execute(breakpoint.Condition).GetCompletionValue().AsBoolean()); } return(true); }
internal DebugInformation(Engine engine, Node currentNode, Location currentLocation, JsValue returnValue, long currentMemoryUsage, PauseType pauseType, BreakPoint breakPoint) { _engine = engine; CurrentNode = currentNode; _currentLocation = currentLocation; _returnValue = returnValue; CurrentMemoryUsage = currentMemoryUsage; PauseType = pauseType; BreakPoint = breakPoint; }
internal void OnStep(Statement statement) { var old = _stepMode; if (statement == null) { return; } BreakPoint breakpoint = _engine.BreakPoints.FirstOrDefault(breakPoint => BpTest(statement, breakPoint)); bool breakpointFound = false; if (breakpoint != null) { DebugInformation info = CreateDebugInformation(statement); var result = _engine.InvokeBreakEvent(info); if (result.HasValue) { _stepMode = result.Value; breakpointFound = true; } } if (breakpointFound == false && _stepMode == StepMode.Into) { DebugInformation info = CreateDebugInformation(statement); var result = _engine.InvokeStepEvent(info); if (result.HasValue) { _stepMode = result.Value; } } //add StepMode.None to fix line 22 changed on this document if ((old == StepMode.Into || old == StepMode.None) && _stepMode == StepMode.Out) { _callBackStepOverDepth = _debugCallStack.Count; } else if ((old == StepMode.Into || old == StepMode.None) && _stepMode == StepMode.Over) { var expressionStatement = statement as ExpressionStatement; if (expressionStatement != null && expressionStatement.Expression is CallExpression) { _callBackStepOverDepth = _debugCallStack.Count; } else { _stepMode = StepMode.Into; } } }
private void CheckBreakPointAndPause(BreakLocation breakLocation, Node node = null, Location?location = null, JsValue returnValue = null) { CurrentLocation = location ?? node?.Location; BreakPoint breakpoint = BreakPoints.FindMatch(this, breakLocation); bool isStepping = _engine.CallStack.Count <= _steppingDepth; if (breakpoint != null || isStepping) { // Even if we matched a breakpoint, if we're stepping, the reason we're pausing is the step. // Still, we need to include the breakpoint at this location, in case the debugger UI needs to update // e.g. a hit count. Pause(isStepping ? PauseType.Step : PauseType.Break, node, location, returnValue, breakpoint); } _paused = false; }
private void Pause(PauseType type, Node node = null, Location?location = null, JsValue returnValue = null, BreakPoint breakPoint = null) { var info = new DebugInformation( engine: _engine, currentNode: node, currentLocation: location ?? node.Location, returnValue: returnValue, currentMemoryUsage: _engine.CurrentMemoryUsage, pauseType: type, breakPoint: breakPoint ); StepMode?result = type switch { // Conventionally, sender should be DebugHandler - but Engine is more useful PauseType.Step => Step?.Invoke(_engine, info), PauseType.Break => Break?.Invoke(_engine, info), PauseType.DebuggerStatement => Break?.Invoke(_engine, info), _ => throw new ArgumentException("Invalid pause type", nameof(type)) }; HandleNewStepMode(result); }
private bool BpTest(Statement statement, BreakPoint breakpoint) { bool afterStart, beforeEnd; afterStart = (breakpoint.Line == statement.Location.Start.Line && breakpoint.Char >= statement.Location.Start.Column); if (!afterStart) { return false; } beforeEnd = breakpoint.Line < statement.Location.End.Line || (breakpoint.Line == statement.Location.End.Line && breakpoint.Char <= statement.Location.End.Column); if (!beforeEnd) { return false; } if (!string.IsNullOrEmpty(breakpoint.Condition)) { return _engine.Execute(breakpoint.Condition).GetCompletionValue().AsBoolean(); } return true; }