use of com.oracle.truffle.api.debug.SuspendedEvent in project graal by oracle.
the class DebuggerSessionTest method testSuspendAll1.
@Test
public void testSuspendAll1() {
Source testSource = testSource("ROOT(\n" + "STATEMENT,\n" + "STATEMENT)");
try (DebuggerSession session = startSession()) {
for (int i = 0; i < 10; i++) {
suspendAll(session);
startEval(testSource);
expectSuspended((SuspendedEvent event) -> {
checkState(event, 2, true, "STATEMENT").prepareContinue();
});
expectDone();
}
}
}
use of com.oracle.truffle.api.debug.SuspendedEvent in project graal by oracle.
the class DebuggerSessionTest method testClosing1.
@Test
public void testClosing1() {
Source testSource = testSource("ROOT(\n" + "STATEMENT,\n" + "STATEMENT)");
DebuggerSession session = startSession();
session.install(Breakpoint.newBuilder(getSourceImpl(testSource)).lineIs(3).build());
session.suspendNextExecution();
startEval(testSource);
expectSuspended((SuspendedEvent event) -> {
checkState(event, 2, true, "STATEMENT").prepareStepOver(1);
});
// closing the session should disable breakpoints and current stepping
session.close();
expectDone();
}
use of com.oracle.truffle.api.debug.SuspendedEvent in project graal by oracle.
the class DebuggerSessionTest method testSuspendThread1.
@Test
public void testSuspendThread1() {
Source testSource = testSource("ROOT(\n" + "STATEMENT,\n" + "STATEMENT)");
try (DebuggerSession session = startSession()) {
// do suspend next for a few times
for (int i = 0; i < 100; i++) {
suspend(session, getEvalThread());
startEval(testSource);
expectSuspended((SuspendedEvent event) -> {
checkState(event, 2, true, "STATEMENT").prepareContinue();
});
expectDone();
}
}
}
use of com.oracle.truffle.api.debug.SuspendedEvent in project graal by oracle.
the class DebuggerThreadsTest method testGetStartedThreads.
@Test
public void testGetStartedThreads() throws Exception {
Engine engine = Engine.create();
TestThreadsListener threadsListener = new TestThreadsListener();
List<ThreadEvent> events = threadsListener.events;
Debugger debugger = engine.getInstruments().get("debugger").lookup(Debugger.class);
CountDownLatch latch = new CountDownLatch(1);
DebuggerSession[] sessionPtr = new DebuggerSession[1];
try (DebuggerSession session = debugger.startSession(new SuspendedCallback() {
@Override
public void onSuspend(SuspendedEvent event) {
latch.countDown();
sessionPtr[0].setThreadsListener(threadsListener, true);
assertEquals(events.toString(), 2, events.size());
assertTrue(events.get(0).isNew);
assertNotNull(events.get(0).context);
assertTrue(events.get(1).isNew);
assertEquals(events.get(0).context, events.get(1).context);
assertNotEquals(events.get(0).thread, events.get(1).thread);
}
})) {
session.suspendNextExecution();
sessionPtr[0] = session;
try (Context context = Context.newBuilder().engine(engine).allowCreateThread(true).build()) {
Source source = testSource("ROOT(DEFINE(f1, EXPRESSION), SPAWN(f1), JOIN())");
context.eval(source);
source = testSource("ROOT(DEFINE(foo, STATEMENT), SPAWN(foo))");
context.eval(source);
latch.await();
context.eval(testSource("JOIN()"));
assertEquals(events.toString(), 3, events.size());
assertFalse(events.get(2).isNew);
assertTrue(events.get(0).thread == events.get(2).thread || events.get(1).thread == events.get(2).thread);
}
assertEquals(4, events.size());
}
}
use of com.oracle.truffle.api.debug.SuspendedEvent in project graal by oracle.
the class BreakpointTest method testDisableBreakpointsDuringSuspend.
@Test
public void testDisableBreakpointsDuringSuspend() throws Throwable {
Source source = testSource("ROOT(\n" + " DEFINE(foo,\n" + " LOOP(3,\n" + " STATEMENT)\n" + " ),\n" + " CALL(foo)\n" + ")\n");
try (DebuggerSession session = startSession()) {
Breakpoint breakpoint1 = session.install(Breakpoint.newBuilder(getSourceImpl(source)).lineIs(4).build());
Breakpoint breakpoint2 = session.install(Breakpoint.newBuilder(getSourceImpl(source)).lineIs(4).build());
Breakpoint breakpoint3 = session.install(Breakpoint.newBuilder(getSourceImpl(source)).lineIs(4).build());
startEval(source);
for (int i = 0; i < 3; i++) {
expectSuspended((SuspendedEvent event) -> {
checkState(event, 4, true, "STATEMENT").prepareContinue();
});
if (i == 0) {
breakpoint3.dispose();
}
if (i == 1) {
breakpoint1.dispose();
}
}
Assert.assertEquals(2, breakpoint1.getHitCount());
Assert.assertEquals(3, breakpoint2.getHitCount());
Assert.assertEquals(1, breakpoint3.getHitCount());
expectDone();
}
}
Aggregations