use of com.oracle.truffle.api.debug.DebuggerSession in project graal by oracle.
the class DebuggerContextsTest method testInContextEval.
@Test
public void testInContextEval() {
try (Engine engine = Engine.create()) {
TestContextsListener contextsListener = new TestContextsListener();
List<ContextEvent> events = contextsListener.events;
Debugger debugger = engine.getInstruments().get("debugger").lookup(Debugger.class);
try (DebuggerSession session = debugger.startSession(null)) {
session.setContextsListener(contextsListener, false);
Context context = Context.newBuilder().engine(engine).build();
assert context != null;
assertEquals(1, events.size());
assertTrue(events.get(0).created);
DebugContext dc = events.get(0).context;
assertNotNull(dc);
assertNull(events.get(0).language);
// "Global" evaluation in the brand new context
DebugValue result = dc.evaluate("VARIABLE(a, 10)", InstrumentationTestLanguage.ID);
assertEquals(3, events.size());
assertTrue(events.get(1).created);
assertEquals(InstrumentationTestLanguage.ID, events.get(1).language.getId());
assertTrue(events.get(2).languageInitialized);
String type = dc.runInContext(() -> {
assertEquals("10", result.as(String.class));
DebugValue metaObj = result.getMetaObject();
return metaObj.as(String.class);
});
assertEquals("Integer", type);
assertEquals(3, events.size());
}
}
}
use of com.oracle.truffle.api.debug.DebuggerSession in project graal by oracle.
the class DebuggerSessionTest method testResumeAll4.
@Test
public void testResumeAll4() {
Source testSource = testSource("ROOT(\n" + "STATEMENT,\n" + "STATEMENT)");
try (DebuggerSession session = startSession()) {
for (int i = 0; i < 10; i++) {
session.suspendNextExecution();
startEval(testSource);
expectSuspended((SuspendedEvent event) -> {
checkState(event, 2, true, "STATEMENT").prepareStepOver(1);
});
// test that resume does not affect current stepping behavior
session.resumeAll();
expectSuspended((SuspendedEvent event) -> {
checkState(event, 3, true, "STATEMENT").prepareStepOver(1);
});
expectDone();
}
}
}
use of com.oracle.truffle.api.debug.DebuggerSession in project graal by oracle.
the class DebuggerSessionTest method testSuspendNextExecution3.
@Test
public void testSuspendNextExecution3() {
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++) {
session.suspendNextExecution();
startEval(testSource);
expectSuspended((SuspendedEvent event) -> {
checkState(event, 2, true, "STATEMENT").prepareContinue();
});
expectDone();
}
}
}
use of com.oracle.truffle.api.debug.DebuggerSession in project graal by oracle.
the class DebuggerSessionTest method testSuspendNextExecution4.
@Test
public void testSuspendNextExecution4() {
Source testSource = testSource("ROOT(\n" + "STATEMENT,\n" + "STATEMENT)");
try (DebuggerSession session = startSession()) {
session.suspendNextExecution();
startEval(testSource);
expectSuspended((SuspendedEvent event) -> {
checkState(event, 2, true, "STATEMENT").prepareContinue();
// use suspend next in an event
event.getSession().suspendNextExecution();
});
expectSuspended((SuspendedEvent event) -> {
checkState(event, 3, true, "STATEMENT").prepareContinue();
});
expectDone();
}
}
use of com.oracle.truffle.api.debug.DebuggerSession in project graal by oracle.
the class DebuggerSessionTest method testResumeThread2.
@Test
public void testResumeThread2() {
Source testSource = testSource("ROOT(\n" + "STATEMENT,\n" + "STATEMENT)");
try (DebuggerSession session = startSession()) {
for (int i = 0; i < 10; i++) {
session.suspendNextExecution();
resume(session, getEvalThread());
startEval(testSource);
// even if the thread is resumed suspend next execution will trigger.
expectSuspended((SuspendedEvent event) -> {
checkState(event, 2, true, "STATEMENT").prepareStepOver(1);
});
resume(session, getEvalThread());
expectDone();
}
}
}
Aggregations