use of com.oracle.truffle.api.debug.DebuggerSession in project graal by oracle.
the class StepTest method testNoPreparesAfterContinueOrKill.
@Test
public void testNoPreparesAfterContinueOrKill() throws Throwable {
final Source source = testSource("ROOT(\n" + " DEFINE(loop,\n" + " LOOP(3,\n" + " STATEMENT),\n" + " STATEMENT\n" + " ),\n" + " STATEMENT(CALL(loop))\n" + ")\n");
try (DebuggerSession session = startSession()) {
session.suspendNextExecution();
Breakpoint bp5 = Breakpoint.newBuilder(getSourceImpl(source)).lineIs(5).build();
session.install(bp5);
startEval(source);
expectSuspended((SuspendedEvent event) -> {
checkState(event, 7, true, "STATEMENT(CALL(loop))").prepareContinue();
try {
event.prepareStepInto(1);
Assert.fail("IllegalStateException should have been thrown.");
} catch (IllegalStateException ex) {
// expected
}
try {
event.prepareStepOver(1);
Assert.fail("IllegalStateException should have been thrown.");
} catch (IllegalStateException ex) {
// expected
}
try {
event.prepareStepOut(1);
Assert.fail("IllegalStateException should have been thrown.");
} catch (IllegalStateException ex) {
// expected
}
try {
event.prepareContinue();
Assert.fail("IllegalStateException should have been thrown.");
} catch (IllegalStateException ex) {
// expected
}
try {
event.prepareKill();
Assert.fail("IllegalStateException should have been thrown.");
} catch (IllegalStateException ex) {
// expected
}
});
expectSuspended((SuspendedEvent event) -> {
checkState(event, 5, true, "STATEMENT").prepareKill();
try {
event.prepareStepInto(1);
Assert.fail("IllegalStateException should have been thrown.");
} catch (IllegalStateException ex) {
// expected
}
try {
event.prepareStepOver(1);
Assert.fail("IllegalStateException should have been thrown.");
} catch (IllegalStateException ex) {
// expected
}
try {
event.prepareStepOut(1);
Assert.fail("IllegalStateException should have been thrown.");
} catch (IllegalStateException ex) {
// expected
}
try {
event.prepareContinue();
Assert.fail("IllegalStateException should have been thrown.");
} catch (IllegalStateException ex) {
// expected
}
try {
event.prepareKill();
Assert.fail("IllegalStateException should have been thrown.");
} catch (IllegalStateException ex) {
// expected
}
});
expectKilled();
}
}
use of com.oracle.truffle.api.debug.DebuggerSession in project graal by oracle.
the class StepTest method testIncompatibleSourceElements.
@Test
public void testIncompatibleSourceElements() {
final Source source = testSource("ROOT(\n" + " STATEMENT,\n" + " EXPRESSION\n" + ")\n");
// No SourceElements, no stepping/suspensions
try (DebuggerSession session = startSession(new SourceElement[] {})) {
startEval(source);
session.suspendNextExecution();
expectDone();
}
try (DebuggerSession session = startSession(new SourceElement[] {})) {
Breakpoint breakpoint = Breakpoint.newBuilder(DebuggerTester.getSourceImpl(source)).lineIs(2).oneShot().build();
session.install(breakpoint);
startEval(source);
expectSuspended((SuspendedEvent event) -> {
checkState(event, 2, true, "STATEMENT");
try {
event.prepareStepInto(StepConfig.newBuilder().sourceElements(SourceElement.STATEMENT).build());
fail();
} catch (IllegalStateException ex) {
// O.K.
}
try {
event.prepareStepInto(StepConfig.newBuilder().sourceElements(SourceElement.EXPRESSION).build());
fail();
} catch (IllegalStateException ex) {
// O.K.
}
try {
event.prepareStepInto(1);
fail();
} catch (IllegalStateException ex) {
// O.K.
}
});
expectDone();
}
try (DebuggerSession session = startSession()) {
startEval(source);
session.suspendNextExecution();
expectSuspended((SuspendedEvent event) -> {
checkState(event, 2, true, "STATEMENT");
try {
event.prepareStepInto(StepConfig.newBuilder().sourceElements(SourceElement.EXPRESSION).build());
fail();
} catch (IllegalArgumentException ex) {
// O.K.
}
});
expectDone();
}
try (DebuggerSession session = startSession(SourceElement.EXPRESSION)) {
startEval(source);
session.suspendNextExecution();
expectSuspended((SuspendedEvent event) -> {
checkState(event, 3, true, "EXPRESSION");
try {
event.prepareStepInto(StepConfig.newBuilder().sourceElements(SourceElement.STATEMENT).build());
fail();
} catch (IllegalArgumentException ex) {
// O.K.
}
// O.K.
event.prepareStepInto(1);
// O.K.
event.prepareStepInto(StepConfig.newBuilder().sourceElements(SourceElement.EXPRESSION).build());
});
expectDone();
}
}
use of com.oracle.truffle.api.debug.DebuggerSession in project graal by oracle.
the class StepTest method testStepIntoAndOut.
@Test
public void testStepIntoAndOut() throws Throwable {
final Source source = testSource("ROOT(\n" + " DEFINE(bar, STATEMENT),\n" + " DEFINE(foo, ROOT(STATEMENT(CALL(bar)), \n" + " STATEMENT(CALL(bar)))),\n" + " STATEMENT(CALL(foo)),\n" + " STATEMENT(CALL(foo)),\n" + " STATEMENT(CALL(foo))\n" + ")\n");
try (DebuggerSession session = startSession()) {
startEval(source);
session.suspendNextExecution();
expectSuspended((SuspendedEvent event) -> {
checkState(event, 5, true, "STATEMENT(CALL(foo))").prepareStepInto(1);
});
expectSuspended((SuspendedEvent event) -> {
checkState(event, 3, true, "STATEMENT(CALL(bar))").prepareStepOut(1);
});
expectSuspended((SuspendedEvent event) -> {
checkState(event, 5, false, "CALL(foo)").prepareStepOver(1);
});
expectSuspended((SuspendedEvent event) -> {
checkState(event, 6, true, "STATEMENT(CALL(foo))").prepareStepInto(1);
});
expectSuspended((SuspendedEvent event) -> {
checkState(event, 3, true, "STATEMENT(CALL(bar))").prepareStepInto(1);
});
expectSuspended((SuspendedEvent event) -> {
checkState(event, 2, true, "STATEMENT").prepareStepOut(1);
});
expectSuspended((SuspendedEvent event) -> {
checkState(event, 3, false, "CALL(bar)").prepareStepOut(1);
});
expectSuspended((SuspendedEvent event) -> {
checkState(event, 6, false, "CALL(foo)").prepareStepOut(1);
});
expectDone();
}
}
use of com.oracle.truffle.api.debug.DebuggerSession in project graal by oracle.
the class StepTest method testBlockStepIntoOver.
@Test
public void testBlockStepIntoOver() throws Throwable {
final Source source = testSource("ROOT(\n" + " STATEMENT,\n" + " STATEMENT,\n" + " STATEMENT,\n" + " STATEMENT,\n" + " STATEMENT,\n" + " STATEMENT,\n" + " STATEMENT,\n" + " STATEMENT\n" + ")\n");
try (DebuggerSession session = startSession()) {
startEval(source);
session.suspendNextExecution();
expectSuspended((SuspendedEvent event) -> {
checkState(event, 2, true, "STATEMENT").prepareStepInto(1);
});
expectSuspended((SuspendedEvent event) -> {
checkState(event, 3, true, "STATEMENT").prepareStepInto(2);
});
expectSuspended((SuspendedEvent event) -> {
checkState(event, 5, true, "STATEMENT").prepareStepOver(1);
});
expectSuspended((SuspendedEvent event) -> {
checkState(event, 6, true, "STATEMENT").prepareStepOver(3);
});
expectSuspended((SuspendedEvent event) -> {
checkState(event, 9, true, "STATEMENT").prepareContinue();
});
expectDone();
}
}
use of com.oracle.truffle.api.debug.DebuggerSession in project graal by oracle.
the class StepTest method testStepOver1.
@Test
public void testStepOver1() throws Throwable {
final Source source = testSource("ROOT(\n" + " DEFINE(bar, STATEMENT),\n" + " DEFINE(foo, ROOT(STATEMENT(CALL(bar)), \n" + " STATEMENT(CALL(bar)))),\n" + " STATEMENT(CALL(foo)),\n" + " STATEMENT(CALL(foo)),\n" + " STATEMENT(CALL(foo))\n" + ")\n");
try (DebuggerSession session = startSession()) {
startEval(source);
session.suspendNextExecution();
expectSuspended((SuspendedEvent event) -> {
checkState(event, 5, true, "STATEMENT(CALL(foo))").prepareStepOver(1);
});
expectSuspended((SuspendedEvent event) -> {
checkState(event, 6, true, "STATEMENT(CALL(foo))").prepareStepOver(1);
});
expectSuspended((SuspendedEvent event) -> {
checkState(event, 7, true, "STATEMENT(CALL(foo))").prepareStepOver(1);
});
expectDone();
}
}
Aggregations