Class Instrumenter
- Since:
- 0.12
-
Method Summary
Modifier and TypeMethodDescriptionabstract <T extends AllocationListener>
EventBinding<T> attachAllocationListener
(AllocationEventFilter filter, T listener) Attach alistener
to be notified about allocations of guest language values.abstract <T extends ContextsListener>
EventBinding<T> attachContextsListener
(T listener, boolean includeActiveContexts) Attach alistener
to be notified about changes in contexts in guest language application.abstract <T extends OutputStream>
EventBinding<T> attachErrConsumer
(T stream) Attach an output stream as a consumer of theerror output
.abstract <T extends ExecuteSourceListener>
EventBinding<T> attachExecuteSourceListener
(SourceFilter filter, T listener, boolean includeExecutedSources) abstract <T extends ExecutionEventNodeFactory>
EventBinding<T> attachExecutionEventFactory
(NearestSectionFilter nearestFilter, SourceSectionFilter baseFilter, T factory) Starts execution event notification for the nearestSourceSection
as specified by theNearestSectionFilter
.abstract <T extends ExecutionEventNodeFactory>
EventBinding<T> attachExecutionEventFactory
(SourceSectionFilter eventFilter, SourceSectionFilter inputFilter, T factory) Starts execution event notification for a givenevent filter
andfactory
.final <T extends ExecutionEventNodeFactory>
EventBinding<T> attachExecutionEventFactory
(SourceSectionFilter eventFilter, T factory) Starts execution event notification for a givenevent filter
andfactory
.abstract <T extends ExecutionEventListener>
EventBinding<T> attachExecutionEventListener
(SourceSectionFilter eventFilter, SourceSectionFilter inputFilter, T listener) Deprecated.final <T extends ExecutionEventListener>
EventBinding<T> attachExecutionEventListener
(SourceSectionFilter eventFilter, T listener) Starts execution event notification for a givenevent filter
andlistener
.abstract <T extends LoadSourceListener>
EventBinding<T> attachLoadSourceListener
(SourceFilter filter, T listener, boolean includeExistingSources) abstract <T extends LoadSourceListener>
EventBinding<T> attachLoadSourceListener
(SourceSectionFilter filter, T listener, boolean includeExistingSources) abstract <T extends LoadSourceSectionListener>
EventBinding<T> attachLoadSourceSectionListener
(NearestSectionFilter nearestFilter, SourceSectionFilter baseFilter, T listener, boolean includeExistingSourceSections) Starts notifications for the nearestSourceSection
as specified by theNearestSectionFilter
and returns a binding that can be used to terminate notifications.abstract <T extends LoadSourceSectionListener>
EventBinding<T> attachLoadSourceSectionListener
(SourceSectionFilter filter, T listener, boolean includeExistingSourceSections) Starts notifications for eachSourceSection
in every newly loadedSource
and returns a binding that can be used to terminate notifications.abstract <T extends OutputStream>
EventBinding<T> attachOutConsumer
(T stream) Attach an output stream as a consumer of thestandard output
.abstract EventBinding
<? extends ThreadsActivationListener> Attach alistener
to be notified about when a thread gets entered or left in guest language applications.abstract <T extends ThreadsListener>
EventBinding<T> attachThreadsListener
(T listener, boolean includeInitializedThreads) Attach alistener
to be notified about changes in threads in guest language application.abstract <T extends ExecuteSourceListener>
EventBinding<T> createExecuteSourceBinding
(SourceFilter filter, T listener, boolean includeExecutedSources) abstract <T extends LoadSourceListener>
EventBinding<T> createLoadSourceBinding
(SourceFilter filter, T listener, boolean includeExistingSources) abstract <T extends LoadSourceSectionListener>
EventBinding<T> createLoadSourceSectionBinding
(NearestSectionFilter nearestFilter, SourceSectionFilter baseFilter, T listener, boolean includeExistingSourceSections) Create a binding to get notification for the nearest source section to the given position as specified by theNearestSectionFilter
.abstract <T extends LoadSourceSectionListener>
EventBinding<T> createLoadSourceSectionBinding
(SourceSectionFilter filter, T listener, boolean includeExistingSourceSections) Create a binding to get notifications for each newly loadedSourceSection
in every newly loadedSource
.abstract ExecutionEventNode
lookupExecutionEventNode
(Node node, EventBinding<?> binding) Returns the execution event node that was inserted at the node's location given an event binding, if any.final List
<SourceSection> Returns a filtered list of loadedSourceSection
instances.Returns an unmodifiableSet
of tag classes which where associated with this node.abstract void
visitLoadedSourceSections
(SourceSectionFilter filter, LoadSourceSectionListener listener) Notifies the listener for eachSourceSection
in every loadedSource
that corresponds to the filter.
-
Method Details
-
attachExecutionEventListener
public final <T extends ExecutionEventListener> EventBinding<T> attachExecutionEventListener(SourceSectionFilter eventFilter, T listener) Starts execution event notification for a givenevent filter
andlistener
. The execution events are delivered to theExecutionEventListener
.Returns a
binding
which allows to dispose the attached execution event binding. Disposing the binding removes all probes and wrappers from the AST that were created for this instrument. The removal of probes and wrappers is performed lazily on the next execution of the AST.By default no
input value events
are delivered to the listener.- Parameters:
eventFilter
- filters the events that are reported to the givenlistener
listener
- that listens to execution events.- Since:
- 0.33
- See Also:
-
attachExecutionEventFactory
public final <T extends ExecutionEventNodeFactory> EventBinding<T> attachExecutionEventFactory(SourceSectionFilter eventFilter, T factory) Starts execution event notification for a givenevent filter
andfactory
. Events are delivered to theExecutionEventNode
instances created by the factory.Returns a
binding
which allows to dispose the attached execution event binding. Disposing the binding removes all probes and wrappers from the AST that were created for this instrument. The removal of probes and wrappers is performed lazily on the next execution of the AST.By default no
input value events
are delivered to the created execution event nodes. To deliver inputs events useattachExecutionEventFactory(SourceSectionFilter, SourceSectionFilter, ExecutionEventNodeFactory)
instead.- Parameters:
eventFilter
- filters the events that are reported to theexecution event nodes
created by the factory.factory
- the factory that createsexecution event nodes
.- Since:
- 0.33
- See Also:
-
attachExecutionEventListener
@Deprecated(since="20.0") public abstract <T extends ExecutionEventListener> EventBinding<T> attachExecutionEventListener(SourceSectionFilter eventFilter, SourceSectionFilter inputFilter, T listener) Deprecated.inputFilters do not work for execution event listeners UseattachExecutionEventFactory(SourceSectionFilter, SourceSectionFilter, ExecutionEventNodeFactory)
or useattachExecutionEventListener(SourceSectionFilter, ExecutionEventListener)
instead.Starts execution event notification for a givenevent filter
andlistener
. The execution events are delivered to theExecutionEventListener
.Returns a
binding
which allows to dispose the attached execution event binding. Disposing the binding removes all probes and wrappers from the AST that were created for this instrument. The removal of probes and wrappers is performed lazily on the next execution of the AST.The input filter argument filters which
input events
are delivered to the created execution event nodes.- Parameters:
eventFilter
- filters the events that are reported to the givenlistener
inputFilter
- filters input events,null
for no input valueslistener
- that listens to execution events.- Since:
- 0.33
- See Also:
-
attachExecutionEventFactory
public abstract <T extends ExecutionEventNodeFactory> EventBinding<T> attachExecutionEventFactory(SourceSectionFilter eventFilter, SourceSectionFilter inputFilter, T factory) Starts execution event notification for a givenevent filter
andfactory
. Events are delivered to theExecutionEventNode
instances created by the factory.Returns a
binding
which allows to dispose the attached execution event binding. Disposing the binding removes all probes and wrappers from the AST that were created for this instrument. The removal of probes and wrappers is performed lazily on the next execution of the AST.The input filter argument filters which
input events
are delivered to the created execution event nodes.- Parameters:
eventFilter
- filters the events that are reported to theexecution event nodes
created by the factory.inputFilter
- filters input events,null
for no input valuesfactory
- the factory that createsexecution event nodes
.- Since:
- 0.33
- See Also:
-
attachExecutionEventFactory
public abstract <T extends ExecutionEventNodeFactory> EventBinding<T> attachExecutionEventFactory(NearestSectionFilter nearestFilter, SourceSectionFilter baseFilter, T factory) Starts execution event notification for the nearestSourceSection
as specified by theNearestSectionFilter
. Events are delivered to theExecutionEventNode
instances created by thefactory
.Returns a
binding
which allows to dispose the attached execution event binding. Disposing the binding removes all probes and wrappers from the AST that were created for this instrument. The removal of probes and wrappers is performed lazily on the next execution of the AST.The final nearest node is selected from the sections filtered by the
baseFilter
by applyingInstrumentableNode.findNearestNodeAt(int, int, Set)
.- Parameters:
nearestFilter
- a filter describing the nearest sectionbaseFilter
- a filter selecting sections we find the nearest fromfactory
- the factory that createsexecution event nodes
.- Returns:
- a handle to dispose the execution event binding.
- Since:
- 23.0
- See Also:
-
attachLoadSourceListener
@Deprecated(since="19.0") public abstract <T extends LoadSourceListener> EventBinding<T> attachLoadSourceListener(SourceSectionFilter filter, T listener, boolean includeExistingSources) Starts notifications for each newly loadedSource
and returns a binding that can be used to terminate notifications. Only subsequent loads will be notified unlessincludeExistingSources
is true, in which case a notification for each previous load will be delivered before this method returns.Note: the provided
SourceSectionFilter
must only contain filters onsources
ormime types
.- Parameters:
filter
- a filter on which sources trigger events. Only source filters are allowed.listener
- a listener that gets notified if a source was loadedincludeExistingSources
- whether or not this listener should be notified for sources which were already loaded at the time when this listener was attached.- Returns:
- a handle for stopping the notification stream
- Since:
- 0.15
- See Also:
-
attachLoadSourceListener
public abstract <T extends LoadSourceListener> EventBinding<T> attachLoadSourceListener(SourceFilter filter, T listener, boolean includeExistingSources) Starts notifications for each newly loadedSource
and returns a binding that can be used to terminate notifications. Only subsequent loads will be notified unlessincludeExistingSources
is true, in which case a notification for each previous load will be delivered before this method returns.- Parameters:
filter
- a filter on which sources events are triggered.listener
- a listener that gets notified if a source was loadedincludeExistingSources
- whether or not this listener should be notified for sources which were already loaded at the time when this listener was attached.- Returns:
- a handle for stopping the notification stream
- Since:
- 0.33
- See Also:
-
attachExecuteSourceListener
public abstract <T extends ExecuteSourceListener> EventBinding<T> attachExecuteSourceListener(SourceFilter filter, T listener, boolean includeExecutedSources) Starts notifications for each newly executedSource
and returns a binding that can be used to terminate notifications. Only subsequent executions will be notified unlessincludeExecutedSources
is true, in which case a notification for each previously executed source will be delivered before this method returns. A source is reported as executed if any of it'sRootNode
s start to be executed. Every source is reported at most once.- Parameters:
filter
- a filter on which source events are triggered.listener
- a listener that gets notified if a source was executedincludeExecutedSources
- whether or not this listener should be notified for sources which were already executed at the time when this listener was attached.- Returns:
- a handle for stopping the notification stream
- Since:
- 0.33
- See Also:
-
attachLoadSourceSectionListener
public abstract <T extends LoadSourceSectionListener> EventBinding<T> attachLoadSourceSectionListener(SourceSectionFilter filter, T listener, boolean includeExistingSourceSections) Starts notifications for eachSourceSection
in every newly loadedSource
and returns a binding that can be used to terminate notifications. Only subsequent loads will be notified unlessincludeExistingSourceSections
is true, in which case a notification for each previous load will be delivered before this method returns. Every source is reported at most once.- Parameters:
filter
- a filter on which sources sections trigger eventslistener
- a listener that gets notified if a source section was loadedincludeExistingSourceSections
- whether or not this listener should be notified for sources which were already loaded at the time when this listener was attached.- Returns:
- a handle for stopping the notification stream
- Since:
- 0.15
- See Also:
-
attachLoadSourceSectionListener
public abstract <T extends LoadSourceSectionListener> EventBinding<T> attachLoadSourceSectionListener(NearestSectionFilter nearestFilter, SourceSectionFilter baseFilter, T listener, boolean includeExistingSourceSections) Starts notifications for the nearestSourceSection
as specified by theNearestSectionFilter
and returns a binding that can be used to terminate notifications. The final nearest node is selected from the sections filtered by thebaseFilter
by applyingInstrumentableNode.findNearestNodeAt(int, int, Set)
. Only subsequent loads will be notified unlessincludeExistingSourceSections
is true, in which case a notification for each previously loaded source section will be delivered before this method returns.- Parameters:
nearestFilter
- a filter describing the nearest sectionbaseFilter
- a filter selecting sections we find the nearest fromlistener
- a listener that gets notified if a source section was loadedincludeExistingSourceSections
- whether or not this listener should be notified for source sections which were already loaded at the time when this listener was attached.- Returns:
- a handle for stopping the notification stream
- Since:
- 23.0
- See Also:
-
createLoadSourceBinding
public abstract <T extends LoadSourceListener> EventBinding<T> createLoadSourceBinding(SourceFilter filter, T listener, boolean includeExistingSources) Create a binding to get notifications for each newly loadedSource
. The binding needs to beattached
to receive notifications. Only subsequent loads will be notified afterattach
, unlessincludeExistingSources
is true, in which case a notification for each previously loaded source will be delivered before attach method returns.The difference from
attachLoadSourceListener(SourceFilter, LoadSourceListener, boolean)
is in having the binding object before notifications are produced when existing sources are requested.- Parameters:
filter
- a filter on which sources events are triggered.listener
- a listener that gets notified if a source was loadedincludeExistingSources
- whether or not this listener should be notified for sources which were already loaded at the time when this listener was attached.- Returns:
- a binding handle to
attach
andstop
the notification stream - Since:
- 21.1
- See Also:
-
createExecuteSourceBinding
public abstract <T extends ExecuteSourceListener> EventBinding<T> createExecuteSourceBinding(SourceFilter filter, T listener, boolean includeExecutedSources) Create a binding to get notifications for each newly executedSource
. The binding needs to beattached
to receive notifications. Only subsequent executions will be notified afterattach
, unlessincludeExecutedSources
is true, in which case a notification for each previously executed source will be delivered before attach method returns. Every source is reported at most once.The difference from
attachExecuteSourceListener(SourceFilter, ExecuteSourceListener, boolean)
is in having the binding object before notifications are produced when executed sources are requested.- Parameters:
filter
- a filter on which sources events are triggered.listener
- a listener that gets notified if a source was executedincludeExecutedSources
- whether or not this listener should be notified for sources which were already executed at the time when this listener was attached.- Returns:
- a binding handle to
attach
andstop
the notification stream - Since:
- 21.1
- See Also:
-
createLoadSourceSectionBinding
public abstract <T extends LoadSourceSectionListener> EventBinding<T> createLoadSourceSectionBinding(SourceSectionFilter filter, T listener, boolean includeExistingSourceSections) Create a binding to get notifications for each newly loadedSourceSection
in every newly loadedSource
. The binding needs to beattached
to receive notifications. Only subsequent loads will be notified afterattach
, unlessincludeExistingSourceSections
is true, in which case a notification for each previously loaded source section will be delivered before attach method returns. Every source is reported at most once.The difference from
attachLoadSourceSectionListener(SourceSectionFilter, LoadSourceSectionListener, boolean)
is in having the binding object before notifications are produced when existing source sections are requested.- Parameters:
filter
- a filter on which sources events are triggered.listener
- a listener that gets notified if a source section was loadedincludeExistingSourceSections
- whether or not this listener should be notified for source sections which were already loaded at the time when this listener was attached.- Returns:
- a binding handle to
attach
andstop
the notification stream - Since:
- 21.1
- See Also:
-
createLoadSourceSectionBinding
public abstract <T extends LoadSourceSectionListener> EventBinding<T> createLoadSourceSectionBinding(NearestSectionFilter nearestFilter, SourceSectionFilter baseFilter, T listener, boolean includeExistingSourceSections) Create a binding to get notification for the nearest source section to the given position as specified by theNearestSectionFilter
. The final nearest node is selected from the sections filtered by thebaseFilter
by applyingInstrumentableNode.findNearestNodeAt(int, int, Set)
. The binding needs to beattached
to receive notifications. Only subsequent loads will be notified afterattach
, unlessincludeExistingSourceSections
is true, in which case a notification for each previously loaded source section will be delivered before attach method returns.The difference from
attachLoadSourceSectionListener(NearestSectionFilter, SourceSectionFilter, LoadSourceSectionListener, boolean)
is in having the binding object before notifications are produced when existing source sections are requested.- Parameters:
nearestFilter
- a filter describing the nearest sectionbaseFilter
- a filter selecting sections we find the nearest fromlistener
- a listener that gets notified if a source section was loadedincludeExistingSourceSections
- whether or not this listener should be notified for source sections which were already loaded at the time when this listener was attached.- Returns:
- a binding handle to
attach
andstop
the notification stream - Since:
- 23.0
- See Also:
-
visitLoadedSourceSections
public abstract void visitLoadedSourceSections(SourceSectionFilter filter, LoadSourceSectionListener listener) Notifies the listener for eachSourceSection
in every loadedSource
that corresponds to the filter. Only loaded sections are notified, synchronously.- Parameters:
filter
- a filter on which source sections trigger eventslistener
- a listener that gets notified with loaded source sections- Since:
- 19.0
- See Also:
-
attachOutConsumer
Attach an output stream as a consumer of thestandard output
. The consumer output stream receives all output that goes toTruffleInstrument.Env.out()
since this call, including output emitted by theEngine
this instrumenter is being executed in, output from instruments (including this one), etc. Be sure todispose
the binding when it's not used any more.- Since:
- 0.25
-
attachErrConsumer
Attach an output stream as a consumer of theerror output
. The consumer output stream receives all error output that goes toTruffleInstrument.Env.err()
since this call, including error output emitted by theEngine
this instrumenter is being executed in, error output from instruments (including this one), etc. Be sure todispose
the binding when it's not used any more.- Since:
- 0.25
-
attachAllocationListener
public abstract <T extends AllocationListener> EventBinding<T> attachAllocationListener(AllocationEventFilter filter, T listener) Attach alistener
to be notified about allocations of guest language values. Be sure todispose
the binding when it's not used any more.- Since:
- 0.27
-
attachContextsListener
public abstract <T extends ContextsListener> EventBinding<T> attachContextsListener(T listener, boolean includeActiveContexts) Attach alistener
to be notified about changes in contexts in guest language application. This is supported inTruffleInstrument.Env.getInstrumenter()
only.- Parameters:
listener
- a listener to receive the context eventsincludeActiveContexts
- whether or not this listener should be notified for present active contexts- Returns:
- a handle for unregistering the listener
- Since:
- 0.30
-
attachThreadsListener
public abstract <T extends ThreadsListener> EventBinding<T> attachThreadsListener(T listener, boolean includeInitializedThreads) Attach alistener
to be notified about changes in threads in guest language application. This is supported inTruffleInstrument.Env.getInstrumenter()
only.- Parameters:
listener
- a listener to receive the context eventsincludeInitializedThreads
- whether or not this listener should be notified for present initialized threads- Returns:
- a handle for unregistering the listener
- Since:
- 0.30
-
attachThreadsActivationListener
public abstract EventBinding<? extends ThreadsActivationListener> attachThreadsActivationListener(ThreadsActivationListener listener) Attach alistener
to be notified about when a thread gets entered or left in guest language applications.The event notification starts after the listener registration is completed. This means that currently activated threads won't get a notification. It is also possible that
ThreadsActivationListener.onLeaveThread(TruffleContext)
is called without ever invokingThreadsActivationListener.onEnterThread(TruffleContext)
.- Returns:
- a handle for unregistering the listener.
- Since:
- 20.3
-
querySourceSections
Returns a filtered list of loadedSourceSection
instances.- Parameters:
filter
- criterion for inclusion- Returns:
- unmodifiable list of instances that pass the filter
- Since:
- 0.18
-
queryTags
Returns an unmodifiableSet
of tag classes which where associated with this node. If the instrumenter is used as aTruffleLanguage
then only nodes can be queried for tags that are associated with the current language otherwise anIllegalArgumentException
is thrown. The given node must not benull
. If the given node is not instrumentable, the given node is not yet adopted by aRootNode
or the given tag was notprovided
by the language then always an emptySet
is returned.- Parameters:
node
- the node to query- Returns:
- an unmodifiable
Set
of tag classes which where associated with this node. - Since:
- 0.12
-
lookupExecutionEventNode
Returns the execution event node that was inserted at the node's location given an event binding, if any. This is useful to identify and find information from nodes that were created for a specific instrumentation.- Parameters:
node
- an instrumentable node specifying the locationbinding
- the binding to lookup the execution nodes of- Returns:
- the
ExecutionEventNode
, ornull
. - Since:
- 19.0
-
attachExecutionEventFactory(SourceSectionFilter, SourceSectionFilter, ExecutionEventNodeFactory)
or useattachExecutionEventListener(SourceSectionFilter, ExecutionEventListener)
instead.