use of com.oracle.truffle.api.debug.DebuggerSession in project graal by oracle.
the class SuspendedEventTest method testIsInternal.
@Test
public void testIsInternal() throws Throwable {
final Source source = Source.newBuilder(InstrumentationTestLanguage.ID, "ROOT(\n" + " DEFINE(bar, ROOT(STATEMENT)),\n" + " DEFINE(foo, STATEMENT, \n" + " STATEMENT(CALL(bar))),\n" + " STATEMENT(CALL(foo))\n" + ")\n", "internal test code").internal(true).build();
try (DebuggerSession session = startSession()) {
session.install(Breakpoint.newBuilder(getSourceImpl(source)).lineIs(2).build());
startEval(source);
expectSuspended((SuspendedEvent event) -> {
Iterator<DebugStackFrame> frameIterator = event.getStackFrames().iterator();
DebugStackFrame frame = frameIterator.next();
assertTrue(frame.isInternal());
frame = frameIterator.next();
assertTrue(frame.isInternal());
frame = frameIterator.next();
assertTrue(frame.isInternal());
});
expectDone();
}
}
use of com.oracle.truffle.api.debug.DebuggerSession 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.DebuggerSession 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.DebuggerSession 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.DebuggerSession in project graal by oracle.
the class SuspensionFilterTest method testInternalNoSuspend.
@Test
public void testInternalNoSuspend() throws Exception {
final Source source = Source.newBuilder(InstrumentationTestLanguage.ID, "ROOT(\n" + " STATEMENT(EXPRESSION),\n" + " STATEMENT(CONSTANT(42))\n" + ")\n", "test").internal(true).build();
// No suspension filter is necessary, internal sources are ignored by default
try (DebuggerSession session = startSession()) {
session.suspendNextExecution();
startEval(source);
// does not stop in internal source
expectDone();
}
}
Aggregations