Skip to content

Commit

Permalink
[Truffle] Simple shell backtrace command.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisseaton committed Feb 27, 2015
1 parent 75239af commit 0afb77c
Showing 1 changed file with 14 additions and 1 deletion.
Expand Up @@ -9,11 +9,14 @@
*/
package org.jruby.truffle.runtime.subsystems;

import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.frame.FrameInstance;
import com.oracle.truffle.api.frame.MaterializedFrame;
import com.oracle.truffle.api.source.Source;
import org.jcodings.specific.UTF8Encoding;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.runtime.RubyArguments;
import org.jruby.truffle.runtime.RubyCallStack;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.backtrace.Backtrace;
import org.jruby.truffle.runtime.control.RaiseException;
Expand Down Expand Up @@ -42,6 +45,10 @@ public void run(MaterializedFrame frame, RubyNode currentNode) {
}

switch (tokenizer.nextToken()) {
case "backtrace":
backtrace(currentNode);
break;

case "continue":
return;

Expand All @@ -62,11 +69,17 @@ public void run(MaterializedFrame frame, RubyNode currentNode) {
final RubyException rubyException = e.getRubyException();

for (String line : Backtrace.DISPLAY_FORMATTER.format(e.getRubyException().getContext(), rubyException, rubyException.getBacktrace())) {
System.err.println(line);
System.console().writer().println(line);
}
}
}
}
}

private void backtrace(RubyNode currentNode) {
for (String line : Backtrace.DEBUG_FORMATTER.format(context, null, RubyCallStack.getBacktrace(currentNode))) {
System.err.println(line);
}
}

}

0 comments on commit 0afb77c

Please sign in to comment.