use of com.oracle.truffle.api.debug.DebuggerSession in project graal by oracle.
the class StepTest method testStepBadArgStepOver.
@Test
public void testStepBadArgStepOver() throws Throwable {
final Source source = testSource("ROOT(\n" + " STATEMENT\n" + ")\n");
try (DebuggerSession session = startSession()) {
startEval(source);
session.suspendNextExecution();
expectSuspended((SuspendedEvent event) -> {
try {
checkState(event, 2, true, "STATEMENT").prepareStepOver(0);
fail("Exception expected");
} catch (IllegalArgumentException e) {
Assert.assertEquals("Step count must be > 0", e.getMessage());
}
});
expectDone();
}
}
use of com.oracle.truffle.api.debug.DebuggerSession in project graal by oracle.
the class StepTest method testStepBadArgStepInto.
@Test
public void testStepBadArgStepInto() throws Throwable {
final Source source = testSource("ROOT(\n" + " STATEMENT\n" + ")\n");
try (DebuggerSession session = startSession()) {
startEval(source);
session.suspendNextExecution();
expectSuspended((SuspendedEvent event) -> {
try {
checkState(event, 2, true, "STATEMENT").prepareStepInto(0);
fail("Exception expected");
} catch (IllegalArgumentException e) {
Assert.assertEquals("Step count must be > 0", e.getMessage());
}
});
expectDone();
}
}
use of com.oracle.truffle.api.debug.DebuggerSession in project graal by oracle.
the class StepTest method testCallLoopStepOut.
@Test
public void testCallLoopStepOut() throws Throwable {
final Source source = testSource("ROOT(\n" + " DEFINE(foo,\n" + " LOOP(3,\n" + " STATEMENT)\n" + " ),\n" + " CALL(foo)\n" + ")\n");
try (DebuggerSession session = startSession()) {
startEval(source);
session.suspendNextExecution();
expectSuspended((SuspendedEvent event) -> {
checkState(event, 4, true, "STATEMENT").prepareStepOut(1);
});
expectSuspended((SuspendedEvent event) -> {
checkState(event, 6, false, "CALL(foo)").prepareContinue();
});
expectDone();
}
}
use of com.oracle.truffle.api.debug.DebuggerSession in project graal by oracle.
the class StepTest method testExpressionStep.
@Test
public void testExpressionStep() {
final Source source = testSource("ROOT(\n" + " DEFINE(inner1, ROOT(\n" + " STATEMENT,\n" + " EXPRESSION,\n" + " EXPRESSION(EXPRESSION(CONSTANT(1)), EXPRESSION(CONSTANT(2)))\n" + " )),\n" + " DEFINE(inner2, ROOT(\n" + " EXPRESSION,\n" + " CALL(inner2_1),\n" + " EXPRESSION(CALL(inner2_1))\n" + " )),\n" + " DEFINE(inner2_1, ROOT(\n" + " STATEMENT(EXPRESSION(EXPRESSION))\n" + " )),\n" + " EXPRESSION,\n" + " STATEMENT(EXPRESSION(CALL(inner1)), EXPRESSION(CALL(inner2))),\n" + " EXPRESSION,\n" + " STATEMENT\n" + ")\n");
try (DebuggerSession session = startSession(SourceElement.EXPRESSION)) {
startEval(source);
session.suspendNextExecution();
expectSuspended((SuspendedEvent event) -> {
checkState(event, 15, true, "EXPRESSION").prepareStepInto(1);
});
expectSuspended((SuspendedEvent event) -> {
checkState(event, 15, false, "EXPRESSION").prepareStepInto(1);
});
expectSuspended((SuspendedEvent event) -> {
checkState(event, 16, true, "EXPRESSION(CALL(inner1))").prepareStepInto(1);
});
expectSuspended((SuspendedEvent event) -> {
checkState(event, 4, true, "EXPRESSION").prepareStepOver(1);
});
expectSuspended((SuspendedEvent event) -> {
checkState(event, 4, false, "EXPRESSION").prepareStepOver(1);
});
expectSuspended((SuspendedEvent event) -> {
checkState(event, 5, true, "EXPRESSION(EXPRESSION(CONSTANT(1)), EXPRESSION(CONSTANT(2)))").prepareStepInto(1);
});
expectSuspended((SuspendedEvent event) -> {
checkState(event, 5, true, "EXPRESSION(CONSTANT(1))").prepareStepOver(1);
});
expectSuspended((SuspendedEvent event) -> {
checkState(event, 5, false, "EXPRESSION(CONSTANT(1))").prepareStepOut(1);
Assert.assertEquals("(1)", event.getReturnValue().as(String.class));
Assert.assertEquals(Arrays.asList(event.getInputValues()).toString(), 0, event.getInputValues().length);
});
expectSuspended((SuspendedEvent event) -> {
checkState(event, 5, false, "EXPRESSION(EXPRESSION(CONSTANT(1)), EXPRESSION(CONSTANT(2)))").prepareStepInto(1);
Assert.assertEquals("((1)+(2))", event.getReturnValue().as(String.class));
DebugValue[] inputValues = event.getInputValues();
Assert.assertEquals(Arrays.asList(inputValues).toString(), 2, event.getInputValues().length);
Assert.assertEquals("(1)", inputValues[0].as(String.class));
Assert.assertEquals("(2)", inputValues[1].as(String.class));
});
expectSuspended((SuspendedEvent event) -> {
checkState(event, 16, false, "CALL(inner1)").prepareStepInto(1);
});
expectSuspended((SuspendedEvent event) -> {
checkState(event, 16, false, "EXPRESSION(CALL(inner1))").prepareStepInto(2);
});
expectSuspended((SuspendedEvent event) -> {
checkState(event, 8, true, "EXPRESSION").prepareStepOver(2);
});
expectSuspended((SuspendedEvent event) -> {
checkState(event, 10, true, "EXPRESSION(CALL(inner2_1))").prepareStepInto(1);
});
expectSuspended((SuspendedEvent event) -> {
checkState(event, 13, true, "EXPRESSION(EXPRESSION)").prepareStepOut(1);
});
expectSuspended((SuspendedEvent event) -> {
checkState(event, 13, false, "EXPRESSION(EXPRESSION)").prepareStepOut(1);
});
expectSuspended((SuspendedEvent event) -> {
checkState(event, 10, false, "CALL(inner2_1)").prepareStepOut(1);
});
expectSuspended((SuspendedEvent event) -> {
checkState(event, 10, false, "EXPRESSION(CALL(inner2_1))").prepareStepOut(1);
});
expectSuspended((SuspendedEvent event) -> {
checkState(event, 16, false, "CALL(inner2)").prepareStepOut(1);
});
expectSuspended((SuspendedEvent event) -> {
checkState(event, 16, false, "EXPRESSION(CALL(inner2))").prepareStepOut(1);
});
expectDone();
}
}
use of com.oracle.truffle.api.debug.DebuggerSession in project graal by oracle.
the class StepTest method testCallLoopStepInto.
@Test
public void testCallLoopStepInto() throws Throwable {
final Source source = testSource("ROOT(\n" + " DEFINE(foo,\n" + " LOOP(3,\n" + " STATEMENT)\n" + " ),\n" + " CALL(foo)\n" + ")\n");
try (DebuggerSession session = startSession()) {
startEval(source);
session.suspendNextExecution();
expectSuspended((SuspendedEvent event) -> {
checkState(event, 4, true, "STATEMENT").prepareStepInto(1);
});
expectSuspended((SuspendedEvent event) -> {
checkState(event, 4, true, "STATEMENT").prepareStepInto(1);
});
expectSuspended((SuspendedEvent event) -> {
checkState(event, 4, true, "STATEMENT").prepareStepInto(1);
});
expectSuspended((SuspendedEvent event) -> {
checkState(event, 6, false, "CALL(foo)").prepareContinue();
});
expectDone();
}
}
Aggregations