use of com.oracle.truffle.api.debug.SuspensionFilter in project graal by oracle.
the class SuspensionFilterTest method testInternalStepping.
@Test
public void testInternalStepping() throws Exception {
final Source internSource = Source.newBuilder(InstrumentationTestLanguage.ID, "ROOT(\n" + " DEFINE(intern, \n" + " STATEMENT(EXPRESSION),\n" + " STATEMENT(CONSTANT(42))\n" + " ),\n" + " CALL(intern)\n" + ")\n", "intern").internal(true).build();
final Source source = testSource("ROOT(\n" + " STATEMENT(CALL(intern)),\n" + " STATEMENT(CONSTANT(1)),\n" + " STATEMENT(CALL(intern))\n" + ")\n");
SuspensionFilter suspensionFilter = SuspensionFilter.newBuilder().includeInternal(false).build();
try (DebuggerSession session = startSession()) {
session.setSteppingFilter(suspensionFilter);
session.suspendNextExecution();
startEval(internSource);
// does not stop in internal source
expectDone();
startEval(source);
expectSuspended((SuspendedEvent event) -> {
checkState(event, 2, true, "STATEMENT(CALL(intern))");
event.prepareStepInto(1);
});
// Step into does not go into the internal source:
expectSuspended((SuspendedEvent event) -> {
checkState(event, 3, true, "STATEMENT(CONSTANT(1))");
Breakpoint bp = Breakpoint.newBuilder(getSourceImpl(internSource)).lineIs(3).build();
session.install(bp);
event.prepareContinue();
});
// Breakpoint stops there:
expectSuspended((SuspendedEvent event) -> {
checkState(event, 3, true, "STATEMENT(EXPRESSION)");
event.prepareContinue();
});
expectDone();
}
}
use of com.oracle.truffle.api.debug.SuspensionFilter in project graal by oracle.
the class SuspensionFilterTest method testInitializationFilterChange.
@Test
public void testInitializationFilterChange() {
// Set to skip the initialization, but put two breakpoints there.
// Verify that step just skips the code to the next breakpoint.
// After second breakpoint is hit, change the filter to allow stepping
// in the initialization code.
String initCode = "ROOT(\n" + " DEFINE(initFoo, \n" + // Skipped by suspensionFilter
" STATEMENT(EXPRESSION),\n" + // l. 4 Breakpoint
" STATEMENT(EXPRESSION),\n" + // Skipped by suspensionFilter
" STATEMENT(CONSTANT(2)),\n" + // l. 6 Breakpoint, filter changed
" STATEMENT(EXPRESSION),\n" + " LOOP(2,\n" + // l. 8 Step stops here
" STATEMENT(CONSTANT(1)))\n" + " ), \n" + " STATEMENT(CALL(initFoo))\n" + ")\n";
Source initSource = Source.newBuilder(InstrumentationTestLanguage.ID, initCode, "<init>").buildLiteral();
InstrumentationTestLanguage.envConfig = Collections.singletonMap("initSource", initSource);
final Source source = testSource("ROOT(\n" + " STATEMENT(CONSTANT(42))\n" + ")\n");
SuspensionFilter.Builder filterBuilder = SuspensionFilter.newBuilder().ignoreLanguageContextInitialization(true);
SuspensionFilter suspensionFilter = filterBuilder.build();
try (DebuggerSession session = startSession()) {
session.setSteppingFilter(suspensionFilter);
session.suspendNextExecution();
Breakpoint bp4 = Breakpoint.newBuilder(getSourceImpl(initSource)).lineIs(4).build();
Breakpoint bp6 = Breakpoint.newBuilder(getSourceImpl(initSource)).lineIs(6).build();
session.install(bp4);
session.install(bp6);
startEval(source);
expectSuspended((SuspendedEvent event) -> {
checkState(event, 4, true, "STATEMENT(EXPRESSION)");
Assert.assertFalse(event.isLanguageContextInitialized());
Assert.assertTrue(event.getBreakpoints().contains(bp4));
event.prepareStepOver(1);
});
expectSuspended((SuspendedEvent event) -> {
checkState(event, 6, true, "STATEMENT(EXPRESSION)");
Assert.assertFalse(event.isLanguageContextInitialized());
Assert.assertTrue(event.getBreakpoints().contains(bp6));
filterBuilder.ignoreLanguageContextInitialization(false);
session.setSteppingFilter(filterBuilder.build());
event.prepareStepOver(1);
});
expectSuspended((SuspendedEvent event) -> {
Assert.assertFalse(event.isLanguageContextInitialized());
checkState(event, 8, true, "STATEMENT(CONSTANT(1))").prepareContinue();
});
expectDone();
}
}
Aggregations