annotate graal/com.oracle.truffle.tools/src/com/oracle/truffle/tools/CoverageTracker.java @ 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.
author Michael Van De Vanter <michael.van.de.vanter@oracle.com>
date Tue, 26 May 2015 16:38:13 -0700
parents graal/com.oracle.truffle.api/src/com/oracle/truffle/api/tools/CoverageTracker.java@06b0a2fb20a1
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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) 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: 20907
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 import java.util.Map.Entry;
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
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.*;
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.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
33 import com.oracle.truffle.api.nodes.*;
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 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
35
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
36 /**
19187
c5b20395a8bf Truffle/Instrumentation: eclipseformat
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19186
diff changeset
37 * An {@link InstrumentationTool} that counts interpreter <em>execution calls</em> to AST nodes that
20907
06b0a2fb20a1 Truffle/Tools: the coverage tool will now ignore counts for any sources holding the tag CoverageTracker.Tags.NO_COVERAGE.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
38 * hold a specified {@linkplain SyntaxTag syntax tag}, tabulated by source and line number
06b0a2fb20a1 Truffle/Tools: the coverage tool will now ignore counts for any sources holding the tag CoverageTracker.Tags.NO_COVERAGE.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
39 * associated with each node. Syntax tags are presumed to be applied external to the tool. If no tag
06b0a2fb20a1 Truffle/Tools: the coverage tool will now ignore counts for any sources holding the tag CoverageTracker.Tags.NO_COVERAGE.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
40 * is specified, {@linkplain StandardSyntaxTag#STATEMENT STATEMENT} is used, corresponding to
06b0a2fb20a1 Truffle/Tools: the coverage tool will now ignore counts for any sources holding the tag CoverageTracker.Tags.NO_COVERAGE.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
41 * conventional behavior for code coverage tools.
06b0a2fb20a1 Truffle/Tools: the coverage tool will now ignore counts for any sources holding the tag CoverageTracker.Tags.NO_COVERAGE.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
42 * <p>
06b0a2fb20a1 Truffle/Tools: the coverage tool will now ignore counts for any sources holding the tag CoverageTracker.Tags.NO_COVERAGE.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
43 * No counts will be kept for execution in sources that hold the {@link SourceTag}
06b0a2fb20a1 Truffle/Tools: the coverage tool will now ignore counts for any sources holding the tag CoverageTracker.Tags.NO_COVERAGE.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
44 * {@link Tags#NO_COVERAGE}.
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
45 * <p>
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 * <b>Tool Life Cycle</b>
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 * <p>
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
48 * See {@link InstrumentationTool} for the life cycle common to all such 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
49 * <p>
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 * <b>Execution Counts</b>
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 * <p>
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 * <ul>
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 * <li>"Execution call" on a node is is defined as invocation of a node method that is instrumented
20889
73b1844b5b14 Truffle/Instrumentation: rename InstrumentListener to SimpleInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
54 * to produce the event {@link SimpleInstrumentListener#enter(Probe)};</li>
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
55 * <li>Execution calls are tabulated only at <em>instrumented</em> nodes, i.e. those for which
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 * {@linkplain Node#isInstrumentable() isInstrumentable() == true};</li>
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 * <li>Execution calls are tabulated only at nodes present in the AST when originally created;
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 * dynamically added nodes will not be instrumented.</li>
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 * </ul>
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 * </p>
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 * <b>Results</b>
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 * <p>
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 * A modification-safe copy of the {@linkplain #getCounts() counts} can be retrieved at any time,
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 * without effect on the state of the tool.
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 * </p>
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 * <p>
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 * A "default" {@linkplain #print(PrintStream) print()} method can summarizes the current counts at
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 * any time in a simple textual format, with no other effect on the state of the tool.
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 * </p>
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 *
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 * @see 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
72 * @see SyntaxTag
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 */
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
74 public final class CoverageTracker 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
75
20907
06b0a2fb20a1 Truffle/Tools: the coverage tool will now ignore counts for any sources holding the tag CoverageTracker.Tags.NO_COVERAGE.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
76 public enum Tags implements SourceTag {
06b0a2fb20a1 Truffle/Tools: the coverage tool will now ignore counts for any sources holding the tag CoverageTracker.Tags.NO_COVERAGE.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
77
06b0a2fb20a1 Truffle/Tools: the coverage tool will now ignore counts for any sources holding the tag CoverageTracker.Tags.NO_COVERAGE.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
78 /**
06b0a2fb20a1 Truffle/Tools: the coverage tool will now ignore counts for any sources holding the tag CoverageTracker.Tags.NO_COVERAGE.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
79 * Report no counts for sources holding this tag.
06b0a2fb20a1 Truffle/Tools: the coverage tool will now ignore counts for any sources holding the tag CoverageTracker.Tags.NO_COVERAGE.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
80 */
06b0a2fb20a1 Truffle/Tools: the coverage tool will now ignore counts for any sources holding the tag CoverageTracker.Tags.NO_COVERAGE.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
81 NO_COVERAGE("No Coverage", "Coverage Tracker will igore");
06b0a2fb20a1 Truffle/Tools: the coverage tool will now ignore counts for any sources holding the tag CoverageTracker.Tags.NO_COVERAGE.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
82
06b0a2fb20a1 Truffle/Tools: the coverage tool will now ignore counts for any sources holding the tag CoverageTracker.Tags.NO_COVERAGE.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
83 private final String name;
06b0a2fb20a1 Truffle/Tools: the coverage tool will now ignore counts for any sources holding the tag CoverageTracker.Tags.NO_COVERAGE.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
84 private final String description;
06b0a2fb20a1 Truffle/Tools: the coverage tool will now ignore counts for any sources holding the tag CoverageTracker.Tags.NO_COVERAGE.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
85
06b0a2fb20a1 Truffle/Tools: the coverage tool will now ignore counts for any sources holding the tag CoverageTracker.Tags.NO_COVERAGE.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
86 private Tags(String name, String description) {
06b0a2fb20a1 Truffle/Tools: the coverage tool will now ignore counts for any sources holding the tag CoverageTracker.Tags.NO_COVERAGE.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
87 this.name = name;
06b0a2fb20a1 Truffle/Tools: the coverage tool will now ignore counts for any sources holding the tag CoverageTracker.Tags.NO_COVERAGE.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
88 this.description = description;
06b0a2fb20a1 Truffle/Tools: the coverage tool will now ignore counts for any sources holding the tag CoverageTracker.Tags.NO_COVERAGE.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
89 }
06b0a2fb20a1 Truffle/Tools: the coverage tool will now ignore counts for any sources holding the tag CoverageTracker.Tags.NO_COVERAGE.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
90
06b0a2fb20a1 Truffle/Tools: the coverage tool will now ignore counts for any sources holding the tag CoverageTracker.Tags.NO_COVERAGE.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
91 public String getName() {
06b0a2fb20a1 Truffle/Tools: the coverage tool will now ignore counts for any sources holding the tag CoverageTracker.Tags.NO_COVERAGE.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
92 return name;
06b0a2fb20a1 Truffle/Tools: the coverage tool will now ignore counts for any sources holding the tag CoverageTracker.Tags.NO_COVERAGE.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
93 }
06b0a2fb20a1 Truffle/Tools: the coverage tool will now ignore counts for any sources holding the tag CoverageTracker.Tags.NO_COVERAGE.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
94
06b0a2fb20a1 Truffle/Tools: the coverage tool will now ignore counts for any sources holding the tag CoverageTracker.Tags.NO_COVERAGE.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
95 public String getDescription() {
06b0a2fb20a1 Truffle/Tools: the coverage tool will now ignore counts for any sources holding the tag CoverageTracker.Tags.NO_COVERAGE.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
96 return description;
06b0a2fb20a1 Truffle/Tools: the coverage tool will now ignore counts for any sources holding the tag CoverageTracker.Tags.NO_COVERAGE.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
97 }
06b0a2fb20a1 Truffle/Tools: the coverage tool will now ignore counts for any sources holding the tag CoverageTracker.Tags.NO_COVERAGE.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
98 }
06b0a2fb20a1 Truffle/Tools: the coverage tool will now ignore counts for any sources holding the tag CoverageTracker.Tags.NO_COVERAGE.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
99
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
100 /** Counting data. */
19248
a2ff253c458f Truffle/Instrumentation: code cleanups in tools CoverageTracker and NodeExecCounter, especially for tutorial value
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19187
diff changeset
101 private final Map<LineLocation, CoverageRecord> coverageMap = new HashMap<>();
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
102
19248
a2ff253c458f Truffle/Instrumentation: code cleanups in tools CoverageTracker and NodeExecCounter, especially for tutorial value
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19187
diff changeset
103 /** Needed for disposal. */
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
104 private final List<Instrument> instruments = new ArrayList<>();
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 /**
19248
a2ff253c458f Truffle/Instrumentation: code cleanups in tools CoverageTracker and NodeExecCounter, especially for tutorial value
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19187
diff changeset
107 * Coverage counting is restricted to nodes holding this tag.
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
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 private final SyntaxTag countingTag;
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
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 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
112
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 /**
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 * Create a per-line coverage tool for nodes tagged as {@linkplain StandardSyntaxTag#STATEMENT
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 * statements} in subsequently created ASTs.
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 public CoverageTracker() {
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 this(StandardSyntaxTag.STATEMENT);
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 }
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
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 /**
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 * Create a per-line coverage tool for nodes tagged as specified, presuming that tags applied
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 * outside this tool.
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 */
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 public CoverageTracker(SyntaxTag tag) {
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 this.probeListener = new CoverageProbeListener();
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 this.countingTag = tag;
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 }
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
129
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
130 @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
131 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
132 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
133 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
134 }
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
135
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
136 @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
137 protected void internalReset() {
19248
a2ff253c458f Truffle/Instrumentation: code cleanups in tools CoverageTracker and NodeExecCounter, especially for tutorial value
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19187
diff changeset
138 coverageMap.clear();
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
139 }
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
140
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
141 @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
142 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
143 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
144 for (Instrument instrument : instruments) {
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
145 instrument.dispose();
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
146 }
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
147 }
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
148
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
149 /**
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
150 * Gets a modification-safe summary of the current per-type node execution counts; does not
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
151 * affect the counts.
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
152 * <p>
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
153 * The map holds an array for each source, and elements of the a array corresponding to the
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
154 * textual lines of that source. An array entry contains null if the corresponding line of
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
155 * source is associated with no nodes of the relevant type, i.e. where no count was made. A
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
156 * numeric entry represents the execution count at the corresponding line of 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
157 * <p>
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
158 * <b>Note:</b> source line numbers are 1-based, so array index {@code i} corresponds to 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
159 * line number {@code i + 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
160 */
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
161 public Map<Source, Long[]> getCounts() {
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
162
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
163 /**
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
164 * Counters for every {Source, line number} for which a counter was installed, i.e. for
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
165 * every line associated with an appropriately tagged AST node; iterable in order of 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
166 * name, then line number.
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
167 */
19248
a2ff253c458f Truffle/Instrumentation: code cleanups in tools CoverageTracker and NodeExecCounter, especially for tutorial value
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19187
diff changeset
168 final TreeSet<Entry<LineLocation, CoverageRecord>> entries = new TreeSet<>(new LineLocationEntryComparator());
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
169
19248
a2ff253c458f Truffle/Instrumentation: code cleanups in tools CoverageTracker and NodeExecCounter, especially for tutorial value
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19187
diff changeset
170 for (Entry<LineLocation, CoverageRecord> entry : coverageMap.entrySet()) {
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
171 entries.add(entry);
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
172 }
19248
a2ff253c458f Truffle/Instrumentation: code cleanups in tools CoverageTracker and NodeExecCounter, especially for tutorial value
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19187
diff changeset
173 final Map<Source, Long[]> result = new HashMap<>();
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
174 Source curSource = 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
175 Long[] curLineTable = null;
19248
a2ff253c458f Truffle/Instrumentation: code cleanups in tools CoverageTracker and NodeExecCounter, especially for tutorial value
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19187
diff changeset
176 for (Entry<LineLocation, CoverageRecord> entry : entries) {
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
177 final LineLocation key = entry.getKey();
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
178 final Source source = key.getSource();
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
179 final int lineNo = key.getLineNumber();
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
180 if (source != curSource) {
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
181 if (curSource != null) {
19248
a2ff253c458f Truffle/Instrumentation: code cleanups in tools CoverageTracker and NodeExecCounter, especially for tutorial value
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19187
diff changeset
182 result.put(curSource, curLineTable);
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
183 }
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
184 curSource = 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
185 curLineTable = new Long[source.getLineCount()];
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
186 }
19593
6d895b028a44 Truffle/InstrumentationTools: clean up some misleading code and commentary in CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
187 curLineTable[lineNo - 1] = entry.getValue().count;
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
188 }
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
189 if (curSource != null) {
19248
a2ff253c458f Truffle/Instrumentation: code cleanups in tools CoverageTracker and NodeExecCounter, especially for tutorial value
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19187
diff changeset
190 result.put(curSource, curLineTable);
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
191 }
19248
a2ff253c458f Truffle/Instrumentation: code cleanups in tools CoverageTracker and NodeExecCounter, especially for tutorial value
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19187
diff changeset
192 return result;
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
193 }
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
194
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
195 /**
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
196 * A default printer for the current line counts, producing lines of the form " (<count>) <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
197 * number> : <text of line>", grouped by 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
198 */
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
199 public void print(PrintStream 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
200 out.println();
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
201 out.println(countingTag.name() + " coverage:");
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
202
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
203 /**
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
204 * Counters for every {Source, line number} for which a counter was installed, i.e. for
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
205 * every line associated with an appropriately tagged AST node; iterable in order of 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
206 * name, then line number.
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
207 */
19248
a2ff253c458f Truffle/Instrumentation: code cleanups in tools CoverageTracker and NodeExecCounter, especially for tutorial value
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19187
diff changeset
208 final TreeSet<Entry<LineLocation, CoverageRecord>> entries = new TreeSet<>(new LineLocationEntryComparator());
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
209
19248
a2ff253c458f Truffle/Instrumentation: code cleanups in tools CoverageTracker and NodeExecCounter, especially for tutorial value
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19187
diff changeset
210 for (Entry<LineLocation, CoverageRecord> entry : coverageMap.entrySet()) {
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
211 entries.add(entry);
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
212 }
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
213 Source curSource = 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
214 int curLineNo = 1;
19248
a2ff253c458f Truffle/Instrumentation: code cleanups in tools CoverageTracker and NodeExecCounter, especially for tutorial value
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19187
diff changeset
215 for (Entry<LineLocation, CoverageRecord> entry : entries) {
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
216 final LineLocation key = entry.getKey();
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
217 final Source source = key.getSource();
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
218 final int lineNo = key.getLineNumber();
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
219 if (source != curSource) {
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
220 if (curSource != 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
221 while (curLineNo <= curSource.getLineCount()) {
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
222 displayLine(out, null, curSource, curLineNo++);
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
223 }
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
224 }
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
225 curSource = 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
226 curLineNo = 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
227 out.println();
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
228 out.println(source.getPath());
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
229 }
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
230 while (curLineNo < lineNo) {
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
231 displayLine(out, null, curSource, curLineNo++);
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
232 }
19593
6d895b028a44 Truffle/InstrumentationTools: clean up some misleading code and commentary in CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
233 displayLine(out, entry.getValue(), curSource, curLineNo++);
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
234 }
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
235 if (curSource != 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
236 while (curLineNo <= curSource.getLineCount()) {
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
237 displayLine(out, null, curSource, curLineNo++);
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
238 }
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
239 }
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
240 }
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
241
19593
6d895b028a44 Truffle/InstrumentationTools: clean up some misleading code and commentary in CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
242 private static void displayLine(PrintStream out, CoverageRecord record, Source source, int lineNo) {
6d895b028a44 Truffle/InstrumentationTools: clean up some misleading code and commentary in CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
243 if (record == null) {
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
244 out.format("%14s", " ");
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
245 } else {
19593
6d895b028a44 Truffle/InstrumentationTools: clean up some misleading code and commentary in CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
246 out.format("(%12d)", record.count);
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
247 }
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
248 out.format(" %3d: ", lineNo);
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
249 out.println(source.getCode(lineNo));
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
250 }
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
251
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
252 /**
19248
a2ff253c458f Truffle/Instrumentation: code cleanups in tools CoverageTracker and NodeExecCounter, especially for tutorial value
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19187
diff changeset
253 * A listener for events at each instrumented AST location. This listener counts
19593
6d895b028a44 Truffle/InstrumentationTools: clean up some misleading code and commentary in CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
254 * "execution calls" to the instrumented node.
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
255 */
20889
73b1844b5b14 Truffle/Instrumentation: rename InstrumentListener to SimpleInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
256 private final class CoverageRecord extends DefaultSimpleInstrumentListener {
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
257
19593
6d895b028a44 Truffle/InstrumentationTools: clean up some misleading code and commentary in CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
258 private final SourceSection srcSection; // The text of the code being counted
6d895b028a44 Truffle/InstrumentationTools: clean up some misleading code and commentary in CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
259 private Instrument instrument; // The attached Instrument, in case need to remove.
6d895b028a44 Truffle/InstrumentationTools: clean up some misleading code and commentary in CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
260 private long count = 0;
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
261
19593
6d895b028a44 Truffle/InstrumentationTools: clean up some misleading code and commentary in CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
262 CoverageRecord(SourceSection srcSection) {
6d895b028a44 Truffle/InstrumentationTools: clean up some misleading code and commentary in CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
263 this.srcSection = srcSection;
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
264 }
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
265
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
266 @Override
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19593
diff changeset
267 public void enter(Probe probe) {
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
268 if (isEnabled()) {
19593
6d895b028a44 Truffle/InstrumentationTools: clean up some misleading code and commentary in CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
269 count++;
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
270 }
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
271 }
19593
6d895b028a44 Truffle/InstrumentationTools: clean up some misleading code and commentary in CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
272
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
273 }
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
274
19248
a2ff253c458f Truffle/Instrumentation: code cleanups in tools CoverageTracker and NodeExecCounter, especially for tutorial value
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19187
diff changeset
275 private static final class LineLocationEntryComparator implements Comparator<Entry<LineLocation, CoverageRecord>> {
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
276
19248
a2ff253c458f Truffle/Instrumentation: code cleanups in tools CoverageTracker and NodeExecCounter, especially for tutorial value
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19187
diff changeset
277 public int compare(Entry<LineLocation, CoverageRecord> e1, Entry<LineLocation, CoverageRecord> e2) {
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
278 return LineLocation.COMPARATOR.compare(e1.getKey(), e2.getKey());
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
279 }
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
280 }
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
281
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
282 /**
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
283 * Attach a counting instrument to each node that is assigned a specified tag.
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
284 */
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
285 private class CoverageProbeListener 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
286
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
287 @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
288 public void probeTaggedAs(Probe probe, SyntaxTag tag, Object tagValue) {
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
289 if (countingTag == tag) {
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
290
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
291 final SourceSection srcSection = 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
292 if (srcSection == 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
293 // TODO (mlvdv) report this?
20907
06b0a2fb20a1 Truffle/Tools: the coverage tool will now ignore counts for any sources holding the tag CoverageTracker.Tags.NO_COVERAGE.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
294 } else if (!srcSection.getSource().isTaggedAs(Tags.NO_COVERAGE)) {
19248
a2ff253c458f Truffle/Instrumentation: code cleanups in tools CoverageTracker and NodeExecCounter, especially for tutorial value
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19187
diff changeset
295 // Get the source line where the
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
296 final LineLocation lineLocation = srcSection.getLineLocation();
19248
a2ff253c458f Truffle/Instrumentation: code cleanups in tools CoverageTracker and NodeExecCounter, especially for tutorial value
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19187
diff changeset
297 CoverageRecord record = coverageMap.get(lineLocation);
a2ff253c458f Truffle/Instrumentation: code cleanups in tools CoverageTracker and NodeExecCounter, especially for tutorial value
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19187
diff changeset
298 if (record != null) {
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
299 // Another node starts on same line; count only the first (textually)
19248
a2ff253c458f Truffle/Instrumentation: code cleanups in tools CoverageTracker and NodeExecCounter, especially for tutorial value
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19187
diff changeset
300 if (srcSection.getCharIndex() > record.srcSection.getCharIndex()) {
19593
6d895b028a44 Truffle/InstrumentationTools: clean up some misleading code and commentary in CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
301 // Existing record, corresponds to code earlier on line
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
302 return;
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
303 } else {
19593
6d895b028a44 Truffle/InstrumentationTools: clean up some misleading code and commentary in CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
304 // Existing record, corresponds to code at a later position; replace it
19248
a2ff253c458f Truffle/Instrumentation: code cleanups in tools CoverageTracker and NodeExecCounter, especially for tutorial value
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19187
diff changeset
305 record.instrument.dispose();
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
306 }
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
307 }
19593
6d895b028a44 Truffle/InstrumentationTools: clean up some misleading code and commentary in CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
308
6d895b028a44 Truffle/InstrumentationTools: clean up some misleading code and commentary in CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
309 final CoverageRecord coverage = new CoverageRecord(srcSection);
6d895b028a44 Truffle/InstrumentationTools: clean up some misleading code and commentary in CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
310 final Instrument instrument = Instrument.create(coverage, CoverageTracker.class.getSimpleName());
6d895b028a44 Truffle/InstrumentationTools: clean up some misleading code and commentary in CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
311 coverage.instrument = instrument;
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
312 instruments.add(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
313 probe.attach(instrument);
19593
6d895b028a44 Truffle/InstrumentationTools: clean up some misleading code and commentary in CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
314 coverageMap.put(lineLocation, coverage);
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
315 }
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
316 }
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
317 }
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
318 }
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
319
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
320 }