Mercurial > hg > graal-compiler
comparison agent/src/share/classes/sun/jvm/hotspot/tools/Tool.java @ 8103:5ed317b25e23
7165259: Remove BugSpot
Reviewed-by: coleenp, mgronlun
author | sla |
---|---|
date | Fri, 22 Feb 2013 10:03:02 +0100 |
parents | c18cbe5936b8 |
children | 38ea2efa32a7 |
comparison
equal
deleted
inserted
replaced
8102:fc64254f5579 | 8103:5ed317b25e23 |
---|---|
25 package sun.jvm.hotspot.tools; | 25 package sun.jvm.hotspot.tools; |
26 | 26 |
27 import java.io.PrintStream; | 27 import java.io.PrintStream; |
28 import java.util.Hashtable; | 28 import java.util.Hashtable; |
29 import sun.jvm.hotspot.*; | 29 import sun.jvm.hotspot.*; |
30 import sun.jvm.hotspot.bugspot.*; | |
31 import sun.jvm.hotspot.runtime.*; | 30 import sun.jvm.hotspot.runtime.*; |
32 import sun.jvm.hotspot.debugger.*; | 31 import sun.jvm.hotspot.debugger.*; |
33 | 32 |
34 // generic command line or GUI tool. | 33 // generic command line or GUI tool. |
35 // override run & code main as shown below. | 34 // override run & code main as shown below. |
36 | 35 |
37 public abstract class Tool implements Runnable { | 36 public abstract class Tool implements Runnable { |
38 private BugSpotAgent agent; | 37 private HotSpotAgent agent; |
39 private int debugeeType; | 38 private int debugeeType; |
40 | 39 |
41 // debugeeType is one of constants below | 40 // debugeeType is one of constants below |
42 protected static final int DEBUGEE_PID = 0; | 41 protected static final int DEBUGEE_PID = 0; |
43 protected static final int DEBUGEE_CORE = 1; | 42 protected static final int DEBUGEE_CORE = 1; |
49 | 48 |
50 protected boolean needsJavaPrefix() { | 49 protected boolean needsJavaPrefix() { |
51 return true; | 50 return true; |
52 } | 51 } |
53 | 52 |
54 // whether this tool requires debuggee to be java process or core? | 53 protected void setAgent(HotSpotAgent a) { |
55 protected boolean requiresVM() { | |
56 return true; | |
57 } | |
58 | |
59 protected void setAgent(BugSpotAgent a) { | |
60 agent = a; | 54 agent = a; |
61 } | 55 } |
62 | 56 |
63 protected void setDebugeeType(int dt) { | 57 protected void setDebugeeType(int dt) { |
64 debugeeType = dt; | 58 debugeeType = dt; |
65 } | 59 } |
66 | 60 |
67 protected BugSpotAgent getAgent() { | 61 protected HotSpotAgent getAgent() { |
68 return agent; | 62 return agent; |
69 } | 63 } |
70 | 64 |
71 protected int getDebugeeType() { | 65 protected int getDebugeeType() { |
72 return debugeeType; | 66 return debugeeType; |
153 | 147 |
154 default: | 148 default: |
155 usage(); | 149 usage(); |
156 } | 150 } |
157 | 151 |
158 agent = new BugSpotAgent(); | 152 agent = new HotSpotAgent(); |
159 try { | 153 try { |
160 switch (debugeeType) { | 154 switch (debugeeType) { |
161 case DEBUGEE_PID: | 155 case DEBUGEE_PID: |
162 err.println("Attaching to process ID " + pid + ", please wait..."); | 156 err.println("Attaching to process ID " + pid + ", please wait..."); |
163 agent.attach(pid); | 157 agent.attach(pid); |
196 System.exit(1); | 190 System.exit(1); |
197 } | 191 } |
198 | 192 |
199 err.println("Debugger attached successfully."); | 193 err.println("Debugger attached successfully."); |
200 | 194 |
201 boolean isJava = agent.isJavaMode(); | 195 VM vm = VM.getVM(); |
202 if (isJava) { | 196 if (vm.isCore()) { |
203 VM vm = VM.getVM(); | 197 err.println("Core build detected."); |
204 if (vm.isCore()) { | 198 } else if (vm.isClientCompiler()) { |
205 err.println("Core build detected."); | 199 err.println("Client compiler detected."); |
206 } else if (vm.isClientCompiler()) { | 200 } else if (vm.isServerCompiler()) { |
207 err.println("Client compiler detected."); | 201 err.println("Server compiler detected."); |
208 } else if (vm.isServerCompiler()) { | 202 } else { |
209 err.println("Server compiler detected."); | 203 throw new RuntimeException("Fatal error: " |
210 } else { | 204 + "should have been able to detect core/C1/C2 build"); |
211 throw new RuntimeException("Fatal error: " + | 205 } |
212 "should have been able to detect core/C1/C2 build"); | 206 |
213 } | 207 String version = vm.getVMRelease(); |
214 | 208 if (version != null) { |
215 String version = vm.getVMRelease(); | 209 err.print("JVM version is "); |
216 if (version != null) { | 210 err.println(version); |
217 err.print("JVM version is "); | 211 } |
218 err.println(version); | 212 |
219 } | 213 run(); |
220 | |
221 run(); | |
222 } else { // not a java process or core | |
223 if (requiresVM()) { | |
224 err.println(getName() + " requires a java VM process/core!"); | |
225 } else { | |
226 run(); | |
227 } | |
228 } | |
229 } | 214 } |
230 } | 215 } |