use of com.oracle.truffle.api.instrumentation.EventContext in project graal by oracle.
the class InstrumentationUpdateTest method setEventFilter.
private void setEventFilter(SourceSectionFilter filter) {
EventBinding<?> old = this.eventBinding;
eventBinding = instrumentEnv.getInstrumenter().attachExecutionEventListener(filter, new ExecutionEventListener() {
public void onReturnValue(EventContext ctx, VirtualFrame frame, Object result) {
}
public void onReturnExceptional(EventContext ctx, VirtualFrame frame, Throwable exception) {
}
public void onEnter(EventContext ctx, VirtualFrame frame) {
executionEvents.add(ctx);
}
});
instrumentEnv.getInstrumenter().attachLoadSourceSectionListener(filter, new LoadSourceSectionListener() {
public void onLoad(LoadSourceSectionEvent event) {
loadEvents.add(event);
}
}, true);
// dispose afterwards to avoid disposal of instrumentation wrappers
if (old != null) {
old.dispose();
}
}
use of com.oracle.truffle.api.instrumentation.EventContext 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());
}
use of com.oracle.truffle.api.instrumentation.EventContext in project graal by oracle.
the class CPUTracerSnippets method resetTracer.
private synchronized void resetTracer() {
assert Thread.holdsLock(this);
if (activeBinding != null) {
activeBinding.dispose();
activeBinding = null;
}
if (!collecting || closed) {
return;
}
SourceSectionFilter f = this.filter;
if (f == null) {
f = DEFAULT_FILTER;
}
this.activeBinding = env.getInstrumenter().attachExecutionEventFactory(f, new ExecutionEventNodeFactory() {
@Override
public ExecutionEventNode create(EventContext context) {
return new CounterNode(getCounter(context));
}
});
}
Aggregations