annotate agent/src/share/classes/sun/jvm/hotspot/tools/Tool.java @ 12932:7fe6ef09d242

8025638: jmap returns 0 instead of 1 when it fails. Summary: Re-factored some code handling return values and fails/errors during tool execution. Reviewed-by: sla, kevinw Contributed-by: fredrik.arvidsson@oracle.com
author farvidsson
date Wed, 16 Oct 2013 09:20:23 +0200
parents 38ea2efa32a7
children 5280822ddfcd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
2 * Copyright (c) 2002, 2004, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 package sun.jvm.hotspot.tools;
a61af66fc99e Initial load
duke
parents:
diff changeset
26
a61af66fc99e Initial load
duke
parents:
diff changeset
27 import java.io.PrintStream;
a61af66fc99e Initial load
duke
parents:
diff changeset
28 import java.util.Hashtable;
12932
7fe6ef09d242 8025638: jmap returns 0 instead of 1 when it fails.
farvidsson
parents: 11054
diff changeset
29
0
a61af66fc99e Initial load
duke
parents:
diff changeset
30 import sun.jvm.hotspot.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 import sun.jvm.hotspot.runtime.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
32 import sun.jvm.hotspot.debugger.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
33
a61af66fc99e Initial load
duke
parents:
diff changeset
34 // generic command line or GUI tool.
a61af66fc99e Initial load
duke
parents:
diff changeset
35 // override run & code main as shown below.
a61af66fc99e Initial load
duke
parents:
diff changeset
36
a61af66fc99e Initial load
duke
parents:
diff changeset
37 public abstract class Tool implements Runnable {
8103
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 1552
diff changeset
38 private HotSpotAgent agent;
11054
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 8103
diff changeset
39 private JVMDebugger jvmDebugger;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
40 private int debugeeType;
a61af66fc99e Initial load
duke
parents:
diff changeset
41
a61af66fc99e Initial load
duke
parents:
diff changeset
42 // debugeeType is one of constants below
a61af66fc99e Initial load
duke
parents:
diff changeset
43 protected static final int DEBUGEE_PID = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
44 protected static final int DEBUGEE_CORE = 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
45 protected static final int DEBUGEE_REMOTE = 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
46
11054
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 8103
diff changeset
47 public Tool() {
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 8103
diff changeset
48 }
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 8103
diff changeset
49
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 8103
diff changeset
50 public Tool(JVMDebugger d) {
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 8103
diff changeset
51 jvmDebugger = d;
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 8103
diff changeset
52 }
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 8103
diff changeset
53
0
a61af66fc99e Initial load
duke
parents:
diff changeset
54 public String getName() {
a61af66fc99e Initial load
duke
parents:
diff changeset
55 return getClass().getName();
a61af66fc99e Initial load
duke
parents:
diff changeset
56 }
a61af66fc99e Initial load
duke
parents:
diff changeset
57
a61af66fc99e Initial load
duke
parents:
diff changeset
58 protected boolean needsJavaPrefix() {
a61af66fc99e Initial load
duke
parents:
diff changeset
59 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
60 }
a61af66fc99e Initial load
duke
parents:
diff changeset
61
8103
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 1552
diff changeset
62 protected void setAgent(HotSpotAgent a) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
63 agent = a;
a61af66fc99e Initial load
duke
parents:
diff changeset
64 }
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66 protected void setDebugeeType(int dt) {
a61af66fc99e Initial load
duke
parents:
diff changeset
67 debugeeType = dt;
a61af66fc99e Initial load
duke
parents:
diff changeset
68 }
a61af66fc99e Initial load
duke
parents:
diff changeset
69
8103
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 1552
diff changeset
70 protected HotSpotAgent getAgent() {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
71 return agent;
a61af66fc99e Initial load
duke
parents:
diff changeset
72 }
a61af66fc99e Initial load
duke
parents:
diff changeset
73
a61af66fc99e Initial load
duke
parents:
diff changeset
74 protected int getDebugeeType() {
a61af66fc99e Initial load
duke
parents:
diff changeset
75 return debugeeType;
a61af66fc99e Initial load
duke
parents:
diff changeset
76 }
a61af66fc99e Initial load
duke
parents:
diff changeset
77
a61af66fc99e Initial load
duke
parents:
diff changeset
78 protected void printUsage() {
a61af66fc99e Initial load
duke
parents:
diff changeset
79 String name = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
80 if (needsJavaPrefix()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
81 name = "java " + getName();
a61af66fc99e Initial load
duke
parents:
diff changeset
82 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
83 name = getName();
a61af66fc99e Initial load
duke
parents:
diff changeset
84 }
a61af66fc99e Initial load
duke
parents:
diff changeset
85 System.out.println("Usage: " + name + " [option] <pid>");
a61af66fc99e Initial load
duke
parents:
diff changeset
86 System.out.println("\t\t(to connect to a live java process)");
a61af66fc99e Initial load
duke
parents:
diff changeset
87 System.out.println(" or " + name + " [option] <executable> <core>");
a61af66fc99e Initial load
duke
parents:
diff changeset
88 System.out.println("\t\t(to connect to a core file)");
a61af66fc99e Initial load
duke
parents:
diff changeset
89 System.out.println(" or " + name + " [option] [server_id@]<remote server IP or hostname>");
a61af66fc99e Initial load
duke
parents:
diff changeset
90 System.out.println("\t\t(to connect to a remote debug server)");
a61af66fc99e Initial load
duke
parents:
diff changeset
91 System.out.println();
a61af66fc99e Initial load
duke
parents:
diff changeset
92 System.out.println("where option must be one of:");
a61af66fc99e Initial load
duke
parents:
diff changeset
93 printFlagsUsage();
a61af66fc99e Initial load
duke
parents:
diff changeset
94 }
a61af66fc99e Initial load
duke
parents:
diff changeset
95
a61af66fc99e Initial load
duke
parents:
diff changeset
96 protected void printFlagsUsage() {
a61af66fc99e Initial load
duke
parents:
diff changeset
97 System.out.println(" -h | -help\tto print this help message");
a61af66fc99e Initial load
duke
parents:
diff changeset
98 }
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100 protected void usage() {
a61af66fc99e Initial load
duke
parents:
diff changeset
101 printUsage();
a61af66fc99e Initial load
duke
parents:
diff changeset
102 }
a61af66fc99e Initial load
duke
parents:
diff changeset
103
a61af66fc99e Initial load
duke
parents:
diff changeset
104 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
105 Derived class main should be of the following form:
a61af66fc99e Initial load
duke
parents:
diff changeset
106
a61af66fc99e Initial load
duke
parents:
diff changeset
107 public static void main(String[] args) {
a61af66fc99e Initial load
duke
parents:
diff changeset
108 <derived class> obj = new <derived class>;
12932
7fe6ef09d242 8025638: jmap returns 0 instead of 1 when it fails.
farvidsson
parents: 11054
diff changeset
109 obj.execute(args);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
110 }
a61af66fc99e Initial load
duke
parents:
diff changeset
111
a61af66fc99e Initial load
duke
parents:
diff changeset
112 */
a61af66fc99e Initial load
duke
parents:
diff changeset
113
12932
7fe6ef09d242 8025638: jmap returns 0 instead of 1 when it fails.
farvidsson
parents: 11054
diff changeset
114 protected void execute(String[] args) {
7fe6ef09d242 8025638: jmap returns 0 instead of 1 when it fails.
farvidsson
parents: 11054
diff changeset
115 int returnStatus = 1;
7fe6ef09d242 8025638: jmap returns 0 instead of 1 when it fails.
farvidsson
parents: 11054
diff changeset
116
7fe6ef09d242 8025638: jmap returns 0 instead of 1 when it fails.
farvidsson
parents: 11054
diff changeset
117 try {
7fe6ef09d242 8025638: jmap returns 0 instead of 1 when it fails.
farvidsson
parents: 11054
diff changeset
118 returnStatus = start(args);
7fe6ef09d242 8025638: jmap returns 0 instead of 1 when it fails.
farvidsson
parents: 11054
diff changeset
119 } finally {
7fe6ef09d242 8025638: jmap returns 0 instead of 1 when it fails.
farvidsson
parents: 11054
diff changeset
120 stop();
7fe6ef09d242 8025638: jmap returns 0 instead of 1 when it fails.
farvidsson
parents: 11054
diff changeset
121 }
7fe6ef09d242 8025638: jmap returns 0 instead of 1 when it fails.
farvidsson
parents: 11054
diff changeset
122
7fe6ef09d242 8025638: jmap returns 0 instead of 1 when it fails.
farvidsson
parents: 11054
diff changeset
123 // Exit with 0 or 1
7fe6ef09d242 8025638: jmap returns 0 instead of 1 when it fails.
farvidsson
parents: 11054
diff changeset
124 System.exit(returnStatus);
7fe6ef09d242 8025638: jmap returns 0 instead of 1 when it fails.
farvidsson
parents: 11054
diff changeset
125 }
7fe6ef09d242 8025638: jmap returns 0 instead of 1 when it fails.
farvidsson
parents: 11054
diff changeset
126
7fe6ef09d242 8025638: jmap returns 0 instead of 1 when it fails.
farvidsson
parents: 11054
diff changeset
127 public void stop() {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
128 if (agent != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
129 agent.detach();
a61af66fc99e Initial load
duke
parents:
diff changeset
130 }
a61af66fc99e Initial load
duke
parents:
diff changeset
131 }
a61af66fc99e Initial load
duke
parents:
diff changeset
132
12932
7fe6ef09d242 8025638: jmap returns 0 instead of 1 when it fails.
farvidsson
parents: 11054
diff changeset
133 private int start(String[] args) {
7fe6ef09d242 8025638: jmap returns 0 instead of 1 when it fails.
farvidsson
parents: 11054
diff changeset
134
0
a61af66fc99e Initial load
duke
parents:
diff changeset
135 if ((args.length < 1) || (args.length > 2)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
136 usage();
12932
7fe6ef09d242 8025638: jmap returns 0 instead of 1 when it fails.
farvidsson
parents: 11054
diff changeset
137 return 1;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
138 }
a61af66fc99e Initial load
duke
parents:
diff changeset
139
a61af66fc99e Initial load
duke
parents:
diff changeset
140 // Attempt to handle -h or -help or some invalid flag
12932
7fe6ef09d242 8025638: jmap returns 0 instead of 1 when it fails.
farvidsson
parents: 11054
diff changeset
141 if (args[0].startsWith("-h")) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
142 usage();
12932
7fe6ef09d242 8025638: jmap returns 0 instead of 1 when it fails.
farvidsson
parents: 11054
diff changeset
143 return 0;
7fe6ef09d242 8025638: jmap returns 0 instead of 1 when it fails.
farvidsson
parents: 11054
diff changeset
144 } else if (args[0].startsWith("-")) {
7fe6ef09d242 8025638: jmap returns 0 instead of 1 when it fails.
farvidsson
parents: 11054
diff changeset
145 usage();
7fe6ef09d242 8025638: jmap returns 0 instead of 1 when it fails.
farvidsson
parents: 11054
diff changeset
146 return 1;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
147 }
a61af66fc99e Initial load
duke
parents:
diff changeset
148
a61af66fc99e Initial load
duke
parents:
diff changeset
149 PrintStream err = System.err;
a61af66fc99e Initial load
duke
parents:
diff changeset
150
a61af66fc99e Initial load
duke
parents:
diff changeset
151 int pid = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
152 String coreFileName = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
153 String executableName = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
154 String remoteServer = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
155
a61af66fc99e Initial load
duke
parents:
diff changeset
156 switch (args.length) {
a61af66fc99e Initial load
duke
parents:
diff changeset
157 case 1:
a61af66fc99e Initial load
duke
parents:
diff changeset
158 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
159 pid = Integer.parseInt(args[0]);
a61af66fc99e Initial load
duke
parents:
diff changeset
160 debugeeType = DEBUGEE_PID;
a61af66fc99e Initial load
duke
parents:
diff changeset
161 } catch (NumberFormatException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
162 // try remote server
a61af66fc99e Initial load
duke
parents:
diff changeset
163 remoteServer = args[0];
a61af66fc99e Initial load
duke
parents:
diff changeset
164 debugeeType = DEBUGEE_REMOTE;
a61af66fc99e Initial load
duke
parents:
diff changeset
165 }
a61af66fc99e Initial load
duke
parents:
diff changeset
166 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
167
a61af66fc99e Initial load
duke
parents:
diff changeset
168 case 2:
a61af66fc99e Initial load
duke
parents:
diff changeset
169 executableName = args[0];
a61af66fc99e Initial load
duke
parents:
diff changeset
170 coreFileName = args[1];
a61af66fc99e Initial load
duke
parents:
diff changeset
171 debugeeType = DEBUGEE_CORE;
a61af66fc99e Initial load
duke
parents:
diff changeset
172 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
173
a61af66fc99e Initial load
duke
parents:
diff changeset
174 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
175 usage();
12932
7fe6ef09d242 8025638: jmap returns 0 instead of 1 when it fails.
farvidsson
parents: 11054
diff changeset
176 return 1;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
177 }
a61af66fc99e Initial load
duke
parents:
diff changeset
178
8103
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 1552
diff changeset
179 agent = new HotSpotAgent();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
180 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
181 switch (debugeeType) {
a61af66fc99e Initial load
duke
parents:
diff changeset
182 case DEBUGEE_PID:
a61af66fc99e Initial load
duke
parents:
diff changeset
183 err.println("Attaching to process ID " + pid + ", please wait...");
a61af66fc99e Initial load
duke
parents:
diff changeset
184 agent.attach(pid);
a61af66fc99e Initial load
duke
parents:
diff changeset
185 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
186
a61af66fc99e Initial load
duke
parents:
diff changeset
187 case DEBUGEE_CORE:
a61af66fc99e Initial load
duke
parents:
diff changeset
188 err.println("Attaching to core " + coreFileName +
a61af66fc99e Initial load
duke
parents:
diff changeset
189 " from executable " + executableName + ", please wait...");
a61af66fc99e Initial load
duke
parents:
diff changeset
190 agent.attach(executableName, coreFileName);
a61af66fc99e Initial load
duke
parents:
diff changeset
191 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
192
a61af66fc99e Initial load
duke
parents:
diff changeset
193 case DEBUGEE_REMOTE:
a61af66fc99e Initial load
duke
parents:
diff changeset
194 err.println("Attaching to remote server " + remoteServer + ", please wait...");
a61af66fc99e Initial load
duke
parents:
diff changeset
195 agent.attach(remoteServer);
a61af66fc99e Initial load
duke
parents:
diff changeset
196 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
197 }
a61af66fc99e Initial load
duke
parents:
diff changeset
198 }
a61af66fc99e Initial load
duke
parents:
diff changeset
199 catch (DebuggerException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
200 switch (debugeeType) {
a61af66fc99e Initial load
duke
parents:
diff changeset
201 case DEBUGEE_PID:
a61af66fc99e Initial load
duke
parents:
diff changeset
202 err.print("Error attaching to process: ");
a61af66fc99e Initial load
duke
parents:
diff changeset
203 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
204
a61af66fc99e Initial load
duke
parents:
diff changeset
205 case DEBUGEE_CORE:
a61af66fc99e Initial load
duke
parents:
diff changeset
206 err.print("Error attaching to core file: ");
a61af66fc99e Initial load
duke
parents:
diff changeset
207 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
208
a61af66fc99e Initial load
duke
parents:
diff changeset
209 case DEBUGEE_REMOTE:
a61af66fc99e Initial load
duke
parents:
diff changeset
210 err.print("Error attaching to remote server: ");
a61af66fc99e Initial load
duke
parents:
diff changeset
211 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
212 }
a61af66fc99e Initial load
duke
parents:
diff changeset
213 if (e.getMessage() != null) {
12932
7fe6ef09d242 8025638: jmap returns 0 instead of 1 when it fails.
farvidsson
parents: 11054
diff changeset
214 err.println(e.getMessage());
11054
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 8103
diff changeset
215 e.printStackTrace();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
216 }
a61af66fc99e Initial load
duke
parents:
diff changeset
217 err.println();
12932
7fe6ef09d242 8025638: jmap returns 0 instead of 1 when it fails.
farvidsson
parents: 11054
diff changeset
218 return 1;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
219 }
a61af66fc99e Initial load
duke
parents:
diff changeset
220
a61af66fc99e Initial load
duke
parents:
diff changeset
221 err.println("Debugger attached successfully.");
11054
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 8103
diff changeset
222 startInternal();
12932
7fe6ef09d242 8025638: jmap returns 0 instead of 1 when it fails.
farvidsson
parents: 11054
diff changeset
223 return 0;
11054
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 8103
diff changeset
224 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
225
11054
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 8103
diff changeset
226 // When using an existing JVMDebugger.
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 8103
diff changeset
227 public void start() {
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 8103
diff changeset
228
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 8103
diff changeset
229 if (jvmDebugger == null) {
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 8103
diff changeset
230 throw new RuntimeException("Tool.start() called with no JVMDebugger set.");
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 8103
diff changeset
231 }
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 8103
diff changeset
232 agent = new HotSpotAgent();
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 8103
diff changeset
233 agent.attach(jvmDebugger);
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 8103
diff changeset
234 startInternal();
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 8103
diff changeset
235 }
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 8103
diff changeset
236
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 8103
diff changeset
237 // Remains of the start mechanism, common to both start methods.
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 8103
diff changeset
238 private void startInternal() {
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 8103
diff changeset
239
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 8103
diff changeset
240 PrintStream err = System.err;
8103
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 1552
diff changeset
241 VM vm = VM.getVM();
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 1552
diff changeset
242 if (vm.isCore()) {
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 1552
diff changeset
243 err.println("Core build detected.");
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 1552
diff changeset
244 } else if (vm.isClientCompiler()) {
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 1552
diff changeset
245 err.println("Client compiler detected.");
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 1552
diff changeset
246 } else if (vm.isServerCompiler()) {
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 1552
diff changeset
247 err.println("Server compiler detected.");
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 1552
diff changeset
248 } else {
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 1552
diff changeset
249 throw new RuntimeException("Fatal error: "
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 1552
diff changeset
250 + "should have been able to detect core/C1/C2 build");
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 1552
diff changeset
251 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
252
8103
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 1552
diff changeset
253 String version = vm.getVMRelease();
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 1552
diff changeset
254 if (version != null) {
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 1552
diff changeset
255 err.print("JVM version is ");
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 1552
diff changeset
256 err.println(version);
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 1552
diff changeset
257 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
258
8103
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 1552
diff changeset
259 run();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
260 }
a61af66fc99e Initial load
duke
parents:
diff changeset
261 }