private DebugStackFrame getTopStackFrame() { if (topStackFrame == null) { topStackFrame = new DebugStackFrame(SuspendedEvent.this, null, 0); } return topStackFrame; }
/** * Returns public information about the language of this frame. * * @return the language info, or <code>null</code> when no language is associated with this * frame. * @since 1.0 */ public LanguageInfo getLanguage() { verifyValidState(true); RootNode root = findCurrentRoot(); if (root == null) { return null; } return root.getLanguageInfo(); }
/** * Evaluates the given code in the state of the current execution and in the same guest language * as the current language is defined in. Returns a heap value that remains valid even if this * stack frame becomes invalid. * * <p> * This method is not thread-safe and will throw an {@link IllegalStateException} if called on * another thread than it was created with. * * @param code the code to evaluate * @return the return value of the expression * @throws DebugException when guest language code throws an exception * @throws IllegalStateException if called on another thread than this frame was created with, * or if {@link #getLanguage() language} of this frame is not * {@link LanguageInfo#isInteractive() interactive}. * @since 0.17 */ public DebugValue eval(String code) throws DebugException { verifyValidState(false); Object result = DebuggerSession.evalInContext(event, code, currentFrame); return wrapHeapValue(result); }
verifyValidState(false); SuspendedContext context = getContext(); RootNode root = findCurrentRoot(); if (root == null) { return null; MaterializedFrame frame = findTruffleFrame(); Iterable<Scope> scopes = debugger.getEnv().findLocalScopes(node, frame); Iterator<Scope> it = scopes.iterator();
/** * 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; } }
/** * Returns the return value of the currently executed source location. Returns <code>null</code> * if the execution is suspended {@link SuspendAnchor#BEFORE before} a guest language location. * The returned value is <code>null</code> if an exception occurred during execution of the * instrumented source element, the exception is provided by {@link #getException()}. * <p> * This method is not thread-safe and will throw an {@link IllegalStateException} if called on * another thread than it was created with. * * @since 0.17 */ public DebugValue getReturnValue() { verifyValidState(false); Object ret = returnValue; if (ret == null) { return null; } return getTopStackFrame().wrapHeapValue(ret); }
DebugScope cscope = getScope();
private SuspendedContext getContext() { SuspendedContext context = event.getContext(); if (context == null) { // there is a race condition here if the event // got disposed between the parent verifyValidState and getContext. // if the context is null we assume the event got disposed so we re-check // the disposed flag. return null should therefore not be reachable. verifyValidState(true); assert false : "should not be reachable"; } return context; }
DebugValue wrapHeapValue(Object result) { LanguageInfo language; RootNode root = findCurrentRoot(); if (root != null) { language = root.getLanguageInfo(); } else { language = null; } return new HeapValue(event.getSession(), language, null, result); }
/** * Prepare to unwind a frame. This frame and all frames above it are unwound off the execution * stack. The frame needs to be on the {@link #getStackFrames() execution stack of this event}. * * @param frame the frame to unwind * @throws IllegalArgumentException when the frame is not on the execution stack of this event * @since 0.31 */ public void prepareUnwindFrame(DebugStackFrame frame) throws IllegalArgumentException { if (frame.event != this) { throw new IllegalArgumentException("The stack frame is not in the scope of this event."); } setNextStrategy(SteppingStrategy.createUnwind(frame.getDepth())); }
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; } }
public void onSuspend(SuspendedEvent ev) { actualName[0] = ev.getTopStackFrame().getName(); haltCount[0] = haltCount[0] + 1; } })) {
verifyValidState(false); SuspendedContext context = getContext(); RootNode root = findCurrentRoot(); if (root == null) { return null; MaterializedFrame frame = findTruffleFrame(); try { Iterable<Scope> scopes = session.getDebugger().getEnv().findLocalScopes(node, frame);
/** * 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 event.getSession().resolveSection(context.getInstrumentedSourceSection()); } else { Node callNode = currentFrame.getCallNode(); if (callNode != null) { return event.getSession().resolveSection(callNode.getEncapsulatingSourceSection()); } return null; } }
/** * Returns the return value of the currently executed source location. Returns <code>null</code> * if the execution is suspended {@link SuspendAnchor#BEFORE before} a guest language location. * The returned value is <code>null</code> if an exception occurred during execution of the * instrumented source element. The debug value remains valid event if the current execution was * suspend. * <p> * This method is not thread-safe and will throw an {@link IllegalStateException} if called on * another thread than it was created with. * * @since 0.17 */ public DebugValue getReturnValue() { verifyValidState(false); Object ret = returnValue; if (ret == null) { return null; } return getTopStackFrame().wrapHeapValue(ret); }
DebugScope cscope = getScope();
private SuspendedContext getContext() { SuspendedContext context = event.getContext(); if (context == null) { // there is a race condition here if the event // got disposed between the parent verifyValidState and getContext. // if the context is null we assume the event got disposed so we re-check // the disposed flag. return null should therefore not be reachable. verifyValidState(true); assert false : "should not be reachable"; } return context; }
DebugValue wrapHeapValue(Object result) { LanguageInfo language; RootNode root = findCurrentRoot(); if (root != null) { language = root.getLanguageInfo(); } else { language = null; } return new HeapValue(event.getSession().getDebugger(), language, null, result); }
/** * Prepare to unwind a frame. This frame and all frames above it are unwound off the execution * stack. The frame needs to be on the {@link #getStackFrames() execution stack of this event}. * * @param frame the frame to unwind * @throws IllegalArgumentException when the frame is not on the execution stack of this event * @since 0.31 */ public void prepareUnwindFrame(DebugStackFrame frame) throws IllegalArgumentException { if (frame.event != this) { throw new IllegalArgumentException("The stack frame is not in the scope of this event."); } setNextStrategy(SteppingStrategy.createUnwind(frame.getDepth())); }
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; } }