Mercurial > hg > graal-compiler
diff graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Probe.java @ 21684:c072fbce5756
Truffle/Instrumentation: move Probe tracing out of DebugEngine and into Probe
author | Michael Van De Vanter <michael.van.de.vanter@oracle.com> |
---|---|
date | Tue, 02 Jun 2015 16:44:16 -0700 |
parents | d6d9631eb057 |
children | fd8a92655fbd |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Probe.java Tue Jun 02 23:20:46 2015 +0200 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Probe.java Tue Jun 02 16:44:16 2015 -0700 @@ -24,6 +24,7 @@ */ package com.oracle.truffle.api.instrument; +import java.io.*; import java.lang.ref.*; import java.util.*; @@ -100,6 +101,16 @@ */ public final class Probe { + private static final boolean TRACE = false; + private static final String TRACE_PREFIX = "PROBE: "; + private static final PrintStream OUT = System.out; + + private static void trace(String format, Object... args) { + if (TRACE) { + OUT.println(TRACE_PREFIX + String.format(format, args)); + } + } + private static final List<ASTProber> astProbers = new ArrayList<>(); private static final List<ProbeListener> probeListeners = new ArrayList<>(); @@ -163,7 +174,8 @@ public static void applyASTProbers(Node node) { final Source source = findSource(node); - + final String sourceName = source == null ? "<?>" : source.getShortName(); + trace("START %s", sourceName); for (ProbeListener listener : probeListeners) { listener.startASTProbing(source); } @@ -173,6 +185,7 @@ for (ProbeListener listener : probeListeners) { listener.endASTProbing(source); } + trace("FINISHED %s", sourceName); } /** @@ -286,6 +299,10 @@ this.sourceSection = sourceSection; probes.add(new WeakReference<>(this)); registerProbeNodeClone(probeNode); + if (TRACE) { + final String location = this.sourceSection == null ? "<unknown>" : sourceSection.getShortDescription(); + trace("ADDED %s %s %s", "Probe@", location, getTagsDescription()); + } for (ProbeListener listener : probeListeners) { listener.newProbeInserted(this); } @@ -332,6 +349,9 @@ if (tagTrapsChanged) { invalidateProbeUnchanged(); } + if (TRACE) { + trace("TAGGED as %s: %s", tag, getShortDescription()); + } } }