use of com.oracle.truffle.api.instrumentation.test.examples.DebuggerController.Callback in project graal by oracle.
the class DebuggerExampleTest method testStepOut.
@Test
@SuppressWarnings("hiding")
public void testStepOut() throws IOException {
Source source = lines(// 1
"ROOT(", // 2
"DEFINE(foo,STATEMENT),", // 3
"DEFINE(bar", // 4
",STATEMENT", // 5
",STATEMENT(CALL(foo))", // 6
",STATEMENT),", /**/
"STATEMENT(CALL(bar)))");
// 7
final AtomicBoolean allStepped = new AtomicBoolean();
debugger.installBreakpoint(2, new Callback() {
@Override
public void halted(DebuggerController debugger, EventContext haltedAt) {
assertLineAt(haltedAt, 2);
debugger.stepOut(new Callback() {
@Override
public void halted(DebuggerController debugger, EventContext haltedAt) {
assertLineAt(haltedAt, 6);
debugger.stepOver(new Callback() {
@Override
public void halted(DebuggerController debugger, EventContext haltedAt) {
throw new AssertionError();
}
});
allStepped.set(true);
}
});
}
});
run(source);
Assert.assertTrue(allStepped.get());
}
use of com.oracle.truffle.api.instrumentation.test.examples.DebuggerController.Callback in project graal by oracle.
the class DebuggerExampleTest method testStepInto.
@Test
@SuppressWarnings("hiding")
public void testStepInto() throws IOException {
Source source = lines(// 1
"ROOT(", // 2
"DEFINE(foo,STATEMENT),", // 3
"DEFINE(bar", // 4
",STATEMENT", // 5
",STATEMENT(CALL(foo))", // 6
",STATEMENT),", /**/
"STATEMENT(CALL(bar)))");
// 7
final AtomicBoolean allStepped = new AtomicBoolean();
debugger.installBreakpoint(7, new Callback() {
public void halted(DebuggerController debugger, EventContext haltedAt) {
assertLineAt(haltedAt, 7);
debugger.stepInto(new Callback() {
public void halted(DebuggerController debugger, EventContext haltedAt) {
assertLineAt(haltedAt, 4);
debugger.stepInto(new Callback() {
public void halted(DebuggerController debugger, EventContext haltedAt) {
assertLineAt(haltedAt, 5);
debugger.stepInto(new Callback() {
public void halted(DebuggerController debugger, EventContext haltedAt) {
assertLineAt(haltedAt, 2);
debugger.stepInto(new Callback() {
public void halted(DebuggerController debugger, EventContext haltedAt) {
assertLineAt(haltedAt, 6);
debugger.stepInto(new Callback() {
public void halted(DebuggerController debugger, EventContext haltedAt) {
throw new AssertionError();
}
});
allStepped.set(true);
}
});
}
});
}
});
}
});
}
});
run(source);
Assert.assertTrue(allStepped.get());
}
use of com.oracle.truffle.api.instrumentation.test.examples.DebuggerController.Callback in project graal by oracle.
the class DebuggerExampleTest method testStepOver.
@Test
@SuppressWarnings("hiding")
public void testStepOver() throws IOException {
Source source = lines(// 1
"ROOT(", // 2
"DEFINE(foo,STATEMENT),", // 3
"DEFINE(bar", // 4
",STATEMENT", // 5
",STATEMENT(CALL(foo))", // 6
",STATEMENT),", /**/
"STATEMENT(CALL(bar)))");
// 7
final AtomicBoolean allStepped = new AtomicBoolean();
debugger.installBreakpoint(4, new Callback() {
public void halted(DebuggerController debugger, EventContext haltedAt) {
assertLineAt(haltedAt, 4);
debugger.stepOver(new Callback() {
public void halted(DebuggerController debugger, EventContext haltedAt) {
assertLineAt(haltedAt, 5);
debugger.stepOver(new Callback() {
public void halted(DebuggerController debugger, EventContext haltedAt) {
assertLineAt(haltedAt, 6);
allStepped.set(true);
debugger.stepOver(new Callback() {
public void halted(DebuggerController debugger, EventContext haltedAt) {
throw new AssertionError();
}
});
}
});
}
});
}
});
run(source);
Assert.assertTrue(allStepped.get());
}
use of com.oracle.truffle.api.instrumentation.test.examples.DebuggerController.Callback in project graal by oracle.
the class DebuggerExampleTest method testBreakpoint.
@Test
public void testBreakpoint() throws IOException {
final AtomicBoolean breakpointHit = new AtomicBoolean();
debugger.installBreakpoint(1, new Callback() {
@Override
public void halted(DebuggerController d, EventContext haltedAt) {
Assert.assertEquals(1, haltedAt.getInstrumentedSourceSection().getStartLine());
breakpointHit.set(true);
}
});
run(lines("BLOCK(STATEMENT,", "STATEMENT,", "STATEMENT)"));
Assert.assertTrue(breakpointHit.get());
}
Aggregations