From 81ad4fe35a27d62599129d21ae5871fcd5728cb0 Mon Sep 17 00:00:00 2001 From: Florian Angerer <florian.angerer@oracle.com> Date: Thu, 11 May 2017 17:23:56 +0200 Subject: [PATCH] Fix: Debug continue did not work properly. --- .../nodes/builtin/helpers/DebugHandling.java | 8 +++-- .../truffle/r/test/ExpectedTestOutput.test | 34 +++++++++++++++++-- .../library/utils/TestInteractiveDebug.java | 6 ++++ 3 files changed, 42 insertions(+), 6 deletions(-) diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/helpers/DebugHandling.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/helpers/DebugHandling.java index c8ed4121ea..472c2d72c8 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/helpers/DebugHandling.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/helpers/DebugHandling.java @@ -194,7 +194,7 @@ public class DebugHandling { return fser; } - private static void ensureSingleStep(FunctionDefinitionNode fdn) { + private static FunctionStatementsEventListener ensureSingleStep(FunctionDefinitionNode fdn) { FunctionStatementsEventListener fser = getFunctionStatementsEventListener(fdn); if (fser == null) { // attach a "once" listener @@ -206,6 +206,7 @@ public class DebugHandling { fser.enabledForStepInto = true; } } + return fser; } private abstract static class DebugEventListener implements ExecutionEventListener { @@ -598,9 +599,10 @@ public class DebugHandling { if (!RContext.getInstance().stateInstrumentation.debugGloballyDisabled()) { CompilerDirectives.transferToInterpreter(); FunctionDefinitionNode fdn = (FunctionDefinitionNode) context.getInstrumentedNode().getRootNode(); - ensureSingleStep(fdn); + FunctionStatementsEventListener ensureSingleStep = ensureSingleStep(fdn); + functionStatementsEventListener.clearStepInstrument(); - functionStatementsEventListener.onEnter(context, frame); + ensureSingleStep.onEnter(context, frame); } } diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test index b14bd57480..092e0341e9 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test @@ -75880,9 +75880,6 @@ IgnoreWarningContext extra newline ##com.oracle.truffle.r.test.builtins.TestTestBase.testTraits#Output.IgnoreWarningContext# #if (exists('.fastr.identity')) { cat('Warning message: In .Internal(foo(42)) : IgnoreWarningContext') } else { cat('Warning message: In foo(42) : IgnoreWarningContext') } Warning message: In foo(42) : IgnoreWarningContext -##com.oracle.truffle.r.test.builtins.TestTestBase.testTraits#Output.IgnoreDebugPath# -#if (exists('.fastr.identity')) { cat('debug at <parse>#10') } else { cat('debug at <text>#10') } -debug at <text>#10 ##com.oracle.truffle.r.test.functions.TestFunctions.testArgEvaluationOrder# #v <- 1; class(v) <- 'foo'; `-.foo` <- function(x,y,...) { cat('[-.foo]'); 1234 }; g <- function(...) { cat('[ing]'); ({cat('[-]'); `-`})(...) }; ({cat('[g]'); g})({cat('[x]'); v},{cat('[y]'); 3},{cat('[z]'); 5}) [g][ing][-][x][y][z][-.foo][1] 1234 @@ -143313,6 +143310,37 @@ Tracing fun(10) on entry x=10 Error: unexpected ';' in ";" +##com.oracle.truffle.r.test.library.utils.TestInteractiveDebug.testContinue#Output.IgnoreDebugExitFrom# +#fun0 <- function() { print('fun0') }; fun1 <- function() { print('enter fun1'); fun0(); print('exit fun1') }; fun2 <- function() { print('enter fun2'); fun1(); print('exit fun2') }; debug(fun2); fun2()<<<NEWLINE>>><<<NEWLINE>>><<<NEWLINE>>>s<<<NEWLINE>>>n<<<NEWLINE>>><<<NEWLINE>>>s<<<NEWLINE>>>c<<<NEWLINE>>>c<<<NEWLINE>>>c<<<NEWLINE>>> +debugging in: fun2() +debug at #1: { + print("enter fun2") + fun1() + print("exit fun2") +} +debug at #1: print("enter fun2") +[1] "enter fun2" +debug at #1: fun1() +debugging in: fun1() +debug at #1: { + print("enter fun1") + fun0() + print("exit fun1") +} +debug at #1: print("enter fun1") +[1] "enter fun1" +debug at #1: fun0() +debugging in: fun0() +debug at #1: { + print("fun0") +} +[1] "fun0" +debug at #1: print("exit fun1") +[1] "exit fun1" +debug at #1: print("exit fun2") +[1] "exit fun2" +exiting from: fun2() + ##com.oracle.truffle.r.test.library.utils.TestInteractiveDebug.testInvalidName# #f <- function(x) {<<<NEWLINE>>> `123t` <- x + 1<<<NEWLINE>>> print(`123t`)<<<NEWLINE>>> `123t`}<<<NEWLINE>>>debug(f)<<<NEWLINE>>>f(5)<<<NEWLINE>>>x<<<NEWLINE>>>n<<<NEWLINE>>>n<<<NEWLINE>>>`123t`<<<NEWLINE>>>n<<<NEWLINE>>>n debugging in: f(5) diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/utils/TestInteractiveDebug.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/utils/TestInteractiveDebug.java index 6fdc4d3262..e61e4c0392 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/utils/TestInteractiveDebug.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/utils/TestInteractiveDebug.java @@ -73,4 +73,10 @@ public class TestInteractiveDebug extends TestBase { public void testConditionalBreakpoint() { assertEval("fun <- function(x) { cat('x='); cat(x); cat('\\n') }; trace(fun, quote(if (x > 10) browser())); fun(10)\n; fun(11)\n\n\n\n\n\n"); } + + @Test + public void testContinue() { + assertEval(Output.IgnoreDebugExitFrom, + "fun0 <- function() { print('fun0') }; fun1 <- function() { print('enter fun1'); fun0(); print('exit fun1') }; fun2 <- function() { print('enter fun2'); fun1(); print('exit fun2') }; debug(fun2); fun2()\n\n\ns\nn\n\ns\nc\nc\nc\n"); + } } -- GitLab