@Override public Object visitFrame(FrameInstance frameInstance) { CallTarget target = frameInstance.getCallTarget(); StringBuilder line = new StringBuilder(" "); if (frameIndex > 0) { line.append(" "); } line.append(formatStackFrame(frameInstance, target)); frameIndex++; runtime.log(line.toString()); if (frameIndex < limit) { return null; } else { runtime.log(" ..."); return frameInstance; } }
/** * Accesses the underlying frame using a specified {@link FrameAccess access mode}. * * @see FrameAccess * @since 0.23 */ default Frame getFrame(FrameAccess access) { return getFrame(access, true); }
@Override public Caller visitFrame(FrameInstance frameInstance) { // we stop at eval root stack frames if (!SuspendedEvent.isEvalRootStackFrame(DebuggerSession.this, frameInstance) && (depth++ == 0)) { return null; } Node callNode = frameInstance.getCallNode(); // Prefer call node with a source section if (callNode != null && callNode.getEncapsulatingSourceSection() != null) { return new Caller(frameInstance); } else { if (nearestCaller[0] == null) { nearestCaller[0] = new Caller(frameInstance); } return null; } } });
@Override public FrameInstance visitFrame(FrameInstance frameInstance) { if (stackFrameLimit >= 0 && stackFrameIndex >= stackFrameLimit) { // no more frames to create return frameInstance; } Node location = frameInstance.getCallNode(); RootCallTarget target = (RootCallTarget) frameInstance.getCallTarget(); if (first) { location = topCallSite; first = false; } boolean captureFrames = target != null && target.getRootNode().isCaptureFramesForTrace(); Frame frame = captureFrames ? frameInstance.getFrame(FrameAccess.READ_ONLY) : null; frames.add(new TruffleStackTraceElement(location, target, frame)); first = false; if (target != null && !target.getRootNode().isInternal()) { stackFrameIndex++; } return null; } });
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; } }
/** * 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); } }
ArrayList<StackTraceEntry> getInitialStack(Node instrumentedNode) { ArrayList<StackTraceEntry> sourceLocations = new ArrayList<>(); reconstructStack(sourceLocations, instrumentedNode, sourceSectionFilter, initInstrumenter); Truffle.getRuntime().iterateFrames(frame -> { Node node = frame.getCallNode(); if (node != null) { reconstructStack(sourceLocations, node, sourceSectionFilter, initInstrumenter); } return null; }); Collections.reverse(sourceLocations); return sourceLocations; }
@Override public FrameInstance visitFrame(FrameInstance frameInstance) { if (stackFrameLimit >= 0 && stackFrameIndex >= stackFrameLimit) { // no more frames to create return frameInstance; } Node location = frameInstance.getCallNode(); RootCallTarget target = (RootCallTarget) frameInstance.getCallTarget(); if (first) { location = topCallSite; first = false; } boolean captureFrames = target != null && target.getRootNode().isCaptureFramesForTrace(); Frame frame = captureFrames ? frameInstance.getFrame(FrameAccess.READ_ONLY) : null; frames.add(new TruffleStackTraceElement(location, target, frame)); first = false; if (target != null && !target.getRootNode().isInternal()) { stackFrameIndex++; } return null; } });
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; } }
frame = ev.getMaterializedFrame(); } else { node = frameInstance.getCallNode(); frame = frameInstance.getFrame(FrameAccess.MATERIALIZE).materialize();
builder.append(name); Node callNode = frameInstance.getCallNode(); SourceSection sourceSection = null; if (callNode != null) {
static boolean isEvalRootStackFrame(DebuggerSession session, FrameInstance instance) { CallTarget target = instance.getCallTarget(); RootNode root = null; if (target instanceof RootCallTarget) { root = ((RootCallTarget) target).getRootNode(); } if (root != null && session.getDebugger().getEnv().isEngineRoot(root)) { return true; } return false; }
/** * Accesses the underlying frame using a specified {@link FrameAccess access mode}. * * @see FrameAccess * @since 0.23 */ default Frame getFrame(FrameAccess access) { return getFrame(access, true); }
@Override public FrameInstance visitFrame(FrameInstance frameInstance) { Node node; if (depth == 0) { node = throwNode; } else { node = frameInstance.getCallNode(); } if (node != null) { Node catchNode = getCatchNode(debugger.getMessageNodes(), node, exception); if (catchNode != null) { catchLocationPtr[0] = new CatchLocation(catchNode.getSourceSection(), frameInstance, depth); return frameInstance; } } depth++; return null; } });
static boolean isEvalRootStackFrame(DebuggerSession session, FrameInstance instance) { CallTarget target = instance.getCallTarget(); RootNode root = null; if (target instanceof RootCallTarget) { root = ((RootCallTarget) target).getRootNode(); } if (root != null && session.getDebugger().getEnv().isEngineRoot(root)) { return true; } return false; }
/** * @since 1.0 */ @Override public boolean equals(Object obj) { if (obj instanceof DebugStackFrame) { DebugStackFrame other = (DebugStackFrame) obj; return event == other.event && (currentFrame == other.currentFrame || currentFrame != null && other.currentFrame != null && currentFrame.getFrame(FrameAccess.READ_ONLY) == other.currentFrame.getFrame(FrameAccess.READ_ONLY)); } return false; }
/** * 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 public Object call(final VirtualFrame frame, final CallTarget target, Object[] arguments) { DefaultTruffleRuntime truffleRuntime = (DefaultTruffleRuntime) Truffle.getRuntime(); final CallTarget currentCallTarget = truffleRuntime.getCurrentFrame().getCallTarget(); FrameInstance frameInstance = new FrameInstance() { public Frame getFrame(FrameAccess access, boolean slowPath) { return frame; } public boolean isVirtualFrame() { return false; } public Node getCallNode() { return DefaultIndirectCallNode.this; } public CallTarget getCallTarget() { return currentCallTarget; } }; truffleRuntime.pushFrame(frameInstance); try { return target.call(arguments); } finally { truffleRuntime.popFrame(); } } }
/** * * @since 0.8 or earlier * @deprecated use {@link #getFrame(FrameAccess)} instead. It is equivalent to * <code>FrameInstance.getFrame(access, true)</code>. */ @Deprecated default Frame getFrame(FrameAccess access, @SuppressWarnings("unused") boolean slowPath) { return getFrame(access); }
@Override public Void visitFrame(FrameInstance frame) { Node callNode = frame.getCallNode(); if (callNode == null) { return null;