@SuppressWarnings("deprecation") public final Frame getFrame(FrameAccess access) { if (access == FrameAccess.NONE) { return null; } Frame localFrame = this.frame; switch (access) { case READ_ONLY: /* Verify that it is really used read only. */ return new ReadOnlyFrame(localFrame); case READ_WRITE: return localFrame; case MATERIALIZE: return localFrame.materialize(); } throw new AssertionError(); }
@SuppressWarnings("deprecation") public final Frame getFrame(FrameAccess access) { if (access == FrameAccess.NONE) { return null; } Frame localFrame = this.frame; switch (access) { case READ_ONLY: /* Verify that it is really used read only. */ return new ReadOnlyFrame(localFrame); case READ_WRITE: return localFrame; case MATERIALIZE: return localFrame.materialize(); } throw new AssertionError(); }
MaterializedFrame findTruffleFrame() { if (currentFrame == null) { return event.getMaterializedFrame(); } else { return currentFrame.getFrame(FrameAccess.MATERIALIZE).materialize(); } }
MaterializedFrame findTruffleFrame() { if (currentFrame == null) { return event.getMaterializedFrame(); } else { return currentFrame.getFrame(FrameAccess.MATERIALIZE).materialize(); } }
private static void appendLazyStackTrace(Node callNode, RootCallTarget root, Frame currentFrame, LazyStackTrace lazy, int stackTraceElementLimit) { if (lazy.stackTrace == null) { if (stackTraceElementLimit >= 0 && lazy.frameCount >= stackTraceElementLimit) { return; } boolean captureFrames = root != null && root.getRootNode().isCaptureFramesForTrace(); lazy.current = new TracebackElement(lazy.current, callNode, root, captureFrames ? currentFrame.materialize() : null); if (root != null && !root.getRootNode().isInternal()) { lazy.frameCount++; } } }
@SuppressWarnings("deprecation") @Override @TruffleBoundary public Frame getFrame(FrameAccess access) { if (access == FrameAccess.NONE) { return null; } if (access == FrameAccess.READ_WRITE || access == FrameAccess.MATERIALIZE) { if (callTargetFrame.isVirtual(CALL_TARGET_FRAME_INDEX)) { callTargetFrame.materializeVirtualObjects(false); } } Frame frame = (Frame) callTargetFrame.getLocal(CALL_TARGET_FRAME_INDEX); if (access == FrameAccess.MATERIALIZE) { frame = frame.materialize(); } return frame; }
private static void appendLazyStackTrace(Node callNode, RootCallTarget root, Frame currentFrame, LazyStackTrace lazy, int stackTraceElementLimit) { if (lazy.stackTrace == null) { if (stackTraceElementLimit >= 0 && lazy.frameCount >= stackTraceElementLimit) { return; } boolean captureFrames = root != null && root.getRootNode().isCaptureFramesForTrace(); lazy.current = new TracebackElement(lazy.current, callNode, root, captureFrames ? currentFrame.materialize() : null); if (root != null && !root.getRootNode().isInternal()) { lazy.frameCount++; } } }
/** * Get the current inner-most scope. The scope might not provide valid information if the * execution path diverges from this trace element. * * @return the scope, or <code>null</code> when no language is associated with this frame * location, or when no local scope exists. * @since 1.0 */ public DebugScope getScope() { Node node = traceElement.getLocation(); if (node == null) { return null; } RootNode root = node.getRootNode(); if (root.getLanguageInfo() == null) { // no language, no scopes return null; } Frame elementFrame = traceElement.getFrame(); MaterializedFrame frame = (elementFrame != null) ? elementFrame.materialize() : null; Iterable<Scope> scopes = session.getDebugger().getEnv().findLocalScopes(node, frame); Iterator<Scope> it = scopes.iterator(); if (!it.hasNext()) { return null; } return new DebugScope(it.next(), it, session, null, frame, root); }
/** * 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); } }
static void addStackFrameInfo(Node callNode, Throwable t, RootCallTarget root, Frame currentFrame) { if (t instanceof ControlFlowException) { // control flow exceptions should never have to get a stack trace. return; } if (!(t instanceof TruffleException) || ((TruffleException) t).isInternalError()) { // capture as much information as possible for host and internal errors fillIn(t); return; } int stackTraceElementLimit = t instanceof TruffleException ? ((TruffleException) t).getStackTraceElementLimit() : -1; Throwable cause = t.getCause(); LazyStackTrace lazy; if (cause == null) { insert(t, lazy = new LazyStackTrace()); } else if (cause instanceof LazyStackTrace) { lazy = (LazyStackTrace) cause; } else { addStackFrameInfoSlowPath(callNode, cause, root, currentFrame == null ? null : currentFrame.materialize(), stackTraceElementLimit); return; } appendLazyStackTrace(callNode, root, currentFrame, lazy, stackTraceElementLimit); }
static void addStackFrameInfo(Node callNode, Throwable t, RootCallTarget root, Frame currentFrame) { if (t instanceof ControlFlowException) { // control flow exceptions should never have to get a stack trace. return; } if (t instanceof PolyglotException) { // Normally, polyglot exceptions should not even end up here, with the exception of // those thrown by Value call targets. In any case, we do not want to attach a cause. return; } if (!(t instanceof TruffleException) || ((TruffleException) t).isInternalError()) { // capture as much information as possible for host and internal errors fillIn(t); return; } int stackTraceElementLimit = t instanceof TruffleException ? ((TruffleException) t).getStackTraceElementLimit() : -1; Throwable cause = t.getCause(); LazyStackTrace lazy; if (cause == null) { insert(t, lazy = new LazyStackTrace()); } else if (cause instanceof LazyStackTrace) { lazy = (LazyStackTrace) cause; } else { addStackFrameInfoSlowPath(callNode, cause, root, currentFrame == null ? null : currentFrame.materialize(), stackTraceElementLimit); return; } appendLazyStackTrace(callNode, root, currentFrame, lazy, stackTraceElementLimit); }
} else { node = frameInstance.getCallNode(); frame = frameInstance.getFrame(FrameAccess.MATERIALIZE).materialize();