author | ysuenaga |
Sat, 07 May 2016 10:29:16 +0900 | |
changeset 38264 | a6a9765aafd5 |
parent 37445 | 5565e6e80352 |
child 40101 | 3b8101f0fd65 |
permissions | -rw-r--r-- |
31978 | 1 |
/* |
2 |
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
* |
|
23 |
*/ |
|
24 |
||
25 |
package sun.jvm.hotspot; |
|
26 |
||
27 |
import java.util.ArrayList; |
|
28 |
import java.util.Arrays; |
|
29 |
||
30 |
import sun.jvm.hotspot.tools.JStack; |
|
31 |
import sun.jvm.hotspot.tools.JMap; |
|
32 |
import sun.jvm.hotspot.tools.JInfo; |
|
37090 | 33 |
import sun.jvm.hotspot.tools.JSnap; |
31978 | 34 |
|
35 |
public class SALauncher { |
|
36 |
||
37 |
private static boolean launcherHelp() { |
|
38 |
System.out.println(" clhsdb \tcommand line debugger"); |
|
39 |
System.out.println(" hsdb \tui debugger"); |
|
40 |
System.out.println(" jstack --help\tto get more information"); |
|
41 |
System.out.println(" jmap --help\tto get more information"); |
|
42 |
System.out.println(" jinfo --help\tto get more information"); |
|
37090 | 43 |
System.out.println(" jsnap --help\tto get more information"); |
31978 | 44 |
return false; |
45 |
} |
|
46 |
||
47 |
private static boolean commonHelp() { |
|
48 |
// --pid <pid> |
|
49 |
// --exe <exe> |
|
50 |
// --core <core> |
|
51 |
System.out.println(" --exe\texecutable image name"); |
|
52 |
System.out.println(" --core\tpath to coredump"); |
|
53 |
System.out.println(" --pid\tpid of process to attach"); |
|
54 |
return false; |
|
55 |
} |
|
56 |
||
57 |
private static boolean jinfoHelp() { |
|
58 |
// --flags -> -flags |
|
59 |
// --sysprops -> -sysprops |
|
60 |
System.out.println(" --flags\tto print VM flags"); |
|
61 |
System.out.println(" --sysprops\tto print Java System properties"); |
|
62 |
System.out.println(" <no option>\tto print both of the above"); |
|
63 |
return commonHelp(); |
|
64 |
} |
|
65 |
||
66 |
private static boolean jmapHelp() { |
|
67 |
// --heap -> -heap |
|
68 |
// --binaryheap -> -heap:format=b |
|
69 |
// --histo -> -histo |
|
70 |
// --clstats -> -clstats |
|
71 |
// --finalizerinfo -> -finalizerinfo |
|
72 |
||
73 |
System.out.println(" <no option>\tto print same info as Solaris pmap"); |
|
74 |
System.out.println(" --heap\tto print java heap summary"); |
|
75 |
System.out.println(" --binaryheap\tto dump java heap in hprof binary format"); |
|
38264 | 76 |
System.out.println(" --dumpfile\tname of the dump file"); |
31978 | 77 |
System.out.println(" --histo\tto print histogram of java object heap"); |
78 |
System.out.println(" --clstats\tto print class loader statistics"); |
|
79 |
System.out.println(" --finalizerinfo\tto print information on objects awaiting finalization"); |
|
80 |
return commonHelp(); |
|
81 |
} |
|
82 |
||
83 |
private static boolean jstackHelp() { |
|
84 |
// --locks -> -l |
|
85 |
// --mixed -> -m |
|
86 |
System.out.println(" --locks\tto print java.util.concurrent locks"); |
|
87 |
System.out.println(" --mixed\tto print both java and native frames (mixed mode)"); |
|
88 |
return commonHelp(); |
|
89 |
} |
|
90 |
||
37090 | 91 |
private static boolean jsnapHelp() { |
37177 | 92 |
System.out.println(" --all\tto print all performance counters"); |
37090 | 93 |
return commonHelp(); |
94 |
} |
|
95 |
||
31978 | 96 |
private static boolean toolHelp(String toolName) { |
97 |
if (toolName.equals("jstack")) { |
|
98 |
return jstackHelp(); |
|
99 |
} |
|
100 |
if (toolName.equals("jinfo")) { |
|
101 |
return jinfoHelp(); |
|
102 |
} |
|
103 |
if (toolName.equals("jmap")) { |
|
104 |
return jmapHelp(); |
|
105 |
} |
|
37090 | 106 |
if (toolName.equals("jsnap")) { |
107 |
return jsnapHelp(); |
|
108 |
} |
|
31978 | 109 |
if (toolName.equals("hsdb") || toolName.equals("clhsdb")) { |
110 |
return commonHelp(); |
|
111 |
} |
|
112 |
return launcherHelp(); |
|
113 |
} |
|
114 |
||
37445
5565e6e80352
8152435: (CL)HSDB should be started with no argument
ysuenaga
parents:
37177
diff
changeset
|
115 |
private static void buildAttachArgs(ArrayList<String> newArgs, String pid, |
5565e6e80352
8152435: (CL)HSDB should be started with no argument
ysuenaga
parents:
37177
diff
changeset
|
116 |
String exe, String core, boolean allowEmpty) { |
5565e6e80352
8152435: (CL)HSDB should be started with no argument
ysuenaga
parents:
37177
diff
changeset
|
117 |
if (!allowEmpty && (pid == null) && (exe == null)) { |
5565e6e80352
8152435: (CL)HSDB should be started with no argument
ysuenaga
parents:
37177
diff
changeset
|
118 |
throw new SAGetoptException("You have to set --pid or --exe."); |
37101
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
119 |
} |
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
120 |
|
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
121 |
if (pid != null) { // Attach to live process |
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
122 |
if (exe != null) { |
37445
5565e6e80352
8152435: (CL)HSDB should be started with no argument
ysuenaga
parents:
37177
diff
changeset
|
123 |
throw new SAGetoptException("Unnecessary argument: --exe"); |
37101
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
124 |
} else if (core != null) { |
37445
5565e6e80352
8152435: (CL)HSDB should be started with no argument
ysuenaga
parents:
37177
diff
changeset
|
125 |
throw new SAGetoptException("Unnecessary argument: --core"); |
37101
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
126 |
} else if (!pid.matches("^\\d+$")) { |
37445
5565e6e80352
8152435: (CL)HSDB should be started with no argument
ysuenaga
parents:
37177
diff
changeset
|
127 |
throw new SAGetoptException("Invalid pid: " + pid); |
37101
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
128 |
} |
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
129 |
|
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
130 |
newArgs.add(pid); |
37445
5565e6e80352
8152435: (CL)HSDB should be started with no argument
ysuenaga
parents:
37177
diff
changeset
|
131 |
} else if (exe != null) { |
37101
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
132 |
if (exe.length() == 0) { |
37445
5565e6e80352
8152435: (CL)HSDB should be started with no argument
ysuenaga
parents:
37177
diff
changeset
|
133 |
throw new SAGetoptException("You have to set --exe."); |
37101
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
134 |
} |
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
135 |
|
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
136 |
newArgs.add(exe); |
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
137 |
|
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
138 |
if ((core == null) || (core.length() == 0)) { |
37445
5565e6e80352
8152435: (CL)HSDB should be started with no argument
ysuenaga
parents:
37177
diff
changeset
|
139 |
throw new SAGetoptException("You have to set --core."); |
37101
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
140 |
} |
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
141 |
|
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
142 |
newArgs.add(core); |
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
143 |
} |
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
144 |
} |
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
145 |
|
31978 | 146 |
private static void runCLHSDB(String[] oldArgs) { |
147 |
SAGetopt sg = new SAGetopt(oldArgs); |
|
148 |
String[] longOpts = {"exe=", "core=", "pid="}; |
|
149 |
||
150 |
ArrayList<String> newArgs = new ArrayList(); |
|
37101
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
151 |
String pid = null; |
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
152 |
String exe = null; |
31978 | 153 |
String core = null; |
154 |
String s = null; |
|
155 |
||
156 |
while((s = sg.next(null, longOpts)) != null) { |
|
157 |
if (s.equals("exe")) { |
|
37101
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
158 |
exe = sg.getOptarg(); |
31978 | 159 |
continue; |
160 |
} |
|
161 |
if (s.equals("core")) { |
|
162 |
core = sg.getOptarg(); |
|
163 |
continue; |
|
164 |
} |
|
165 |
if (s.equals("pid")) { |
|
37101
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
166 |
pid = sg.getOptarg(); |
31978 | 167 |
continue; |
168 |
} |
|
169 |
} |
|
170 |
||
37445
5565e6e80352
8152435: (CL)HSDB should be started with no argument
ysuenaga
parents:
37177
diff
changeset
|
171 |
buildAttachArgs(newArgs, pid, exe, core, true); |
31978 | 172 |
CLHSDB.main(newArgs.toArray(new String[newArgs.size()])); |
173 |
} |
|
174 |
||
175 |
private static void runHSDB(String[] oldArgs) { |
|
176 |
SAGetopt sg = new SAGetopt(oldArgs); |
|
177 |
String[] longOpts = {"exe=", "core=", "pid="}; |
|
178 |
||
179 |
ArrayList<String> newArgs = new ArrayList(); |
|
37101
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
180 |
String pid = null; |
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
181 |
String exe = null; |
31978 | 182 |
String core = null; |
183 |
String s = null; |
|
184 |
||
185 |
while((s = sg.next(null, longOpts)) != null) { |
|
186 |
if (s.equals("exe")) { |
|
37101
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
187 |
exe = sg.getOptarg(); |
31978 | 188 |
continue; |
189 |
} |
|
190 |
if (s.equals("core")) { |
|
191 |
core = sg.getOptarg(); |
|
192 |
continue; |
|
193 |
} |
|
194 |
if (s.equals("pid")) { |
|
37101
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
195 |
pid = sg.getOptarg(); |
31978 | 196 |
continue; |
197 |
} |
|
198 |
} |
|
199 |
||
37445
5565e6e80352
8152435: (CL)HSDB should be started with no argument
ysuenaga
parents:
37177
diff
changeset
|
200 |
buildAttachArgs(newArgs, pid, exe, core, true); |
31978 | 201 |
HSDB.main(newArgs.toArray(new String[newArgs.size()])); |
202 |
} |
|
203 |
||
204 |
private static void runJSTACK(String[] oldArgs) { |
|
205 |
SAGetopt sg = new SAGetopt(oldArgs); |
|
206 |
String[] longOpts = {"exe=", "core=", "pid=", |
|
207 |
"mixed", "locks"}; |
|
208 |
||
209 |
ArrayList<String> newArgs = new ArrayList(); |
|
37101
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
210 |
String pid = null; |
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
211 |
String exe = null; |
31978 | 212 |
String core = null; |
213 |
String s = null; |
|
214 |
||
215 |
while((s = sg.next(null, longOpts)) != null) { |
|
216 |
if (s.equals("exe")) { |
|
37101
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
217 |
exe = sg.getOptarg(); |
31978 | 218 |
continue; |
219 |
} |
|
220 |
if (s.equals("core")) { |
|
221 |
core = sg.getOptarg(); |
|
222 |
continue; |
|
223 |
} |
|
224 |
if (s.equals("pid")) { |
|
37101
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
225 |
pid = sg.getOptarg(); |
31978 | 226 |
continue; |
227 |
} |
|
228 |
if (s.equals("mixed")) { |
|
229 |
newArgs.add("-m"); |
|
230 |
continue; |
|
231 |
} |
|
232 |
if (s.equals("locks")) { |
|
233 |
newArgs.add("-l"); |
|
234 |
continue; |
|
235 |
} |
|
236 |
} |
|
237 |
||
37445
5565e6e80352
8152435: (CL)HSDB should be started with no argument
ysuenaga
parents:
37177
diff
changeset
|
238 |
buildAttachArgs(newArgs, pid, exe, core, false); |
31978 | 239 |
JStack.main(newArgs.toArray(new String[newArgs.size()])); |
240 |
} |
|
241 |
||
242 |
private static void runJMAP(String[] oldArgs) { |
|
243 |
SAGetopt sg = new SAGetopt(oldArgs); |
|
244 |
String[] longOpts = {"exe=", "core=", "pid=", |
|
38264 | 245 |
"heap", "binaryheap", "dumpfile=", "histo", "clstats", "finalizerinfo"}; |
31978 | 246 |
|
247 |
ArrayList<String> newArgs = new ArrayList(); |
|
37101
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
248 |
String pid = null; |
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
249 |
String exe = null; |
31978 | 250 |
String core = null; |
251 |
String s = null; |
|
38264 | 252 |
String dumpfile = null; |
253 |
boolean requestHeapdump = false; |
|
31978 | 254 |
|
255 |
while((s = sg.next(null, longOpts)) != null) { |
|
256 |
if (s.equals("exe")) { |
|
37101
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
257 |
exe = sg.getOptarg(); |
31978 | 258 |
continue; |
259 |
} |
|
260 |
if (s.equals("core")) { |
|
261 |
core = sg.getOptarg(); |
|
262 |
continue; |
|
263 |
} |
|
264 |
if (s.equals("pid")) { |
|
37101
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
265 |
pid = sg.getOptarg(); |
31978 | 266 |
continue; |
267 |
} |
|
268 |
if (s.equals("heap")) { |
|
269 |
newArgs.add("-heap"); |
|
270 |
continue; |
|
271 |
} |
|
272 |
if (s.equals("binaryheap")) { |
|
38264 | 273 |
requestHeapdump = true; |
274 |
continue; |
|
275 |
} |
|
276 |
if (s.equals("dumpfile")) { |
|
277 |
dumpfile = sg.getOptarg(); |
|
31978 | 278 |
continue; |
279 |
} |
|
280 |
if (s.equals("histo")) { |
|
281 |
newArgs.add("-histo"); |
|
282 |
continue; |
|
283 |
} |
|
284 |
if (s.equals("clstats")) { |
|
285 |
newArgs.add("-clstats"); |
|
286 |
continue; |
|
287 |
} |
|
288 |
if (s.equals("finalizerinfo")) { |
|
289 |
newArgs.add("-finalizerinfo"); |
|
290 |
continue; |
|
291 |
} |
|
292 |
} |
|
293 |
||
38264 | 294 |
if (!requestHeapdump && (dumpfile != null)) { |
295 |
throw new IllegalArgumentException("Unexpected argument dumpfile"); |
|
296 |
} |
|
297 |
if (requestHeapdump) { |
|
298 |
if (dumpfile == null) { |
|
299 |
newArgs.add("-heap:format=b"); |
|
300 |
} else { |
|
301 |
newArgs.add("-heap:format=b,file=" + dumpfile); |
|
302 |
} |
|
303 |
} |
|
304 |
||
37445
5565e6e80352
8152435: (CL)HSDB should be started with no argument
ysuenaga
parents:
37177
diff
changeset
|
305 |
buildAttachArgs(newArgs, pid, exe, core, false); |
31978 | 306 |
JMap.main(newArgs.toArray(new String[newArgs.size()])); |
307 |
} |
|
308 |
||
309 |
private static void runJINFO(String[] oldArgs) { |
|
310 |
SAGetopt sg = new SAGetopt(oldArgs); |
|
311 |
String[] longOpts = {"exe=", "core=", "pid=", |
|
312 |
"flags", "sysprops"}; |
|
313 |
||
314 |
ArrayList<String> newArgs = new ArrayList(); |
|
37101
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
315 |
String exe = null; |
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
316 |
String pid = null; |
31978 | 317 |
String core = null; |
318 |
String s = null; |
|
319 |
||
320 |
while((s = sg.next(null, longOpts)) != null) { |
|
321 |
if (s.equals("exe")) { |
|
37101
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
322 |
exe = sg.getOptarg(); |
31978 | 323 |
continue; |
324 |
} |
|
325 |
if (s.equals("core")) { |
|
326 |
core = sg.getOptarg(); |
|
327 |
continue; |
|
328 |
} |
|
329 |
if (s.equals("pid")) { |
|
37101
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
330 |
pid = sg.getOptarg(); |
31978 | 331 |
continue; |
332 |
} |
|
333 |
if (s.equals("flags")) { |
|
334 |
newArgs.add("-flags"); |
|
335 |
continue; |
|
336 |
} |
|
337 |
if (s.equals("sysprops")) { |
|
338 |
newArgs.add("-sysprops"); |
|
339 |
continue; |
|
340 |
} |
|
341 |
} |
|
342 |
||
37445
5565e6e80352
8152435: (CL)HSDB should be started with no argument
ysuenaga
parents:
37177
diff
changeset
|
343 |
buildAttachArgs(newArgs, pid, exe, core, false); |
31978 | 344 |
JInfo.main(newArgs.toArray(new String[newArgs.size()])); |
345 |
} |
|
346 |
||
37090 | 347 |
private static void runJSNAP(String[] oldArgs) { |
348 |
SAGetopt sg = new SAGetopt(oldArgs); |
|
37177 | 349 |
String[] longOpts = {"exe=", "core=", "pid=", "all"}; |
37090 | 350 |
|
351 |
ArrayList<String> newArgs = new ArrayList(); |
|
37101
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
352 |
String exe = null; |
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
353 |
String pid = null; |
37090 | 354 |
String core = null; |
355 |
String s = null; |
|
356 |
||
357 |
while((s = sg.next(null, longOpts)) != null) { |
|
358 |
if (s.equals("exe")) { |
|
37101
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
359 |
exe = sg.getOptarg(); |
37090 | 360 |
continue; |
361 |
} |
|
362 |
if (s.equals("core")) { |
|
363 |
core = sg.getOptarg(); |
|
364 |
continue; |
|
365 |
} |
|
366 |
if (s.equals("pid")) { |
|
37101
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
367 |
pid = sg.getOptarg(); |
37090 | 368 |
continue; |
369 |
} |
|
37177 | 370 |
if (s.equals("all")) { |
371 |
newArgs.add("-a"); |
|
372 |
continue; |
|
373 |
} |
|
37090 | 374 |
} |
375 |
||
37445
5565e6e80352
8152435: (CL)HSDB should be started with no argument
ysuenaga
parents:
37177
diff
changeset
|
376 |
buildAttachArgs(newArgs, pid, exe, core, false); |
37090 | 377 |
JSnap.main(newArgs.toArray(new String[newArgs.size()])); |
378 |
} |
|
379 |
||
31978 | 380 |
public static void main(String[] args) { |
381 |
// Provide a help |
|
382 |
if (args.length == 0) { |
|
383 |
launcherHelp(); |
|
384 |
return; |
|
385 |
} |
|
386 |
// No arguments imply help for jstack, jmap, jinfo but launch clhsdb and hsdb |
|
387 |
if (args.length == 1 && !args[0].equals("clhsdb") && !args[0].equals("hsdb")) { |
|
388 |
toolHelp(args[0]); |
|
389 |
return; |
|
390 |
} |
|
391 |
||
392 |
for (String arg : args) { |
|
393 |
if (arg.equals("-h") || arg.equals("-help") || arg.equals("--help")) { |
|
394 |
toolHelp(args[0]); |
|
395 |
return; |
|
396 |
} |
|
397 |
} |
|
398 |
||
399 |
String[] oldArgs = Arrays.copyOfRange(args, 1, args.length); |
|
400 |
||
37101
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
401 |
try { |
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
402 |
// Run SA interactive mode |
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
403 |
if (args[0].equals("clhsdb")) { |
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
404 |
runCLHSDB(oldArgs); |
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
405 |
return; |
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
406 |
} |
31978 | 407 |
|
37101
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
408 |
if (args[0].equals("hsdb")) { |
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
409 |
runHSDB(oldArgs); |
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
410 |
return; |
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
411 |
} |
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
412 |
|
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
413 |
// Run SA tmtools mode |
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
414 |
if (args[0].equals("jstack")) { |
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
415 |
runJSTACK(oldArgs); |
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
416 |
return; |
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
417 |
} |
31978 | 418 |
|
37101
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
419 |
if (args[0].equals("jmap")) { |
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
420 |
runJMAP(oldArgs); |
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
421 |
return; |
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
422 |
} |
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
423 |
|
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
424 |
if (args[0].equals("jinfo")) { |
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
425 |
runJINFO(oldArgs); |
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
426 |
return; |
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
427 |
} |
31978 | 428 |
|
37101
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
429 |
if (args[0].equals("jsnap")) { |
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
430 |
runJSNAP(oldArgs); |
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
431 |
return; |
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
432 |
} |
31978 | 433 |
|
37445
5565e6e80352
8152435: (CL)HSDB should be started with no argument
ysuenaga
parents:
37177
diff
changeset
|
434 |
throw new SAGetoptException("Unknown tool: " + args[0]); |
5565e6e80352
8152435: (CL)HSDB should be started with no argument
ysuenaga
parents:
37177
diff
changeset
|
435 |
} catch (SAGetoptException e) { |
37101
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
436 |
System.err.println(e.getMessage()); |
496308fe87f1
8151709: jhsdb should show help message in SALauncher.
ysuenaga
parents:
37090
diff
changeset
|
437 |
toolHelp(args[0]); |
37090 | 438 |
} |
31978 | 439 |
} |
440 |
} |