< prev index next >
src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/SALauncher.java
Print this page
*** 43,84 ****
System.out.println(" jinfo --help\tto get more information");
System.out.println(" jsnap --help\tto get more information");
return false;
}
! private static boolean commonHelp(String mode) {
// --pid <pid>
// --exe <exe>
// --core <core>
! System.out.println(" --pid <pid> \tTo attach to and operate on the given live process.");
! System.out.println(" --core <corefile>\tTo operate on the given core file.");
System.out.println(" --exe <executable for corefile>");
System.out.println();
System.out.println(" The --core and --exe options must be set together to give the core");
! System.out.println(" file, and associated executable, to operate on. Otherwise the --pid");
! System.out.println(" option can be set to operate on a live process.");
! System.out.println(" The arguments for --exe and --core can use absolute or relative paths.");
System.out.println();
System.out.println(" Examples: jhsdb " + mode + " --pid 1234");
System.out.println(" or jhsdb " + mode + " --core ./core.1234 --exe ./myexe");
return false;
}
private static boolean debugdHelp() {
// [options] <pid> [server-id]
// [options] <executable> <core> [server-id]
System.out.println(" --serverid <id> \tA unique identifier for this debug server.");
! return commonHelp("debugd");
}
private static boolean jinfoHelp() {
// --flags -> -flags
// --sysprops -> -sysprops
System.out.println(" --flags \tTo print VM flags.");
System.out.println(" --sysprops \tTo print Java System properties.");
System.out.println(" <no option> \tTo print both of the above.");
! return commonHelp("jinfo");
}
private static boolean jmapHelp() {
// --heap -> -heap
// --binaryheap -> -heap:format=b
--- 43,99 ----
System.out.println(" jinfo --help\tto get more information");
System.out.println(" jsnap --help\tto get more information");
return false;
}
! private static boolean commonHelp(String mode, boolean canConnectToRemote) {
// --pid <pid>
// --exe <exe>
// --core <core>
! // --remote <[id@]server>
! System.out.println(" --pid <pid> \tTo attach to and operate on the given");
! System.out.println(" \tlive process.");
! System.out.println(" --core <corefile> \tTo operate on the given core file.");
System.out.println(" --exe <executable for corefile>");
+ if (canConnectToRemote) {
+ System.out.println(" --remote <[id@]server>\tTo operate on the remote debug server.");
+ }
System.out.println();
System.out.println(" The --core and --exe options must be set together to give the core");
! System.out.println(" file, and associated executable, to operate on. They can use");
! System.out.println(" absolute or relative paths.");
! System.out.println(" The --pid option can be set to operate on a live process.");
! if (canConnectToRemote) {
! System.out.println(" The --remote option can be set to operate on a debug server.");
! System.out.println(" <--core --exe> and <--pid> and <--remote> are exclusive.");
! } else {
! System.out.println(" <--core --exe> and <--pid> are exclusive.");
! }
System.out.println();
System.out.println(" Examples: jhsdb " + mode + " --pid 1234");
System.out.println(" or jhsdb " + mode + " --core ./core.1234 --exe ./myexe");
+ if (canConnectToRemote) {
+ System.out.println(" or jhsdb " + mode + " --remote debugserver");
+ System.out.println(" or jhsdb " + mode + " --remote id@debugserver");
+ }
return false;
}
private static boolean debugdHelp() {
// [options] <pid> [server-id]
// [options] <executable> <core> [server-id]
System.out.println(" --serverid <id> \tA unique identifier for this debug server.");
! return commonHelp("debugd", false);
}
private static boolean jinfoHelp() {
// --flags -> -flags
// --sysprops -> -sysprops
System.out.println(" --flags \tTo print VM flags.");
System.out.println(" --sysprops \tTo print Java System properties.");
System.out.println(" <no option> \tTo print both of the above.");
! return commonHelp("jinfo", true);
}
private static boolean jmapHelp() {
// --heap -> -heap
// --binaryheap -> -heap:format=b
*** 87,114 ****
// --finalizerinfo -> -finalizerinfo
System.out.println(" <no option> \tTo print same info as Solaris pmap.");
System.out.println(" --heap \tTo print java heap summary.");
System.out.println(" --binaryheap \tTo dump java heap in hprof binary format.");
! System.out.println(" --dumpfile <name>\tThe name of the dump file.");
System.out.println(" --histo \tTo print histogram of java object heap.");
System.out.println(" --clstats \tTo print class loader statistics.");
System.out.println(" --finalizerinfo \tTo print information on objects awaiting finalization.");
! return commonHelp("jmap");
}
private static boolean jstackHelp() {
// --locks -> -l
// --mixed -> -m
System.out.println(" --locks \tTo print java.util.concurrent locks.");
System.out.println(" --mixed \tTo print both Java and native frames (mixed mode).");
! return commonHelp("jstack");
}
private static boolean jsnapHelp() {
System.out.println(" --all \tTo print all performance counters.");
! return commonHelp("jsnap");
}
private static boolean toolHelp(String toolName) {
if (toolName.equals("jstack")) {
return jstackHelp();
--- 102,129 ----
// --finalizerinfo -> -finalizerinfo
System.out.println(" <no option> \tTo print same info as Solaris pmap.");
System.out.println(" --heap \tTo print java heap summary.");
System.out.println(" --binaryheap \tTo dump java heap in hprof binary format.");
! System.out.println(" --dumpfile <name> \tThe name of the dump file.");
System.out.println(" --histo \tTo print histogram of java object heap.");
System.out.println(" --clstats \tTo print class loader statistics.");
System.out.println(" --finalizerinfo \tTo print information on objects awaiting finalization.");
! return commonHelp("jmap", true);
}
private static boolean jstackHelp() {
// --locks -> -l
// --mixed -> -m
System.out.println(" --locks \tTo print java.util.concurrent locks.");
System.out.println(" --mixed \tTo print both Java and native frames (mixed mode).");
! return commonHelp("jstack", true);
}
private static boolean jsnapHelp() {
System.out.println(" --all \tTo print all performance counters.");
! return commonHelp("jsnap", true);
}
private static boolean toolHelp(String toolName) {
if (toolName.equals("jstack")) {
return jstackHelp();
*** 124,169 ****
}
if (toolName.equals("debugd")) {
return debugdHelp();
}
if (toolName.equals("hsdb")) {
! return commonHelp("hsdb");
}
if (toolName.equals("clhsdb")) {
! return commonHelp("clhsdb");
}
return launcherHelp();
}
private static void buildAttachArgs(ArrayList<String> newArgs, String pid,
! String exe, String core, boolean allowEmpty) {
! if (!allowEmpty && (pid == null) && (exe == null)) {
! throw new SAGetoptException("You have to set --pid or --exe.");
}
if (pid != null) { // Attach to live process
if (exe != null) {
throw new SAGetoptException("Unnecessary argument: --exe");
} else if (core != null) {
throw new SAGetoptException("Unnecessary argument: --core");
} else if (!pid.matches("^\\d+$")) {
throw new SAGetoptException("Invalid pid: " + pid);
}
newArgs.add(pid);
} else if (exe != null) {
! if (exe.length() == 0) {
throw new SAGetoptException("You have to set --exe.");
}
newArgs.add(exe);
if ((core == null) || (core.length() == 0)) {
throw new SAGetoptException("You have to set --core.");
}
newArgs.add(core);
}
}
private static void runCLHSDB(String[] oldArgs) {
SAGetopt sg = new SAGetopt(oldArgs);
--- 139,190 ----
}
if (toolName.equals("debugd")) {
return debugdHelp();
}
if (toolName.equals("hsdb")) {
! return commonHelp("hsdb", false);
}
if (toolName.equals("clhsdb")) {
! return commonHelp("clhsdb", false);
}
return launcherHelp();
}
private static void buildAttachArgs(ArrayList<String> newArgs, String pid,
! String exe, String core, String remote, boolean allowEmpty) {
! if (!allowEmpty && (pid == null) && (exe == null) && (remote == null)) {
! throw new SAGetoptException("You have to set --pid or --exe or --remote.");
}
if (pid != null) { // Attach to live process
if (exe != null) {
throw new SAGetoptException("Unnecessary argument: --exe");
} else if (core != null) {
throw new SAGetoptException("Unnecessary argument: --core");
+ } else if (remote != null) {
+ throw new SAGetoptException("Unnecessary argument: --remote");
} else if (!pid.matches("^\\d+$")) {
throw new SAGetoptException("Invalid pid: " + pid);
}
newArgs.add(pid);
} else if (exe != null) {
! if (remote != null) {
! throw new SAGetoptException("Unnecessary argument: --remote");
! } else if (exe.length() == 0) {
throw new SAGetoptException("You have to set --exe.");
}
newArgs.add(exe);
if ((core == null) || (core.length() == 0)) {
throw new SAGetoptException("You have to set --core.");
}
newArgs.add(core);
+ } else if (remote != null) {
+ newArgs.add(remote);
}
}
private static void runCLHSDB(String[] oldArgs) {
SAGetopt sg = new SAGetopt(oldArgs);
*** 188,198 ****
pid = sg.getOptarg();
continue;
}
}
! buildAttachArgs(newArgs, pid, exe, core, true);
CLHSDB.main(newArgs.toArray(new String[newArgs.size()]));
}
private static void runHSDB(String[] oldArgs) {
SAGetopt sg = new SAGetopt(oldArgs);
--- 209,219 ----
pid = sg.getOptarg();
continue;
}
}
! buildAttachArgs(newArgs, pid, exe, core, null, true);
CLHSDB.main(newArgs.toArray(new String[newArgs.size()]));
}
private static void runHSDB(String[] oldArgs) {
SAGetopt sg = new SAGetopt(oldArgs);
*** 217,239 ****
pid = sg.getOptarg();
continue;
}
}
! buildAttachArgs(newArgs, pid, exe, core, true);
HSDB.main(newArgs.toArray(new String[newArgs.size()]));
}
private static void runJSTACK(String[] oldArgs) {
SAGetopt sg = new SAGetopt(oldArgs);
! String[] longOpts = {"exe=", "core=", "pid=",
"mixed", "locks"};
ArrayList<String> newArgs = new ArrayList();
String pid = null;
String exe = null;
String core = null;
String s = null;
while((s = sg.next(null, longOpts)) != null) {
if (s.equals("exe")) {
exe = sg.getOptarg();
--- 238,261 ----
pid = sg.getOptarg();
continue;
}
}
! buildAttachArgs(newArgs, pid, exe, core, null, true);
HSDB.main(newArgs.toArray(new String[newArgs.size()]));
}
private static void runJSTACK(String[] oldArgs) {
SAGetopt sg = new SAGetopt(oldArgs);
! String[] longOpts = {"exe=", "core=", "pid=", "remote=",
"mixed", "locks"};
ArrayList<String> newArgs = new ArrayList();
String pid = null;
String exe = null;
String core = null;
+ String remote = null;
String s = null;
while((s = sg.next(null, longOpts)) != null) {
if (s.equals("exe")) {
exe = sg.getOptarg();
*** 245,278 ****
}
if (s.equals("pid")) {
pid = sg.getOptarg();
continue;
}
if (s.equals("mixed")) {
newArgs.add("-m");
continue;
}
if (s.equals("locks")) {
newArgs.add("-l");
continue;
}
}
! buildAttachArgs(newArgs, pid, exe, core, false);
JStack jstack = new JStack(false, false);
jstack.runWithArgs(newArgs.toArray(new String[newArgs.size()]));
}
private static void runJMAP(String[] oldArgs) {
SAGetopt sg = new SAGetopt(oldArgs);
! String[] longOpts = {"exe=", "core=", "pid=",
"heap", "binaryheap", "dumpfile=", "histo", "clstats", "finalizerinfo"};
ArrayList<String> newArgs = new ArrayList();
String pid = null;
String exe = null;
String core = null;
String s = null;
String dumpfile = null;
boolean requestHeapdump = false;
while((s = sg.next(null, longOpts)) != null) {
--- 267,305 ----
}
if (s.equals("pid")) {
pid = sg.getOptarg();
continue;
}
+ if (s.equals("remote")) {
+ remote = sg.getOptarg();
+ continue;
+ }
if (s.equals("mixed")) {
newArgs.add("-m");
continue;
}
if (s.equals("locks")) {
newArgs.add("-l");
continue;
}
}
! buildAttachArgs(newArgs, pid, exe, core, remote, false);
JStack jstack = new JStack(false, false);
jstack.runWithArgs(newArgs.toArray(new String[newArgs.size()]));
}
private static void runJMAP(String[] oldArgs) {
SAGetopt sg = new SAGetopt(oldArgs);
! String[] longOpts = {"exe=", "core=", "pid=", "remote=",
"heap", "binaryheap", "dumpfile=", "histo", "clstats", "finalizerinfo"};
ArrayList<String> newArgs = new ArrayList();
String pid = null;
String exe = null;
String core = null;
+ String remote = null;
String s = null;
String dumpfile = null;
boolean requestHeapdump = false;
while((s = sg.next(null, longOpts)) != null) {
*** 286,295 ****
--- 313,326 ----
}
if (s.equals("pid")) {
pid = sg.getOptarg();
continue;
}
+ if (s.equals("remote")) {
+ remote = sg.getOptarg();
+ continue;
+ }
if (s.equals("heap")) {
newArgs.add("-heap");
continue;
}
if (s.equals("binaryheap")) {
*** 323,345 ****
} else {
newArgs.add("-heap:format=b,file=" + dumpfile);
}
}
! buildAttachArgs(newArgs, pid, exe, core, false);
JMap.main(newArgs.toArray(new String[newArgs.size()]));
}
private static void runJINFO(String[] oldArgs) {
SAGetopt sg = new SAGetopt(oldArgs);
! String[] longOpts = {"exe=", "core=", "pid=",
"flags", "sysprops"};
ArrayList<String> newArgs = new ArrayList();
String exe = null;
String pid = null;
String core = null;
String s = null;
while((s = sg.next(null, longOpts)) != null) {
if (s.equals("exe")) {
exe = sg.getOptarg();
--- 354,377 ----
} else {
newArgs.add("-heap:format=b,file=" + dumpfile);
}
}
! buildAttachArgs(newArgs, pid, exe, core, remote, false);
JMap.main(newArgs.toArray(new String[newArgs.size()]));
}
private static void runJINFO(String[] oldArgs) {
SAGetopt sg = new SAGetopt(oldArgs);
! String[] longOpts = {"exe=", "core=", "pid=", "remote=",
"flags", "sysprops"};
ArrayList<String> newArgs = new ArrayList();
String exe = null;
String pid = null;
String core = null;
+ String remote = null;
String s = null;
while((s = sg.next(null, longOpts)) != null) {
if (s.equals("exe")) {
exe = sg.getOptarg();
*** 351,382 ****
}
if (s.equals("pid")) {
pid = sg.getOptarg();
continue;
}
if (s.equals("flags")) {
newArgs.add("-flags");
continue;
}
if (s.equals("sysprops")) {
newArgs.add("-sysprops");
continue;
}
}
! buildAttachArgs(newArgs, pid, exe, core, false);
JInfo.main(newArgs.toArray(new String[newArgs.size()]));
}
private static void runJSNAP(String[] oldArgs) {
SAGetopt sg = new SAGetopt(oldArgs);
! String[] longOpts = {"exe=", "core=", "pid=", "all"};
ArrayList<String> newArgs = new ArrayList();
String exe = null;
String pid = null;
String core = null;
String s = null;
while((s = sg.next(null, longOpts)) != null) {
if (s.equals("exe")) {
exe = sg.getOptarg();
--- 383,419 ----
}
if (s.equals("pid")) {
pid = sg.getOptarg();
continue;
}
+ if (s.equals("remote")) {
+ remote = sg.getOptarg();
+ continue;
+ }
if (s.equals("flags")) {
newArgs.add("-flags");
continue;
}
if (s.equals("sysprops")) {
newArgs.add("-sysprops");
continue;
}
}
! buildAttachArgs(newArgs, pid, exe, core, remote, false);
JInfo.main(newArgs.toArray(new String[newArgs.size()]));
}
private static void runJSNAP(String[] oldArgs) {
SAGetopt sg = new SAGetopt(oldArgs);
! String[] longOpts = {"exe=", "core=", "pid=", "remote=", "all"};
ArrayList<String> newArgs = new ArrayList();
String exe = null;
String pid = null;
String core = null;
+ String remote = null;
String s = null;
while((s = sg.next(null, longOpts)) != null) {
if (s.equals("exe")) {
exe = sg.getOptarg();
*** 388,404 ****
}
if (s.equals("pid")) {
pid = sg.getOptarg();
continue;
}
if (s.equals("all")) {
newArgs.add("-a");
continue;
}
}
! buildAttachArgs(newArgs, pid, exe, core, false);
JSnap.main(newArgs.toArray(new String[newArgs.size()]));
}
private static void runDEBUGD(String[] oldArgs) {
// By default SA agent classes prefer Windows process debugger
--- 425,445 ----
}
if (s.equals("pid")) {
pid = sg.getOptarg();
continue;
}
+ if (s.equals("remote")) {
+ remote = sg.getOptarg();
+ continue;
+ }
if (s.equals("all")) {
newArgs.add("-a");
continue;
}
}
! buildAttachArgs(newArgs, pid, exe, core, remote, false);
JSnap.main(newArgs.toArray(new String[newArgs.size()]));
}
private static void runDEBUGD(String[] oldArgs) {
// By default SA agent classes prefer Windows process debugger
*** 434,444 ****
serverid = sg.getOptarg();
continue;
}
}
! buildAttachArgs(newArgs, pid, exe, core, false);
if (serverid != null) {
newArgs.add(serverid);
}
// delegate to the actual SA debug server.
--- 475,485 ----
serverid = sg.getOptarg();
continue;
}
}
! buildAttachArgs(newArgs, pid, exe, core, null, false);
if (serverid != null) {
newArgs.add(serverid);
}
// delegate to the actual SA debug server.
< prev index next >