Skip to content

Commit

Permalink
Showing 2 changed files with 26 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -11,6 +11,8 @@

import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.nodes.RootNode;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
import org.jcodings.specific.UTF8Encoding;
@@ -19,6 +21,7 @@
import org.jruby.truffle.builtins.UnaryCoreMethodNode;
import org.jruby.truffle.core.rope.RopeOperations;
import org.jruby.truffle.core.string.StringOperations;
import org.jruby.truffle.language.RubyRootNode;
import org.jruby.truffle.language.backtrace.Activation;

@CoreClass("Thread::Backtrace::Location")
@@ -84,7 +87,11 @@ public DynamicObject toS(DynamicObject threadBacktraceLocation) {
return coreStrings().BACKTRACE_OMITTED_LIMIT.createInstance();
}

final SourceSection sourceSection = activation.getCallNode().getEncapsulatingSourceSection();
final Node callNode = activation.getCallNode();

final RootNode rootNode = callNode.getRootNode();

final SourceSection sourceSection = callNode.getEncapsulatingSourceSection();

if (sourceSection.getSource() == null) {
return createString(StringOperations.encodeRope(sourceSection.getShortDescription(), UTF8Encoding.INSTANCE));
@@ -95,7 +102,7 @@ public DynamicObject toS(DynamicObject threadBacktraceLocation) {
":",
sourceSection.getStartLine(),
":in `",
sourceSection.getIdentifier(),
rootNode.getName(),
"'"));
}

Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@

import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.nodes.RootNode;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.Source;
import com.oracle.truffle.api.source.SourceSection;
@@ -129,7 +130,9 @@ public String formatLine(List<Activation> activations, int n, DynamicObject exce
builder.append("\tfrom ");
}

if (activation.getCallNode().getRootNode() instanceof RubyRootNode) {
final RootNode rootNode = activation.getCallNode().getRootNode().getRootNode();

if (rootNode instanceof RubyRootNode) {
final SourceSection sourceSection = activation.getCallNode().getEncapsulatingSourceSection();
final SourceSection reportedSourceSection;
String reportedName;
@@ -142,7 +145,7 @@ public String formatLine(List<Activation> activations, int n, DynamicObject exce
reportedName = getMethodNameFromActivation(activation);
} else {
reportedSourceSection = sourceSection;
reportedName = sourceSection.getIdentifier();
reportedName = rootNode.getName();
}

if (reportedSourceSection == null) {
@@ -264,9 +267,19 @@ private String formatForeign(Node callNode) {
} else {
builder.append(sourceSection.getShortDescription());

if (sourceSection.getIdentifier() != null && !sourceSection.getIdentifier().isEmpty()) {
final RootNode rootNode = callNode.getRootNode();

final String identifier;

if (rootNode instanceof RubyRootNode) {
identifier = rootNode.getName();
} else {
identifier = sourceSection.getIdentifier();
}

if (identifier != null && !identifier.isEmpty()) {
builder.append(":in `");
builder.append(sourceSection.getIdentifier());
builder.append(identifier);
builder.append("'");
}
}

0 comments on commit 3da798b

Please sign in to comment.