Mercurial > hg > truffle
comparison truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/debug/LineBreakpointFactory.java @ 22219:1c0f490984d5
Merge with f47b601edbc626dcfe8b3636933b4834c89f7779
author | Michael Van De Vanter <michael.van.de.vanter@oracle.com> |
---|---|
date | Wed, 16 Sep 2015 15:36:22 -0700 |
parents | dc83cc1f94f2 3aad794eec0e |
children | a0fa69e3e60e |
comparison
equal
deleted
inserted
replaced
22160:0599e2df6a9f | 22219:1c0f490984d5 |
---|---|
22 * or visit www.oracle.com if you need additional information or have any | 22 * or visit www.oracle.com if you need additional information or have any |
23 * questions. | 23 * questions. |
24 */ | 24 */ |
25 package com.oracle.truffle.api.debug; | 25 package com.oracle.truffle.api.debug; |
26 | 26 |
27 import com.oracle.truffle.api.Assumption; | |
28 import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; | |
29 import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; | |
30 import com.oracle.truffle.api.Truffle; | |
31 import static com.oracle.truffle.api.debug.Breakpoint.State.DISABLED; | 27 import static com.oracle.truffle.api.debug.Breakpoint.State.DISABLED; |
32 import static com.oracle.truffle.api.debug.Breakpoint.State.DISABLED_UNRESOLVED; | 28 import static com.oracle.truffle.api.debug.Breakpoint.State.DISABLED_UNRESOLVED; |
33 import static com.oracle.truffle.api.debug.Breakpoint.State.DISPOSED; | 29 import static com.oracle.truffle.api.debug.Breakpoint.State.DISPOSED; |
34 import static com.oracle.truffle.api.debug.Breakpoint.State.ENABLED; | 30 import static com.oracle.truffle.api.debug.Breakpoint.State.ENABLED; |
35 import static com.oracle.truffle.api.debug.Breakpoint.State.ENABLED_UNRESOLVED; | 31 import static com.oracle.truffle.api.debug.Breakpoint.State.ENABLED_UNRESOLVED; |
32 | |
33 import java.io.IOException; | |
34 import java.io.PrintStream; | |
35 import java.util.ArrayList; | |
36 import java.util.Collections; | |
37 import java.util.Comparator; | |
38 import java.util.HashMap; | |
39 import java.util.List; | |
40 import java.util.Map; | |
41 import java.util.Map.Entry; | |
42 | |
43 import com.oracle.truffle.api.Assumption; | |
44 import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; | |
45 import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; | |
46 import com.oracle.truffle.api.Truffle; | |
36 import com.oracle.truffle.api.debug.Debugger.BreakpointCallback; | 47 import com.oracle.truffle.api.debug.Debugger.BreakpointCallback; |
37 import com.oracle.truffle.api.debug.Debugger.WarningLog; | 48 import com.oracle.truffle.api.debug.Debugger.WarningLog; |
38 import com.oracle.truffle.api.frame.VirtualFrame; | 49 import com.oracle.truffle.api.frame.VirtualFrame; |
39 import com.oracle.truffle.api.instrument.AdvancedInstrumentResultListener; | 50 import com.oracle.truffle.api.instrument.AdvancedInstrumentResultListener; |
40 import com.oracle.truffle.api.instrument.Instrument; | 51 import com.oracle.truffle.api.instrument.Instrument; |
52 import com.oracle.truffle.api.instrument.Instrumenter; | |
41 import com.oracle.truffle.api.instrument.Probe; | 53 import com.oracle.truffle.api.instrument.Probe; |
42 import com.oracle.truffle.api.instrument.StandardSyntaxTag; | 54 import com.oracle.truffle.api.instrument.StandardSyntaxTag; |
43 import com.oracle.truffle.api.instrument.SyntaxTag; | 55 import com.oracle.truffle.api.instrument.SyntaxTag; |
44 import com.oracle.truffle.api.instrument.impl.DefaultProbeListener; | 56 import com.oracle.truffle.api.instrument.impl.DefaultProbeListener; |
45 import com.oracle.truffle.api.instrument.impl.DefaultStandardInstrumentListener; | 57 import com.oracle.truffle.api.instrument.impl.DefaultStandardInstrumentListener; |
46 import com.oracle.truffle.api.nodes.InvalidAssumptionException; | 58 import com.oracle.truffle.api.nodes.InvalidAssumptionException; |
47 import com.oracle.truffle.api.nodes.Node; | 59 import com.oracle.truffle.api.nodes.Node; |
48 import com.oracle.truffle.api.source.LineLocation; | 60 import com.oracle.truffle.api.source.LineLocation; |
49 import com.oracle.truffle.api.source.SourceSection; | 61 import com.oracle.truffle.api.source.SourceSection; |
50 import com.oracle.truffle.api.utilities.CyclicAssumption; | 62 import com.oracle.truffle.api.utilities.CyclicAssumption; |
51 import java.io.IOException; | |
52 import java.io.PrintStream; | |
53 import java.util.ArrayList; | |
54 import java.util.Collections; | |
55 import java.util.Comparator; | |
56 import java.util.HashMap; | |
57 import java.util.List; | |
58 import java.util.Map; | |
59 import java.util.Map.Entry; | |
60 | 63 |
61 //TODO (mlvdv) some common functionality could be factored out of this and TagBreakpointSupport | 64 //TODO (mlvdv) some common functionality could be factored out of this and TagBreakpointSupport |
62 | 65 |
63 /** | 66 /** |
64 * Support class for creating and managing all existing ordinary (user visible) line breakpoints. | 67 * Support class for creating and managing all existing ordinary (user visible) line breakpoints. |
81 final class LineBreakpointFactory { | 84 final class LineBreakpointFactory { |
82 | 85 |
83 private static final boolean TRACE = false; | 86 private static final boolean TRACE = false; |
84 private static final PrintStream OUT = System.out; | 87 private static final PrintStream OUT = System.out; |
85 | 88 |
86 private static final String BREAKPOINT_NAME = "LINE BREAKPOINT"; | 89 private static final String BREAKPOINT_NAME = "Line Breakpoints"; |
87 | 90 |
88 @TruffleBoundary | 91 @TruffleBoundary |
89 private static void trace(String format, Object... args) { | 92 private static void trace(String format, Object... args) { |
90 if (TRACE) { | 93 if (TRACE) { |
91 OUT.println(String.format("%s: %s", BREAKPOINT_NAME, String.format(format, args))); | 94 OUT.println(String.format("%s: %s", BREAKPOINT_NAME, String.format(format, args))); |
104 } | 107 } |
105 return Integer.compare(line1.getLineNumber(), line2.getLineNumber()); | 108 return Integer.compare(line1.getLineNumber(), line2.getLineNumber()); |
106 } | 109 } |
107 }; | 110 }; |
108 | 111 |
112 private final Debugger debugger; | |
109 private final BreakpointCallback breakpointCallback; | 113 private final BreakpointCallback breakpointCallback; |
110 private final WarningLog warningLog; | 114 private final WarningLog warningLog; |
111 | 115 |
112 /** | 116 /** |
113 * Map: Source lines ==> attached breakpoints. There may be no more than one line breakpoint | 117 * Map: Source lines ==> attached breakpoints. There may be no more than one line breakpoint |
125 * Globally suspends all line breakpoint activity when {@code false}, ignoring whether | 129 * Globally suspends all line breakpoint activity when {@code false}, ignoring whether |
126 * individual breakpoints are enabled. | 130 * individual breakpoints are enabled. |
127 */ | 131 */ |
128 @CompilationFinal private boolean breakpointsActive = true; | 132 @CompilationFinal private boolean breakpointsActive = true; |
129 private final CyclicAssumption breakpointsActiveUnchanged = new CyclicAssumption(BREAKPOINT_NAME + " globally active"); | 133 private final CyclicAssumption breakpointsActiveUnchanged = new CyclicAssumption(BREAKPOINT_NAME + " globally active"); |
130 private final Debugger debugger; | |
131 | 134 |
132 LineBreakpointFactory(Debugger debugger, BreakpointCallback breakpointCallback, final WarningLog warningLog) { | 135 LineBreakpointFactory(Debugger debugger, BreakpointCallback breakpointCallback, final WarningLog warningLog) { |
133 this.debugger = debugger; | 136 this.debugger = debugger; |
134 this.breakpointCallback = breakpointCallback; | 137 this.breakpointCallback = breakpointCallback; |
135 this.warningLog = warningLog; | 138 this.warningLog = warningLog; |
136 | 139 |
140 final Instrumenter instrumenter = debugger.getInstrumenter(); | |
137 lineToProbesMap = new LineToProbesMap(); | 141 lineToProbesMap = new LineToProbesMap(); |
138 lineToProbesMap.install(); | 142 lineToProbesMap.install(instrumenter); |
139 | 143 |
140 Probe.addProbeListener(new DefaultProbeListener() { | 144 instrumenter.addProbeListener(new DefaultProbeListener() { |
141 | 145 |
142 @Override | 146 @Override |
143 public void probeTaggedAs(Probe probe, SyntaxTag tag, Object tagValue) { | 147 public void probeTaggedAs(Probe probe, SyntaxTag tag, Object tagValue) { |
144 if (tag == StandardSyntaxTag.STATEMENT) { | 148 if (tag == StandardSyntaxTag.STATEMENT) { |
145 final SourceSection sourceSection = probe.getProbedSourceSection(); | 149 final SourceSection sourceSection = probe.getProbedSourceSection(); |