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 c8ed4121ea65cdd1c629b832d19a846fb5034aac..472c2d72c8d3016f40c22e14e8ed5cfce34db766 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 b14bd57480f5dd74da6ca45621a32d1fee0c14d3..092e0341e9e4478872a1bf7b24e200d501662bc5 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 6fdc4d3262f38de8dec99b05a45da3afb53add1f..e61e4c03925398eed7469b93306ff8a395278333 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"); + } }