public async Task AddRemoveBreakpoint() { const string code = @"x <- 1 y <- 2 z <- 3"; var tracer = await _session.TraceExecutionAsync(); using (var sf = new SourceFile(code)) { var bp1Loc = new RSourceLocation(sf.FilePath, 1); var bp1 = await tracer.CreateBreakpointAsync(bp1Loc); bp1.Location.Should().Be(bp1Loc); bp1.Tracer.Should().Be(tracer); tracer.Breakpoints.Count.Should().Be(1); var bp2Loc = new RSourceLocation(sf.FilePath, 3); var bp2 = await tracer.CreateBreakpointAsync(bp2Loc); bp2.Location.Should().Be(bp2Loc); bp2.Tracer.Should().Be(tracer); tracer.Breakpoints.Count.Should().Be(2); await bp1.DeleteAsync(); tracer.Breakpoints.Count.Should().Be(1); tracer.Breakpoints.First().Should().BeSameAs(bp2); } }
public async Task BreakpointsInDifferentFiles() { var tracer = await _session.TraceExecutionAsync(); using (var sf1 = new SourceFile("1")) using (var sf2 = new SourceFile($"eval(parse({sf1.FilePath.ToRStringLiteral()}))")) { await tracer.EnableBreakpointsAsync(true); var bp1Loc = new RSourceLocation(sf1.FilePath, 1); var bp1 = await tracer.CreateBreakpointAsync(bp1Loc); bp1.Location.Should().Be(bp1Loc); var bp2Loc = new RSourceLocation(sf2.FilePath, 1); var bp2 = await tracer.CreateBreakpointAsync(bp2Loc); bp2.Location.Should().Be(bp2Loc); tracer.Breakpoints.Should().HaveCount(2); var bp1Hit = new BreakpointHitDetector(bp1); var bp2Hit = new BreakpointHitDetector(bp2); await sf2.Source(_session); await bp2Hit.ShouldBeHitAtNextPromptAsync(); bp1Hit.WasHit.Should().BeFalse(); bp2Hit.Reset(); await tracer.ContinueAsync(); await bp1Hit.ShouldBeHitAtNextPromptAsync(); bp2Hit.WasHit.Should().BeFalse(); } }
public void Add(RSourceLocation location, string call) { Add(location.FileName, location.LineNumber, call); }
public void Add(RSourceLocation location, int offset = 0) { Add(location.FileName, location.LineNumber + offset, Any); }
public void Add(RSourceLocation location, int offset, string call) { Add(location.FileName, location.LineNumber + offset, call); }
public static Task ShouldBeAtAsync(this IRSession session, RSourceLocation location, int offset = 0) { return session.ShouldBeAtAsync(location.FileName, location.LineNumber + offset); }
public AD7BoundBreakpoint(AD7PendingBreakpoint pendingBreakpoint, RSourceLocation location, enum_PENDING_BP_STATE state) { PendingBreakpoint = pendingBreakpoint; Location = location; SetState((enum_BP_STATE)state); }
private async Task ProcessBrowsePromptWorker(IRSessionInteraction inter) { var frames = await Session.TracebackAsync(); // If there's .doTrace(rtvs:::breakpoint) anywhere on the stack, we're inside the internal machinery // that triggered Browse> prompt when hitting a breakpoint. We need to step out of it until we're // back at the frame where the breakpoint was actually set, so that those internal frames do not show // on the call stack, and further stepping does not try to step through them. // Since browserSetDebug-based step out is not reliable in the presence of loops, we'll just keep // stepping over with "n" until we're all the way out. Every step will trigger a new prompt, and // we will come back to this method again. var doTraceFrame = frames.FirstOrDefault(frame => IsDoTrace(frame)); if (doTraceFrame != null) { await inter.RespondAsync(Invariant($"n\n")); return; } IReadOnlyCollection<RBreakpoint> breakpointsHit = null; var lastFrame = frames.LastOrDefault(); if (lastFrame != null) { // Report breakpoints first, so that by the time step completion is reported, all actions associated // with breakpoints (e.g. printing messages for tracepoints) have already been completed. if (lastFrame.FileName != null && lastFrame.LineNumber != null) { var location = new RSourceLocation(lastFrame.FileName, lastFrame.LineNumber.Value); RBreakpoint bp; if (_breakpoints.TryGetValue(location, out bp)) { bp.RaiseBreakpointHit(); breakpointsHit = Enumerable.Repeat(bp, bp.UseCount).ToArray(); } } } bool isStepCompleted = false; if (_stepTcs != null) { var stepTcs = _stepTcs; _stepTcs = null; stepTcs.TrySetResult(breakpointsHit == null || breakpointsHit.Count == 0); isStepCompleted = true; } EventHandler<RBrowseEventArgs> browse; lock (_browseLock) { browse = _browse; } var eventArgs = new RBrowseEventArgs(inter, isStepCompleted, breakpointsHit); _currentBrowseEventArgs = eventArgs; browse?.Invoke(this, eventArgs); }
public async Task<IRBreakpoint> CreateBreakpointAsync(RSourceLocation location, CancellationToken cancellationToken = default(CancellationToken)) { ThrowIfDisposed(); await TaskUtilities.SwitchToBackgroundThread(); await InitializeAsync(cancellationToken); RBreakpoint bp; if (!_breakpoints.TryGetValue(location, out bp)) { bp = new RBreakpoint(this, location); _breakpoints.Add(location, bp); } await bp.SetBreakpointAsync(cancellationToken); return bp; }
public static Task ShouldBeAtAsync(this IRSession session, RSourceLocation location, int offset = 0) { return(session.ShouldBeAtAsync(location.FileName, location.LineNumber + offset)); }
internal RBreakpoint(RExecutionTracer tracer, RSourceLocation location) { _tracer = tracer; Location = location; }