Mercurial > hg > graal-jvmci-8
comparison graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/impl/ProbeManager.java @ 16873:3ad18f453679
Truffle/Instrumentation: Javadoc
author | Michael Van De Vanter <michael.van.de.vanter@oracle.com> |
---|---|
date | Wed, 20 Aug 2014 15:14:30 -0700 |
parents | 1051d6e4b61b |
children | c88ab4f1f04a |
comparison
equal
deleted
inserted
replaced
16872:ce8ac92efb14 | 16873:3ad18f453679 |
---|---|
41 private final List<ProbeImpl> allProbes = new ArrayList<>(); | 41 private final List<ProbeImpl> allProbes = new ArrayList<>(); |
42 | 42 |
43 /** | 43 /** |
44 * Called when a {@link #tagTrap} is activated in a Probe. | 44 * Called when a {@link #tagTrap} is activated in a Probe. |
45 */ | 45 */ |
46 /** | |
47 * The callback to be triggered by the {@link #tagTrap}. | |
48 * | |
49 */ | |
50 private final ProbeCallback probeCallback; | 46 private final ProbeCallback probeCallback; |
51 | 47 |
52 /** | 48 /** |
53 * When non-null, "enter" events with matching tags will trigger a callback. | 49 * When non-null, "enter" events with matching tags will trigger a callback. |
54 */ | 50 */ |
70 } | 66 } |
71 }; | 67 }; |
72 } | 68 } |
73 | 69 |
74 /** | 70 /** |
75 * Add a {@link ProbeListener} to receive events. | 71 * Adds a {@link ProbeListener} to receive events. |
76 * | |
77 * @param listener The listener to be added. | |
78 */ | 72 */ |
79 public void addProbeListener(ProbeListener listener) { | 73 public void addProbeListener(ProbeListener listener) { |
80 assert listener != null; | 74 assert listener != null; |
81 probeListeners.add(listener); | 75 probeListeners.add(listener); |
82 } | 76 } |
83 | 77 |
84 /** | 78 /** |
85 * Remove a {@link ProbeListener}. If no matching probe listener is found, nothing happens. | 79 * Removes a {@link ProbeListener}. Ignored if listener not found. |
86 * | |
87 * @param removeListener | |
88 */ | 80 */ |
89 public void removeProbeListener(ProbeListener removeListener) { | 81 public void removeProbeListener(ProbeListener removeListener) { |
90 final List<ProbeListener> listeners = new ArrayList<>(probeListeners); | 82 final List<ProbeListener> listeners = new ArrayList<>(probeListeners); |
91 for (ProbeListener listener : listeners) { | 83 for (ProbeListener listener : listeners) { |
92 if (listener == removeListener) { | 84 if (listener == removeListener) { |
95 } | 87 } |
96 } | 88 } |
97 | 89 |
98 /** | 90 /** |
99 * Creates a new {@link Probe} associated with a {@link SourceSection} of code corresponding to | 91 * Creates a new {@link Probe} associated with a {@link SourceSection} of code corresponding to |
100 * a Trufle AST node. | 92 * a Truffle AST node. |
101 * | |
102 * @param source The source section to associate with this probe. | |
103 * @return The probe that was created. | |
104 */ | 93 */ |
105 public Probe createProbe(SourceSection source) { | 94 public Probe createProbe(SourceSection source) { |
106 assert source != null; | 95 assert source != null; |
107 | 96 |
108 ProbeImpl probe = InstrumentationNode.createProbe(source, probeCallback); | 97 ProbeImpl probe = InstrumentationNode.createProbe(source, probeCallback); |
117 | 106 |
118 /** | 107 /** |
119 * Returns the subset of all {@link Probe}s holding a particular {@link SyntaxTag}, or the whole | 108 * Returns the subset of all {@link Probe}s holding a particular {@link SyntaxTag}, or the whole |
120 * collection if the specified tag is {@code null}. | 109 * collection if the specified tag is {@code null}. |
121 * | 110 * |
122 * @return An iterable collection of probes containing the given tag. | 111 * @return A collection of probes containing the given tag. |
123 */ | 112 */ |
124 public Collection<Probe> findProbesTaggedAs(SyntaxTag tag) { | 113 public Collection<Probe> findProbesTaggedAs(SyntaxTag tag) { |
125 final List<Probe> probes = new ArrayList<>(); | 114 final List<Probe> probes = new ArrayList<>(); |
126 for (Probe probe : allProbes) { | 115 for (Probe probe : allProbes) { |
127 if (tag == null || probe.isTaggedAs(tag)) { | 116 if (tag == null || probe.isTaggedAs(tag)) { |
130 } | 119 } |
131 return probes; | 120 return probes; |
132 } | 121 } |
133 | 122 |
134 /** | 123 /** |
135 * Calls {@link ProbeImpl#setTrap(SyntaxTagTrap)} for all probes with the given | 124 * Sets the current "tag trap", which will cause a callback to be triggered whenever execution |
136 * {@link SyntaxTag} . There can only be one tag trap set at a time. | 125 * reaches a Probe (existing or subsequently created) with the specified tag. There can only be |
126 * one tag trap set at a time. | |
127 * <p> | |
137 * | 128 * |
138 * @param tagTrap The {@link SyntaxTagTrap} to set. | 129 * @param tagTrap The {@link SyntaxTagTrap} to set. |
139 * @throws IllegalStateException if a trap is currently set. | 130 * @throws IllegalStateException if a trap is currently set. |
140 */ | 131 */ |
141 public void setTagTrap(SyntaxTagTrap tagTrap) throws IllegalStateException { | 132 public void setTagTrap(SyntaxTagTrap tagTrap) throws IllegalStateException { |