Search in sources :

Example 1 with LoadSourceEvent

use of com.oracle.truffle.api.instrumentation.LoadSourceEvent in project graal by oracle.

the class InstrumentationMultiThreadingTest method createDummyBindings.

private static EventBinding<?>[] createDummyBindings(Instrumenter instrumenter) {
    EventBinding<?>[] bindings = new EventBinding<?>[5];
    int bi = 0;
    ExecutionEventListener dummyListener = new ExecutionEventListener() {

        public void onReturnValue(EventContext context, VirtualFrame frame, Object result) {
        }

        public void onReturnExceptional(EventContext context, VirtualFrame frame, Throwable exception) {
        }

        public void onEnter(EventContext context, VirtualFrame frame) {
        }
    };
    bindings[bi++] = instrumenter.attachExecutionEventListener(SourceSectionFilter.newBuilder().tagIs(InstrumentationTestLanguage.EXPRESSION).build(), dummyListener);
    bindings[bi++] = instrumenter.attachExecutionEventListener(SourceSectionFilter.newBuilder().tagIs(InstrumentationTestLanguage.STATEMENT).build(), dummyListener);
    bindings[bi++] = instrumenter.attachLoadSourceListener(SourceFilter.ANY, new LoadSourceListener() {

        public void onLoad(LoadSourceEvent event) {
        }
    }, true);
    bindings[bi++] = instrumenter.attachLoadSourceSectionListener(SourceSectionFilter.newBuilder().tagIs(InstrumentationTestLanguage.EXPRESSION).build(), new LoadSourceSectionListener() {

        public void onLoad(LoadSourceSectionEvent event) {
        }
    }, true);
    bindings[bi++] = instrumenter.attachLoadSourceSectionListener(SourceSectionFilter.newBuilder().tagIs(InstrumentationTestLanguage.STATEMENT).build(), new LoadSourceSectionListener() {

        public void onLoad(LoadSourceSectionEvent event) {
        }
    }, true);
    return bindings;
}
Also used : EventContext(com.oracle.truffle.api.instrumentation.EventContext) VirtualFrame(com.oracle.truffle.api.frame.VirtualFrame) EventBinding(com.oracle.truffle.api.instrumentation.EventBinding) LoadSourceEvent(com.oracle.truffle.api.instrumentation.LoadSourceEvent) LoadSourceSectionEvent(com.oracle.truffle.api.instrumentation.LoadSourceSectionEvent) LoadSourceListener(com.oracle.truffle.api.instrumentation.LoadSourceListener) LoadSourceSectionListener(com.oracle.truffle.api.instrumentation.LoadSourceSectionListener) ExecutionEventListener(com.oracle.truffle.api.instrumentation.ExecutionEventListener)

Example 2 with LoadSourceEvent

use of com.oracle.truffle.api.instrumentation.LoadSourceEvent in project graal by oracle.

the class Debugger method getLoadedSources.

/**
 * Returns a list of all loaded sources. The sources are returned in the order as they have been
 * loaded by the languages.
 *
 * @return an unmodifiable list of sources
 * @since 0.17
 * @deprecated not very flexible, polls all sources without any notification about changes.
 */
@Deprecated
public List<Source> getLoadedSources() {
    final List<Source> sources = new ArrayList<>();
    EventBinding<?> binding = env.getInstrumenter().attachLoadSourceListener(SourceFilter.ANY, new LoadSourceListener() {

        public void onLoad(LoadSourceEvent event) {
            sources.add(event.getSource());
        }
    }, true);
    binding.dispose();
    return Collections.unmodifiableList(sources);
}
Also used : LoadSourceEvent(com.oracle.truffle.api.instrumentation.LoadSourceEvent) ArrayList(java.util.ArrayList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) LoadSourceListener(com.oracle.truffle.api.instrumentation.LoadSourceListener) Source(com.oracle.truffle.api.source.Source)

Aggregations

LoadSourceEvent (com.oracle.truffle.api.instrumentation.LoadSourceEvent)2 LoadSourceListener (com.oracle.truffle.api.instrumentation.LoadSourceListener)2 VirtualFrame (com.oracle.truffle.api.frame.VirtualFrame)1 EventBinding (com.oracle.truffle.api.instrumentation.EventBinding)1 EventContext (com.oracle.truffle.api.instrumentation.EventContext)1 ExecutionEventListener (com.oracle.truffle.api.instrumentation.ExecutionEventListener)1 LoadSourceSectionEvent (com.oracle.truffle.api.instrumentation.LoadSourceSectionEvent)1 LoadSourceSectionListener (com.oracle.truffle.api.instrumentation.LoadSourceSectionListener)1 Source (com.oracle.truffle.api.source.Source)1 ArrayList (java.util.ArrayList)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1