@Override public SuspendedContext get() { return SuspendedContext.create(caller.node, null); } });
SuspendedEvent(DebuggerSession session, Thread thread, SuspendedContext context, MaterializedFrame frame, SuspendAnchor suspendAnchor, InputValuesProvider inputValuesProvider, Object returnValue, List<Breakpoint> breakpoints, Map<Breakpoint, Throwable> conditionFailures) { this.session = session; this.context = context; this.suspendAnchor = suspendAnchor; this.materializedFrame = frame; this.inputValuesProvider = inputValuesProvider; this.returnValue = returnValue; this.conditionFailures = conditionFailures; this.breakpoints = breakpoints == null ? Collections.<Breakpoint> emptyList() : Collections.<Breakpoint> unmodifiableList(breakpoints); this.thread = thread; this.sourceSection = context.getInstrumentedSourceSection(); }
@Override void initialize(SuspendedContext context, SuspendAnchor suspendAnchor) { this.stackCounter = 0; this.exprCounter = context.hasTag(SourceElement.EXPRESSION.getTag()) && SuspendAnchor.BEFORE == suspendAnchor ? 0 : -1; }
throw new KillException(context.getInstrumentedNode()); } else if (strategy.isUnwind()) { ThreadDeath unwind = context.createUnwind(null, syntaxElementsBinding); ((SteppingStrategy.Unwind) strategy).unwind = unwind; throw unwind;
/** * Evaluates a snippet of code in a halted execution context. Assumes frame is part of the * current execution stack, behavior is undefined if not. * * @param ev event notification where execution is halted * @param code text of the code to be executed * @param frameInstance frame where execution is halted * @return * @throws IOException */ static Object evalInContext(SuspendedEvent ev, String code, FrameInstance frameInstance) throws IOException { try { Node node; MaterializedFrame frame; if (frameInstance == null) { node = ev.getContext().getInstrumentedNode(); frame = ev.getMaterializedFrame(); } else { node = frameInstance.getCallNode(); frame = frameInstance.getFrame(FrameAccess.MATERIALIZE).materialize(); } return Debugger.ACCESSOR.evalInContext(node, frame, code); } catch (KillException kex) { throw new IOException("Evaluation was killed.", kex); } }
/** * Test if the language context of the source of the event is initialized. * * @since 0.26 */ public boolean isLanguageContextInitialized() { verifyValidState(true); return context.isLanguageContextInitialized(); }
private List<DebugStackFrame> getOtherFrames() { if (otherFrames == null) { final List<DebugStackFrame> frameInstances = new ArrayList<>(); Truffle.getRuntime().iterateFrames(new FrameInstanceVisitor<FrameInstance>() { private int depth = -context.getStackDepth() - 1; @Override public FrameInstance visitFrame(FrameInstance frameInstance) { if (isEvalRootStackFrame(session, frameInstance)) { // we stop at eval root stack frames return frameInstance; } if (++depth <= 0) { return null; } frameInstances.add(new DebugStackFrame(SuspendedEvent.this, frameInstance, depth)); return null; } }); otherFrames = frameInstances; } return otherFrames; }
throw new KillException(); } else if (strategy.isUnwind()) { ThreadDeath unwind = context.createUnwind(null, rootBinding); ((SteppingStrategy.Unwind) strategy).unwind = unwind; throw unwind;
RootNode findCurrentRoot() { SuspendedContext context = getContext(); if (currentFrame == null) { return context.getInstrumentedNode().getRootNode(); } else { Node callNode = currentFrame.getCallNode(); if (callNode != null) { return callNode.getRootNode(); } CallTarget target = currentFrame.getCallTarget(); if (target instanceof RootCallTarget) { return ((RootCallTarget) target).getRootNode(); } return null; } }
/** * Test if the language context of the source of the event is initialized. * * @since 0.26 */ public boolean isLanguageContextInitialized() { verifyValidState(true); return context.isLanguageContextInitialized(); }
private List<DebugStackFrame> getOtherFrames() { if (otherFrames == null) { final List<DebugStackFrame> frameInstances = new ArrayList<>(); Truffle.getRuntime().iterateFrames(new FrameInstanceVisitor<FrameInstance>() { private int depth = -context.getStackDepth() - 1; @Override public FrameInstance visitFrame(FrameInstance frameInstance) { if (isEvalRootStackFrame(session, frameInstance)) { // we stop at eval root stack frames return frameInstance; } if (++depth <= 0) { return null; } frameInstances.add(new DebugStackFrame(SuspendedEvent.this, frameInstance, depth)); return null; } }); otherFrames = frameInstances; } return otherFrames; }
@Override public SuspendedContext get() { return SuspendedContext.create(source.getContext(), debugger.getEnv()); } });
RootNode findCurrentRoot() { SuspendedContext context = getContext(); if (currentFrame == null) { return context.getInstrumentedNode().getRootNode(); } else { Node callNode = currentFrame.getCallNode(); if (callNode != null) { return callNode.getRootNode(); } CallTarget target = currentFrame.getCallTarget(); if (target instanceof RootCallTarget) { return ((RootCallTarget) target).getRootNode(); } return null; } }
@Override void initialize(SuspendedContext context, SuspendAnchor suspendAnchor) { this.stackCounter = 0; this.exprCounter = context.hasTag(SourceElement.EXPRESSION.getTag()) && SuspendAnchor.BEFORE == suspendAnchor ? 0 : -1; }
SuspendedEvent(DebuggerSession session, Thread thread, SuspendedContext context, MaterializedFrame frame, SuspendAnchor suspendAnchor, InsertableNode insertableNode, InputValuesProvider inputValuesProvider, Object returnValue, DebugException exception, List<Breakpoint> breakpoints, Map<Breakpoint, Throwable> conditionFailures) { this.session = session; this.context = context; this.suspendAnchor = suspendAnchor; this.materializedFrame = frame; this.insertableNode = insertableNode; this.inputValuesProvider = inputValuesProvider; this.returnValue = returnValue; this.exception = exception; this.conditionFailures = conditionFailures; this.breakpoints = breakpoints == null ? Collections.<Breakpoint> emptyList() : Collections.<Breakpoint> unmodifiableList(breakpoints); this.thread = thread; this.sourceSection = context.getInstrumentedSourceSection(); }
@Override boolean step(DebuggerSession steppingSession, EventContext context, SuspendAnchor suspendAnchor) { boolean hit = current.step(steppingSession, context, suspendAnchor); if (hit) { if (current == last) { return true; } else { current = current.next; current.initialize(SuspendedContext.create(context), suspendAnchor); } } return false; }
node = context.getInstrumentedNode(); } else { node = currentFrame.getCallNode();
/** * Returns <code>true</code> if the underlying guest language source location is denoted as the * source element. * * @param sourceElement the source element to check, must not be <code>null</code>. * @since 0.33 */ public boolean hasSourceElement(SourceElement sourceElement) { return context.hasTag(sourceElement.getTag()); }
/** * Returns the source section of the location where the debugging session was suspended. The * source section is <code>null</code> if the source location is not available. * * <p> * This method is thread-safe. * * @since 0.17 */ public SourceSection getSourceSection() { verifyValidState(true); if (currentFrame == null) { SuspendedContext context = getContext(); return context.getInstrumentedSourceSection(); } else { Node callNode = currentFrame.getCallNode(); if (callNode != null) { return callNode.getEncapsulatingSourceSection(); } return null; } }
@Override boolean step(DebuggerSession steppingSession, EventContext context, SuspendAnchor suspendAnchor) { boolean hit = current.step(steppingSession, context, suspendAnchor); if (hit) { if (current == last) { return true; } else { current = current.next; current.initialize(SuspendedContext.create(context, steppingSession.getDebugger().getEnv()), suspendAnchor); } } return false; }