@Override public SourceSection getInstrumentedSourceSection() { if (node == null) { return null; } else { return node.getEncapsulatingSourceSection(); } }
@Override public SourceSection getInstrumentedSourceSection() { if (node == null) { return null; } else { return node.getEncapsulatingSourceSection(); } }
/** * Returns a location where this exception occurred in the AST. This method may return * <code>null</code> to indicate that the location is not available. * * @return the {@link SourceSection} or null * @since 0.33 */ default SourceSection getSourceLocation() { final Node node = getLocation(); return node == null ? null : node.getEncapsulatingSourceSection(); } }
/** * Returns a location where this exception occurred in the AST. This method may return * <code>null</code> to indicate that the location is not available. * * @return the {@link SourceSection} or null * @since 0.33 */ default SourceSection getSourceLocation() { final Node node = getLocation(); return node == null ? null : node.getEncapsulatingSourceSection(); } }
/** * Get a source section representing this scope. Please note that while this scope does not * provide variables that are valid only after the suspension point, the source section can * actually span after the suspension point. * * @return the source section, or <code>null</code> when not available. * @since 0.29 */ public SourceSection getSourceSection() { Node node = scope.getNode(); if (node != null) { return node.getEncapsulatingSourceSection(); } else { return null; } }
public String displaySourceLocation(Node node) { if (node == null) { return "<unknown>"; } SourceSection section = node.getSourceSection(); boolean estimated = false; if (section == null) { section = node.getEncapsulatingSourceSection(); estimated = true; } return section.getShortDescription() + (estimated ? "~" : ""); }
public SourceSection getInstrumentedSourceSection() { SourceSection ss = eventContext.getInstrumentedSourceSection(); if (ss == null) { Node node = eventContext.getInstrumentedNode(); // Nodes tagged with standard tags should have a source section attached. PrintStream err = new PrintStream(env.err()); err.print("WARNING: Instrumented node " + node + " of class " + node.getClass() + " has null SourceSection."); ss = node.getEncapsulatingSourceSection(); if (ss == null) { RootNode root = node.getRootNode(); err.print("WARNING: and null encapsulating SourceSection under " + root + " of class = " + root.getClass()); } err.flush(); } return ss; }
/** * Returns the source section location of this trace element. The source section is * <code>null</code> if the source location is not available. * * @since 1.0 */ public SourceSection getSourceSection() { Node node = traceElement.getLocation(); if (node != null) { return session.resolveSection(node.getEncapsulatingSourceSection()); } return null; }
@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; } } });
SourceSection sourceSection = null; if (callNode != null) { sourceSection = callNode.getEncapsulatingSourceSection();
static void traceRewrite(Node oldNode, Node newNode, CharSequence reason) { if (TruffleOptions.TraceRewritesFilterFromCost != null) { if (filterByKind(oldNode, TruffleOptions.TraceRewritesFilterFromCost)) { return; } } if (TruffleOptions.TraceRewritesFilterToCost != null) { if (filterByKind(newNode, TruffleOptions.TraceRewritesFilterToCost)) { return; } } String filter = TruffleOptions.TraceRewritesFilterClass; Class<? extends Node> from = oldNode.getClass(); Class<? extends Node> to = newNode.getClass(); if (filter != null && (filterByContainsClassName(from, filter) || filterByContainsClassName(to, filter))) { return; } final SourceSection reportedSourceSection = oldNode.getEncapsulatingSourceSection(); PrintStream out = System.out; out.printf("[truffle] rewrite %-50s |From %-40s |To %-40s |Reason %s %s%n", oldNode.toString(), formatNodeInfo(oldNode), formatNodeInfo(newNode), reason != null && reason.length() > 0 ? reason : "unknown", formatLocation(reportedSourceSection)); }
/** * Get a source section representing this scope. Please note that while this scope does not * provide variables that are valid only after the suspension point, the source section can * actually span after the suspension point. * * @return the source section, or <code>null</code> when not available. * @throws DebugException when guest language code throws an exception * @since 0.29 */ public SourceSection getSourceSection() throws DebugException { try { Node node = scope.getNode(); if (node != null) { return session.resolveSection(node.getEncapsulatingSourceSection()); } else { return null; } } catch (ThreadDeath td) { throw td; } catch (Throwable ex) { throw new DebugException(session, ex, language, null, true, null); } }
static void traceRewrite(Node oldNode, Node newNode, CharSequence reason) { if (TruffleOptions.TraceRewritesFilterFromCost != null) { if (filterByKind(oldNode, TruffleOptions.TraceRewritesFilterFromCost)) { return; } } if (TruffleOptions.TraceRewritesFilterToCost != null) { if (filterByKind(newNode, TruffleOptions.TraceRewritesFilterToCost)) { return; } } String filter = TruffleOptions.TraceRewritesFilterClass; Class<? extends Node> from = oldNode.getClass(); Class<? extends Node> to = newNode.getClass(); if (filter != null && (filterByContainsClassName(from, filter) || filterByContainsClassName(to, filter))) { return; } final SourceSection reportedSourceSection = oldNode.getEncapsulatingSourceSection(); PrintStream out = System.out; out.printf("[truffle] rewrite %-50s |From %-40s |To %-40s |Reason %s %s%n", oldNode.toString(), formatNodeInfo(oldNode), formatNodeInfo(newNode), reason != null && reason.length() > 0 ? reason : "unknown", formatLocation(reportedSourceSection)); }
static void traceRewrite(Node oldNode, Node newNode, CharSequence reason) { if (TruffleOptions.TraceRewritesFilterFromCost != null) { if (filterByKind(oldNode, TruffleOptions.TraceRewritesFilterFromCost)) { return; } } if (TruffleOptions.TraceRewritesFilterToCost != null) { if (filterByKind(newNode, TruffleOptions.TraceRewritesFilterToCost)) { return; } } String filter = TruffleOptions.TraceRewritesFilterClass; Class<? extends Node> from = oldNode.getClass(); Class<? extends Node> to = newNode.getClass(); if (filter != null && (filterByContainsClassName(from, filter) || filterByContainsClassName(to, filter))) { return; } final SourceSection reportedSourceSection = oldNode.getEncapsulatingSourceSection(); PrintStream out = System.out; out.printf("[truffle] rewrite %-50s |From %-40s |To %-40s |Reason %s%s%n", oldNode.toString(), formatNodeInfo(oldNode), formatNodeInfo(newNode), reason != null && reason.length() > 0 ? reason : "unknown", reportedSourceSection != null ? " at " + reportedSourceSection.getShortDescription() : ""); }
/** * 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; } }
SourceSection sourceSection = callNode.getEncapsulatingSourceSection(); Source source = sourceSection != null ? sourceSection.getSource() : null; String sourceName = source != null ? source.getName() : null;
/** * 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; } }
static PolyglotExceptionFrame createGuest(PolyglotExceptionImpl exception, TruffleStackTraceElement frame, boolean first) { if (frame == null) { return null; } RootNode targetRoot = frame.getTarget().getRootNode(); if (targetRoot.isInternal()) { return null; } LanguageInfo info = targetRoot.getLanguageInfo(); if (info == null) { return null; } PolyglotEngineImpl engine = exception.getEngine(); PolyglotLanguage language = engine.idToLanguage.get(info.getId()); String rootName = targetRoot.getName(); SourceSection location; Node callNode = frame.getLocation(); if (callNode != null) { com.oracle.truffle.api.source.SourceSection section = callNode.getEncapsulatingSourceSection(); if (section != null) { Source source = engine.getAPIAccess().newSource(language.getId(), section.getSource()); location = engine.getAPIAccess().newSourceSection(source, section); } else { location = null; } } else { location = first ? exception.getSourceLocation() : null; } return new PolyglotExceptionFrame(exception, language, location, rootName, false, null); }
static PolyglotExceptionFrame createGuest(PolyglotExceptionImpl exception, TruffleStackTraceElement frame, boolean first) { if (frame == null) { return null; } RootNode targetRoot = frame.getTarget().getRootNode(); if (targetRoot.isInternal()) { return null; } LanguageInfo info = targetRoot.getLanguageInfo(); if (info == null) { return null; } PolyglotEngineImpl engine = exception.context.getEngine(); PolyglotLanguage language = engine.idToLanguage.get(info.getId()); String rootName = targetRoot.getName(); SourceSection location; Node callNode = frame.getLocation(); if (callNode != null) { com.oracle.truffle.api.source.SourceSection section = callNode.getEncapsulatingSourceSection(); if (section != null) { Source source = engine.getAPIAccess().newSource(language.getId(), section.getSource()); location = engine.getAPIAccess().newSourceSection(source, section); } else { location = null; } } else { location = first ? exception.getSourceLocation() : null; } return new PolyglotExceptionFrame(exception, language, location, rootName, false, null); }