Skip to content
Snippets Groups Projects
Commit 81b1b02b authored by stepan's avatar stepan
Browse files

Fix loops debugging.

parent e85b8a64
No related branches found
No related tags found
No related merge requests found
......@@ -131,6 +131,9 @@ public abstract class BrowserInteractNode extends Node {
break LW;
case "Q":
throw new JumpToTopLevelException();
case "help":
printHelp(ch);
break;
case "where": {
if (currentCaller.getDepth() > 1) {
Object stack = Utils.createTraceback(0);
......@@ -205,4 +208,15 @@ public abstract class BrowserInteractNode extends Node {
private static String browserPrompt(int depth) {
return "Browse[" + depth + "]> ";
}
private static void printHelp(ConsoleIO out) {
out.println("n next");
out.println("s step into");
out.println("f finish");
out.println("c or cont continue");
out.println("Q quit");
out.println("where show stack");
out.println("help show help");
out.println("<expr> evaluate expression");
}
}
......@@ -46,6 +46,7 @@ import com.oracle.truffle.r.nodes.control.AbstractLoopNode;
import com.oracle.truffle.r.nodes.function.FunctionDefinitionNode;
import com.oracle.truffle.r.nodes.instrumentation.RInstrumentation;
import com.oracle.truffle.r.nodes.instrumentation.RSyntaxTags;
import com.oracle.truffle.r.nodes.instrumentation.RSyntaxTags.LoopTag;
import com.oracle.truffle.r.runtime.JumpToTopLevelException;
import com.oracle.truffle.r.runtime.RArguments;
import com.oracle.truffle.r.runtime.RDeparse;
......@@ -515,7 +516,7 @@ public class DebugHandling {
void setFinishing(AbstractLoopNode loopNode) {
// Disable every statement listener except that for loopNode
for (LoopStatementEventListener lser : loopStatementListeners) {
if (lser.getLoopNode() == loopNode) {
if (lser.handlesLoop(loopNode)) {
lser.setFinishing();
} else {
lser.disable();
......@@ -708,24 +709,24 @@ public class DebugHandling {
* The wrapper for the loop node is stable whereas the loop node itself will be replaced
* with a specialized node.
*/
private final RSyntaxNode loopNode;
private final SourceSection loopSourceSection;
private final FunctionStatementsEventListener fser;
LoopStatementEventListener(FunctionDefinitionNode functionDefinitionNode, Object text, Object condition, RSyntaxNode loopNode, FunctionStatementsEventListener fser) {
super(functionDefinitionNode, text, condition);
this.loopNode = loopNode;
this.loopSourceSection = loopNode.getSourceSection();
this.fser = fser;
}
@Override
public void onEnter(EventContext context, VirtualFrame frame) {
if (!disabled() && context.getInstrumentedNode() == loopNode) {
if (isEnabled(context)) {
super.onEnter(context, frame);
}
}
RSyntaxNode getLoopNode() {
return loopNode;
boolean handlesLoop(RSyntaxNode loop) {
return loopSourceSection != null && loopSourceSection.equals(loop.getSourceSection());
}
void setFinishing() {
......@@ -734,7 +735,7 @@ public class DebugHandling {
@Override
public void onReturnExceptional(EventContext context, VirtualFrame frame, Throwable exception) {
if (!disabled() && context.getInstrumentedNode() == loopNode) {
if (isEnabled(context)) {
CompilerDirectives.transferToInterpreter();
returnCleanup();
}
......@@ -742,12 +743,16 @@ public class DebugHandling {
@Override
public void onReturnValue(EventContext context, VirtualFrame frame, Object result) {
if (!disabled() && context.getInstrumentedNode() == loopNode) {
if (isEnabled(context)) {
CompilerDirectives.transferToInterpreter();
returnCleanup();
}
}
private boolean isEnabled(EventContext ctx) {
return !disabled() && loopSourceSection != null && loopSourceSection.equals(ctx.getInstrumentedNode().getSourceSection());
}
private void returnCleanup() {
if (finishing) {
finishing = false;
......
......@@ -7,7 +7,7 @@ suite = {
{
"name" : "truffle",
"subdir" : True,
"version" : "e140680ae7ebc4329e5cd96889258a75b6987dfe",
"version" : "b1c4af13e75d2dc839b5050ba020356ec1602788",
"urls" : [
{"url" : "https://github.com/graalvm/graal", "kind" : "git"},
{"url" : "https://curio.ssw.jku.at/nexus/content/repositories/snapshots", "kind" : "binary"},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment