use of com.oracle.truffle.api.debug.SuspensionFilter in project graal by oracle.
the class SuspensionFilterTest method testSuspendAfterInitialization2.
@Test
public void testSuspendAfterInitialization2() {
// Suspend after initialization code finishes,
// but can step into the same code that was executed during initialization, later on.
Source initSource = Source.newBuilder(InstrumentationTestLanguage.ID, "STATEMENT(EXPRESSION)", "<init>").buildLiteral();
InstrumentationTestLanguage.envConfig = new HashMap<>();
InstrumentationTestLanguage.envConfig.put("initSource", initSource);
InstrumentationTestLanguage.envConfig.put("runInitAfterExec", true);
final Source source = testSource("ROOT(\n" + " STATEMENT(CONSTANT(42))\n" + ")\n");
SuspensionFilter suspensionFilter = SuspensionFilter.newBuilder().ignoreLanguageContextInitialization(true).build();
try (DebuggerSession session = startSession()) {
session.setSteppingFilter(suspensionFilter);
session.suspendNextExecution();
startEval(source);
expectSuspended((SuspendedEvent event) -> {
checkState(event, 2, true, "STATEMENT(CONSTANT(42))").prepareStepOver(1);
Assert.assertTrue(event.isLanguageContextInitialized());
session.suspendNextExecution();
});
expectSuspended((SuspendedEvent event) -> {
checkState(event, 1, true, "STATEMENT(EXPRESSION)").prepareContinue();
Assert.assertTrue(event.isLanguageContextInitialized());
});
expectDone();
}
}
use of com.oracle.truffle.api.debug.SuspensionFilter in project graal by oracle.
the class SuspensionFilterTest method testInternalSteppingChange.
@Test
public void testInternalSteppingChange() 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" + " LOOP(5,\n" + " STATEMENT(CALL(intern))\n" + " )\n" + ")\n");
SuspensionFilter suspensionFilter = SuspensionFilter.newBuilder().includeInternal(true).build();
try (DebuggerSession session = startSession()) {
session.setSteppingFilter(suspensionFilter);
session.suspendNextExecution();
startEval(internSource);
// we stop in the internal source as the filter does not ignore internal sources now
expectSuspended((SuspendedEvent event) -> {
checkState(event, 3, true, "STATEMENT(EXPRESSION)");
event.prepareStepOver(1);
});
expectSuspended((SuspendedEvent event) -> {
checkState(event, 4, true, "STATEMENT(CONSTANT(42))");
event.prepareContinue();
});
expectDone();
// Ignore internal sources now
suspensionFilter = SuspensionFilter.newBuilder().includeInternal(false).build();
session.setSteppingFilter(suspensionFilter);
session.suspendNextExecution();
startEval(source);
expectSuspended((SuspendedEvent event) -> {
checkState(event, 3, true, "STATEMENT(CALL(intern))");
event.prepareStepInto(1);
});
// Step into does not go into the internal source:
expectSuspended((SuspendedEvent event) -> {
checkState(event, 3, true, "STATEMENT(CALL(intern))");
// do not ignore instenal sources again
session.setSteppingFilter(SuspensionFilter.newBuilder().includeInternal(true).build());
event.prepareStepInto(1);
});
// Stopped in an internal source again
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 testSourceFilter.
@Test
public void testSourceFilter() {
final Source source1 = Source.newBuilder(InstrumentationTestLanguage.ID, "ROOT(\n" + " DEFINE(foo1,\n" + " STATEMENT(CONSTANT(43))\n" + " ))\n", "Source1").buildLiteral();
final Source source2 = Source.newBuilder(InstrumentationTestLanguage.ID, "ROOT(\n" + " DEFINE(foo2,\n" + " STATEMENT(CONSTANT(44))\n" + " ))\n", "Source2").buildLiteral();
final Source source3 = testSource("ROOT(\n" + " CALL(foo1),\n" + " CALL(foo2),\n" + " STATEMENT(CALL(foo1)),\n" + " STATEMENT(CALL(foo2)),\n" + " STATEMENT(CALL(foo1)),\n" + " STATEMENT(CALL(foo2)),\n" + " STATEMENT(CONSTANT(100))\n" + ")\n");
try (DebuggerSession session = startSession()) {
// Filter out all sections
SuspensionFilter suspensionFilter = SuspensionFilter.newBuilder().sourceIs(s -> false).build();
session.setSteppingFilter(suspensionFilter);
session.suspendNextExecution();
startEval(source1);
expectDone();
startEval(source2);
expectDone();
startEval(source3);
expectDone();
Predicate<com.oracle.truffle.api.source.Source> filterSource1 = source -> {
return source.getName().indexOf("Source1") < 0;
};
suspensionFilter = SuspensionFilter.newBuilder().sourceIs(filterSource1).build();
session.setSteppingFilter(suspensionFilter);
session.suspendNextExecution();
startEval(source3);
// Skip foo1 and suspend in foo2:
expectSuspended((SuspendedEvent event) -> {
checkState(event, 3, true, "STATEMENT(CONSTANT(44))");
event.prepareStepOver(1);
});
expectSuspended((SuspendedEvent event) -> {
checkState(event, 3, false, "CALL(foo2)");
event.prepareStepInto(1);
});
expectSuspended((SuspendedEvent event) -> {
checkState(event, 4, true, "STATEMENT(CALL(foo1))");
event.prepareStepInto(1);
});
expectSuspended((SuspendedEvent event) -> {
checkState(event, 5, true, "STATEMENT(CALL(foo2))");
event.prepareStepInto(1);
});
expectSuspended((SuspendedEvent event) -> {
checkState(event, 3, true, "STATEMENT(CONSTANT(44))");
event.prepareStepInto(2);
});
// Change the filter to filter Source2 out:
expectSuspended((SuspendedEvent event) -> {
checkState(event, 6, true, "STATEMENT(CALL(foo1))");
Predicate<com.oracle.truffle.api.source.Source> filterSource2 = source -> {
return source.getName().indexOf("Source2") < 0;
};
session.setSteppingFilter(SuspensionFilter.newBuilder().sourceIs(filterSource2).build());
event.prepareStepInto(1);
});
expectSuspended((SuspendedEvent event) -> {
checkState(event, 3, true, "STATEMENT(CONSTANT(43))");
event.prepareStepOut(1).prepareStepOver(1).prepareStepInto(1);
});
expectSuspended((SuspendedEvent event) -> {
checkState(event, 8, true, "STATEMENT(CONSTANT(100))");
event.prepareContinue();
});
expectDone();
}
}
use of com.oracle.truffle.api.debug.SuspensionFilter in project graal by oracle.
the class SuspensionFilterTest method testSuspendInInitialization.
@Test
public void testSuspendInInitialization() {
Source initSource = Source.newBuilder(InstrumentationTestLanguage.ID, "STATEMENT(EXPRESSION)", "<init>").buildLiteral();
InstrumentationTestLanguage.envConfig = Collections.singletonMap("initSource", initSource);
final Source source = testSource("ROOT(\n" + " DEFINE(foo, \n" + " STATEMENT(CONSTANT(42))\n" + " ), \n" + " STATEMENT(CALL(foo))\n" + ")\n");
SuspensionFilter suspensionFilter = SuspensionFilter.newBuilder().build();
// Empty filter does not filter anything
try (DebuggerSession session = startSession()) {
session.setSteppingFilter(suspensionFilter);
session.suspendNextExecution();
startEval(source);
expectSuspended((SuspendedEvent event) -> {
checkState(event, 1, true, "STATEMENT(EXPRESSION)").prepareContinue();
Assert.assertFalse(event.isLanguageContextInitialized());
});
expectDone();
}
}
use of com.oracle.truffle.api.debug.SuspensionFilter in project graal by oracle.
the class SuspensionFilterTest method testSuspendAfterInitialization.
@Test
public void testSuspendAfterInitialization() {
Source initSource = Source.newBuilder(InstrumentationTestLanguage.ID, "STATEMENT(EXPRESSION)", "<init>").buildLiteral();
InstrumentationTestLanguage.envConfig = Collections.singletonMap("initSource", initSource);
final Source source = testSource("ROOT(\n" + " STATEMENT(CONSTANT(42))\n" + ")\n");
SuspensionFilter suspensionFilter = SuspensionFilter.newBuilder().ignoreLanguageContextInitialization(true).build();
try (DebuggerSession session = startSession()) {
session.setSteppingFilter(suspensionFilter);
session.suspendNextExecution();
startEval(source);
expectSuspended((SuspendedEvent event) -> {
checkState(event, 2, true, "STATEMENT(CONSTANT(42))").prepareContinue();
Assert.assertTrue(event.isLanguageContextInitialized());
});
expectDone();
}
}
Aggregations