Mercurial > hg > graal-jvmci-8
annotate graal/com.oracle.truffle.tools/src/com/oracle/truffle/tools/LineToProbesMap.java @ 21870:12dcf5ba8b34
Merge with jdk8u45-b14
author | Gilles Duboscq <gilles.m.duboscq@oracle.com> |
---|---|
date | Tue, 09 Jun 2015 11:54:04 +0200 |
parents | 3b8bbf51d320 |
children |
rev | line source |
---|---|
18987
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
1 /* |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
4 * |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. Oracle designates this |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
8 * particular file as subject to the "Classpath" exception as provided |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
9 * by Oracle in the LICENSE file that accompanied this code. |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
10 * |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
11 * This code is distributed in the hope that it will be useful, but WITHOUT |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
14 * version 2 for more details (a copy is included in the LICENSE file that |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
15 * accompanied this code). |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
16 * |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
17 * You should have received a copy of the GNU General Public License version |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
18 * 2 along with this work; if not, write to the Free Software Foundation, |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
20 * |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
22 * or visit www.oracle.com if you need additional information or have any |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
23 * questions. |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
24 */ |
21568
3b8bbf51d320
Truffle/Debugging: add the Truffle DebugEngine and supporting code, as well as add a crude command-line debugging tool used mainly to test the DebugEngine. Migrate the small tols out of project com.oracle.truffle.api into the new project com.oracle.truffle.tools.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19650
diff
changeset
|
25 package com.oracle.truffle.tools; |
18987
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
26 |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
27 import java.io.*; |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
28 import java.util.*; |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
29 |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
30 import com.oracle.truffle.api.instrument.*; |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
31 import com.oracle.truffle.api.instrument.impl.*; |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
32 import com.oracle.truffle.api.source.*; |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
33 |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
34 /** |
19650
ac35617db239
Truffle/Instrumentation: Javadoc fix
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19187
diff
changeset
|
35 * An {@link InstrumentationTool} that builds a map of every {@link Probe} attached to some AST, |
19187
c5b20395a8bf
Truffle/Instrumentation: eclipseformat
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19186
diff
changeset
|
36 * indexed by {@link Source} and line number. |
18987
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
37 */ |
19186
3d2296dbace9
Truffle/Instrumentation: TruffleTool renamed to InstrumentationTool (the base class for a group of tools that collect information during program execution)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
18987
diff
changeset
|
38 public final class LineToProbesMap extends InstrumentationTool { |
18987
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
39 |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
40 private static final boolean TRACE = false; |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
41 private static final PrintStream OUT = System.out; |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
42 |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
43 private static void trace(String msg) { |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
44 OUT.println("LineToProbesMap: " + msg); |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
45 } |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
46 |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
47 /** |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
48 * Map: Source line ==> probes associated with source sections starting on the line. |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
49 */ |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
50 private final Map<LineLocation, Collection<Probe>> lineToProbesMap = new HashMap<>(); |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
51 |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
52 private final ProbeListener probeListener; |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
53 |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
54 /** |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
55 * Create a map of {@link Probe}s that collects information on all probes added to subsequently |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
56 * created ASTs (once installed). |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
57 */ |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
58 public LineToProbesMap() { |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
59 this.probeListener = new LineToProbesListener(); |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
60 } |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
61 |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
62 @Override |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
63 protected boolean internalInstall() { |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
64 Probe.addProbeListener(probeListener); |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
65 return true; |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
66 } |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
67 |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
68 @Override |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
69 protected void internalReset() { |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
70 lineToProbesMap.clear(); |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
71 } |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
72 |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
73 @Override |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
74 protected void internalDispose() { |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
75 Probe.removeProbeListener(probeListener); |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
76 } |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
77 |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
78 /** |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
79 * Returns the {@link Probe}, if any, associated with a specific line of guest language code; if |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
80 * more than one, return the one with the first starting character location. |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
81 */ |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
82 public Probe findFirstProbe(LineLocation lineLocation) { |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
83 Probe probe = null; |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
84 final Collection<Probe> probes = findProbes(lineLocation); |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
85 for (Probe probesOnLine : probes) { |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
86 if (probe == null) { |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
87 probe = probesOnLine; |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
88 } else if (probesOnLine.getProbedSourceSection().getCharIndex() < probe.getProbedSourceSection().getCharIndex()) { |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
89 probe = probesOnLine; |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
90 } |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
91 } |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
92 return probe; |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
93 } |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
94 |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
95 /** |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
96 * Returns all {@link Probe}s whose associated source begins at the given {@link LineLocation}, |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
97 * an empty list if none. |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
98 */ |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
99 public Collection<Probe> findProbes(LineLocation line) { |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
100 final Collection<Probe> probes = lineToProbesMap.get(line); |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
101 if (probes == null) { |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
102 return Collections.emptyList(); |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
103 } |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
104 return Collections.unmodifiableCollection(probes); |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
105 } |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
106 |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
107 private class LineToProbesListener extends DefaultProbeListener { |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
108 |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
109 @Override |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
110 public void newProbeInserted(Probe probe) { |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
111 final SourceSection sourceSection = probe.getProbedSourceSection(); |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
112 if (sourceSection != null && !(sourceSection instanceof NullSourceSection)) { |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
113 final LineLocation lineLocation = sourceSection.getLineLocation(); |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
114 if (TRACE) { |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
115 trace("ADD " + lineLocation.getShortDescription() + " ==> " + probe.getShortDescription()); |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
116 } |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
117 Collection<Probe> probes = lineToProbesMap.get(lineLocation); |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
118 if (probes == null) { |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
119 probes = new ArrayList<>(2); |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
120 lineToProbesMap.put(lineLocation, probes); |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
121 } else { |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
122 assert !probes.contains(probe); |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
123 } |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
124 probes.add(probe); |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
125 } |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
126 } |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
127 } |
ac114ad31cdd
Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
128 } |