use of com.oracle.truffle.api.instrumentation.EventContext in project graal by oracle.
the class DebuggerSessionSnippets method collectDebuggerNodes.
private List<DebuggerNode> collectDebuggerNodes(DebuggerNode source, SuspendAnchor suspendAnchor) {
EventContext context = source.getContext();
List<DebuggerNode> nodes = new ArrayList<>();
nodes.add(source);
Iterator<ExecutionEventNode> nodesIterator = context.lookupExecutionEventNodes(allBindings);
if (SuspendAnchor.BEFORE.equals(suspendAnchor)) {
// We collect nodes following the source (these nodes remain to be executed)
boolean after = false;
while (nodesIterator.hasNext()) {
DebuggerNode node = (DebuggerNode) nodesIterator.next();
if (after) {
if (node.isActiveAt(suspendAnchor)) {
nodes.add(node);
}
} else {
after = node == source;
}
}
} else {
// We collect nodes preceding the source (these nodes remain to be executed)
while (nodesIterator.hasNext()) {
DebuggerNode node = (DebuggerNode) nodesIterator.next();
if (node == source) {
break;
}
if (node.isActiveAt(suspendAnchor)) {
nodes.add(node);
}
}
}
return nodes;
}
use of com.oracle.truffle.api.instrumentation.EventContext in project graal by oracle.
the class InstrumentationUpdateTest method assertExecuted.
private void assertExecuted(Node... children) {
Iterator<EventContext> executeIterator = executionEvents.iterator();
for (Node loadedChild : children) {
Assert.assertTrue(executeIterator.hasNext());
Assert.assertSame(loadedChild, executeIterator.next().getInstrumentedNode());
}
Assert.assertFalse(executeIterator.hasNext());
}
use of com.oracle.truffle.api.instrumentation.EventContext in project graal by oracle.
the class InputFilterTest method assertCleanedUp.
private void assertCleanedUp(String code) {
// first we capture all root nodes used by the code.
Set<RootNode> rootNodes = new HashSet<>();
EventBinding<?> binding = instrumenter.attachExecutionEventListener(SourceSectionFilter.ANY, new ExecutionEventListener() {
public void onEnter(EventContext c, VirtualFrame frame) {
addRoot(c);
}
@TruffleBoundary
private void addRoot(EventContext c) {
rootNodes.add(c.getInstrumentedNode().getRootNode());
}
public void onReturnValue(EventContext c, VirtualFrame frame, Object result) {
}
public void onReturnExceptional(EventContext c, VirtualFrame frame, Throwable exception) {
}
});
execute(code);
binding.dispose();
// we execute again to let the instrumentation wrappers be cleaned up
execute(code);
for (RootNode root : rootNodes) {
// all frame slots got removed
assertEquals(new HashSet<>(), root.getFrameDescriptor().getIdentifiers());
// no wrappers left
root.accept(new NodeVisitor() {
public boolean visit(Node node) {
if (node instanceof WrapperNode) {
throw new AssertionError();
}
return true;
}
});
}
}
use of com.oracle.truffle.api.instrumentation.EventContext 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.EventContext 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());
}
Aggregations