Search in sources :

Example 11 with EventContext

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();
    }
}
Also used : EventContext(com.oracle.truffle.api.instrumentation.EventContext) VirtualFrame(com.oracle.truffle.api.frame.VirtualFrame) LoadSourceSectionEvent(com.oracle.truffle.api.instrumentation.LoadSourceSectionEvent) LoadSourceSectionListener(com.oracle.truffle.api.instrumentation.LoadSourceSectionListener) ExecutionEventListener(com.oracle.truffle.api.instrumentation.ExecutionEventListener)

Example 12 with EventContext

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());
}
Also used : EventContext(com.oracle.truffle.api.instrumentation.EventContext) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Callback(com.oracle.truffle.api.instrumentation.test.examples.DebuggerController.Callback) Test(org.junit.Test) AbstractInstrumentationTest(com.oracle.truffle.api.instrumentation.test.AbstractInstrumentationTest)

Example 13 with EventContext

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));
        }
    });
}
Also used : EventContext(com.oracle.truffle.api.instrumentation.EventContext) ExecutionEventNodeFactory(com.oracle.truffle.api.instrumentation.ExecutionEventNodeFactory) SourceSectionFilter(com.oracle.truffle.api.instrumentation.SourceSectionFilter)

Aggregations

EventContext (com.oracle.truffle.api.instrumentation.EventContext)13 VirtualFrame (com.oracle.truffle.api.frame.VirtualFrame)5 Test (org.junit.Test)5 ExecutionEventListener (com.oracle.truffle.api.instrumentation.ExecutionEventListener)4 AbstractInstrumentationTest (com.oracle.truffle.api.instrumentation.test.AbstractInstrumentationTest)4 Callback (com.oracle.truffle.api.instrumentation.test.examples.DebuggerController.Callback)4 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)4 Source (org.graalvm.polyglot.Source)4 ExecutionEventNodeFactory (com.oracle.truffle.api.instrumentation.ExecutionEventNodeFactory)3 Node (com.oracle.truffle.api.nodes.Node)3 RootNode (com.oracle.truffle.api.nodes.RootNode)3 ExecutionEventNode (com.oracle.truffle.api.instrumentation.ExecutionEventNode)2 WrapperNode (com.oracle.truffle.api.instrumentation.InstrumentableNode.WrapperNode)2 LoadSourceSectionEvent (com.oracle.truffle.api.instrumentation.LoadSourceSectionEvent)2 LoadSourceSectionListener (com.oracle.truffle.api.instrumentation.LoadSourceSectionListener)2 ProbeNode (com.oracle.truffle.api.instrumentation.ProbeNode)2 SourceSectionFilter (com.oracle.truffle.api.instrumentation.SourceSectionFilter)2 TruffleBoundary (com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)1 EventBinding (com.oracle.truffle.api.instrumentation.EventBinding)1 InstrumentableNode (com.oracle.truffle.api.instrumentation.InstrumentableNode)1