Merge
This commit is contained in:
commit
df1294ed41
@ -26,7 +26,6 @@
|
|||||||
package sun.tools.jinfo;
|
package sun.tools.jinfo;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
@ -44,7 +43,7 @@ public class JInfo {
|
|||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
usage(); // no arguments
|
usage(1); // no arguments
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean useSA = true;
|
boolean useSA = true;
|
||||||
@ -56,14 +55,20 @@ public class JInfo {
|
|||||||
// (<executable> and <code file>). So, total
|
// (<executable> and <code file>). So, total
|
||||||
// argument count including option has to 2 or 3.
|
// argument count including option has to 2 or 3.
|
||||||
if (args.length != 2 && args.length != 3) {
|
if (args.length != 2 && args.length != 3) {
|
||||||
usage();
|
usage(1);
|
||||||
}
|
}
|
||||||
} else if (arg1.equals("-flag")) {
|
} else if (arg1.equals("-flag")) {
|
||||||
// do not use SA, use attach-on-demand
|
// do not use SA, use attach-on-demand
|
||||||
useSA = false;
|
useSA = false;
|
||||||
} else {
|
} else {
|
||||||
// unknown option or -h or -help, print help
|
// unknown option or -h or -help, print help
|
||||||
usage();
|
int exit;
|
||||||
|
if (arg1.equals("-help") || arg1.equals("-h")) {
|
||||||
|
exit = 0;
|
||||||
|
} else {
|
||||||
|
exit = 1;
|
||||||
|
}
|
||||||
|
usage(exit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +80,13 @@ public class JInfo {
|
|||||||
String option = args[1];
|
String option = args[1];
|
||||||
flag(pid, option);
|
flag(pid, option);
|
||||||
} else {
|
} else {
|
||||||
usage();
|
int exit;
|
||||||
|
if (arg1.equals("-help") || arg1.equals("-h")) {
|
||||||
|
exit = 0;
|
||||||
|
} else {
|
||||||
|
exit = 1;
|
||||||
|
}
|
||||||
|
usage(exit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -86,7 +97,7 @@ public class JInfo {
|
|||||||
// Tool not available on this platform.
|
// Tool not available on this platform.
|
||||||
Class<?> c = loadClass(tool);
|
Class<?> c = loadClass(tool);
|
||||||
if (c == null) {
|
if (c == null) {
|
||||||
usage();
|
usage(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// invoke the main method with the arguments
|
// invoke the main method with the arguments
|
||||||
@ -176,39 +187,39 @@ public class JInfo {
|
|||||||
|
|
||||||
|
|
||||||
// print usage message
|
// print usage message
|
||||||
private static void usage() {
|
private static void usage(int exit) {
|
||||||
|
|
||||||
Class<?> c = loadClass("sun.jvm.hotspot.tools.JInfo");
|
Class<?> c = loadClass("sun.jvm.hotspot.tools.JInfo");
|
||||||
boolean usageSA = (c != null);
|
boolean usageSA = (c != null);
|
||||||
|
|
||||||
System.out.println("Usage:");
|
System.err.println("Usage:");
|
||||||
if (usageSA) {
|
if (usageSA) {
|
||||||
System.out.println(" jinfo [option] <pid>");
|
System.err.println(" jinfo [option] <pid>");
|
||||||
System.out.println(" (to connect to running process)");
|
System.err.println(" (to connect to running process)");
|
||||||
System.out.println(" jinfo [option] <executable <core>");
|
System.err.println(" jinfo [option] <executable <core>");
|
||||||
System.out.println(" (to connect to a core file)");
|
System.err.println(" (to connect to a core file)");
|
||||||
System.out.println(" jinfo [option] [server_id@]<remote server IP or hostname>");
|
System.err.println(" jinfo [option] [server_id@]<remote server IP or hostname>");
|
||||||
System.out.println(" (to connect to remote debug server)");
|
System.err.println(" (to connect to remote debug server)");
|
||||||
System.out.println("");
|
System.err.println("");
|
||||||
System.out.println("where <option> is one of:");
|
System.err.println("where <option> is one of:");
|
||||||
System.out.println(" -flag <name> to print the value of the named VM flag");
|
System.err.println(" -flag <name> to print the value of the named VM flag");
|
||||||
System.out.println(" -flag [+|-]<name> to enable or disable the named VM flag");
|
System.err.println(" -flag [+|-]<name> to enable or disable the named VM flag");
|
||||||
System.out.println(" -flag <name>=<value> to set the named VM flag to the given value");
|
System.err.println(" -flag <name>=<value> to set the named VM flag to the given value");
|
||||||
System.out.println(" -flags to print VM flags");
|
System.err.println(" -flags to print VM flags");
|
||||||
System.out.println(" -sysprops to print Java system properties");
|
System.err.println(" -sysprops to print Java system properties");
|
||||||
System.out.println(" <no option> to print both of the above");
|
System.err.println(" <no option> to print both of the above");
|
||||||
System.out.println(" -h | -help to print this help message");
|
System.err.println(" -h | -help to print this help message");
|
||||||
} else {
|
} else {
|
||||||
System.out.println(" jinfo <option> <pid>");
|
System.err.println(" jinfo <option> <pid>");
|
||||||
System.out.println(" (to connect to a running process)");
|
System.err.println(" (to connect to a running process)");
|
||||||
System.out.println("");
|
System.err.println("");
|
||||||
System.out.println("where <option> is one of:");
|
System.err.println("where <option> is one of:");
|
||||||
System.out.println(" -flag <name> to print the value of the named VM flag");
|
System.err.println(" -flag <name> to print the value of the named VM flag");
|
||||||
System.out.println(" -flag [+|-]<name> to enable or disable the named VM flag");
|
System.err.println(" -flag [+|-]<name> to enable or disable the named VM flag");
|
||||||
System.out.println(" -flag <name>=<value> to set the named VM flag to the given value");
|
System.err.println(" -flag <name>=<value> to set the named VM flag to the given value");
|
||||||
System.out.println(" -h | -help to print this help message");
|
System.err.println(" -h | -help to print this help message");
|
||||||
}
|
}
|
||||||
|
|
||||||
System.exit(1);
|
System.exit(exit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ public class JMap {
|
|||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
usage(); // no arguments
|
usage(1); // no arguments
|
||||||
}
|
}
|
||||||
|
|
||||||
// used to indicate if we should use SA
|
// used to indicate if we should use SA
|
||||||
@ -77,11 +77,13 @@ public class JMap {
|
|||||||
if (!arg.startsWith("-")) {
|
if (!arg.startsWith("-")) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (arg.equals(FORCE_SA_OPTION)) {
|
if (arg.equals("-help") || arg.equals("-h")) {
|
||||||
|
usage(0);
|
||||||
|
} else if (arg.equals(FORCE_SA_OPTION)) {
|
||||||
useSA = true;
|
useSA = true;
|
||||||
} else {
|
} else {
|
||||||
if (option != null) {
|
if (option != null) {
|
||||||
usage(); // option already specified
|
usage(1); // option already specified
|
||||||
}
|
}
|
||||||
option = arg;
|
option = arg;
|
||||||
}
|
}
|
||||||
@ -101,7 +103,7 @@ public class JMap {
|
|||||||
// only one parameter (the process-id)
|
// only one parameter (the process-id)
|
||||||
int paramCount = args.length - optionCount;
|
int paramCount = args.length - optionCount;
|
||||||
if (paramCount == 0 || paramCount > 2) {
|
if (paramCount == 0 || paramCount > 2) {
|
||||||
usage();
|
usage(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (optionCount == 0 || paramCount != 1) {
|
if (optionCount == 0 || paramCount != 1) {
|
||||||
@ -139,7 +141,7 @@ public class JMap {
|
|||||||
} else if (option.startsWith(DUMP_OPTION_PREFIX)) {
|
} else if (option.startsWith(DUMP_OPTION_PREFIX)) {
|
||||||
dump(pid, option);
|
dump(pid, option);
|
||||||
} else {
|
} else {
|
||||||
usage();
|
usage(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -161,7 +163,9 @@ public class JMap {
|
|||||||
if (option.startsWith(DUMP_OPTION_PREFIX)) {
|
if (option.startsWith(DUMP_OPTION_PREFIX)) {
|
||||||
// first check that the option can be parsed
|
// first check that the option can be parsed
|
||||||
String fn = parseDumpOptions(option);
|
String fn = parseDumpOptions(option);
|
||||||
if (fn == null) usage();
|
if (fn == null) {
|
||||||
|
usage(1);
|
||||||
|
}
|
||||||
|
|
||||||
// tool for heap dumping
|
// tool for heap dumping
|
||||||
tool = "sun.jvm.hotspot.tools.HeapDumper";
|
tool = "sun.jvm.hotspot.tools.HeapDumper";
|
||||||
@ -180,13 +184,13 @@ public class JMap {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (tool == null) {
|
if (tool == null) {
|
||||||
usage(); // no mapping to tool
|
usage(1); // no mapping to tool
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tool not available on this platform.
|
// Tool not available on this platform.
|
||||||
Class<?> c = loadClass(tool);
|
Class<?> c = loadClass(tool);
|
||||||
if (c == null) {
|
if (c == null) {
|
||||||
usage();
|
usage(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// invoke the main method with the arguments
|
// invoke the main method with the arguments
|
||||||
@ -225,7 +229,7 @@ public class JMap {
|
|||||||
// parse the options to get the dump filename
|
// parse the options to get the dump filename
|
||||||
String filename = parseDumpOptions(options);
|
String filename = parseDumpOptions(options);
|
||||||
if (filename == null) {
|
if (filename == null) {
|
||||||
usage(); // invalid options or no filename
|
usage(1); // invalid options or no filename
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the canonical path - important to avoid just passing
|
// get the canonical path - important to avoid just passing
|
||||||
@ -341,49 +345,49 @@ public class JMap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// print usage message
|
// print usage message
|
||||||
private static void usage() {
|
private static void usage(int exit) {
|
||||||
System.out.println("Usage:");
|
System.err.println("Usage:");
|
||||||
if (haveSA()) {
|
if (haveSA()) {
|
||||||
System.out.println(" jmap [option] <pid>");
|
System.err.println(" jmap [option] <pid>");
|
||||||
System.out.println(" (to connect to running process)");
|
System.err.println(" (to connect to running process)");
|
||||||
System.out.println(" jmap [option] <executable <core>");
|
System.err.println(" jmap [option] <executable <core>");
|
||||||
System.out.println(" (to connect to a core file)");
|
System.err.println(" (to connect to a core file)");
|
||||||
System.out.println(" jmap [option] [server_id@]<remote server IP or hostname>");
|
System.err.println(" jmap [option] [server_id@]<remote server IP or hostname>");
|
||||||
System.out.println(" (to connect to remote debug server)");
|
System.err.println(" (to connect to remote debug server)");
|
||||||
System.out.println("");
|
System.err.println("");
|
||||||
System.out.println("where <option> is one of:");
|
System.err.println("where <option> is one of:");
|
||||||
System.out.println(" <none> to print same info as Solaris pmap");
|
System.err.println(" <none> to print same info as Solaris pmap");
|
||||||
System.out.println(" -heap to print java heap summary");
|
System.err.println(" -heap to print java heap summary");
|
||||||
System.out.println(" -histo[:live] to print histogram of java object heap; if the \"live\"");
|
System.err.println(" -histo[:live] to print histogram of java object heap; if the \"live\"");
|
||||||
System.out.println(" suboption is specified, only count live objects");
|
System.err.println(" suboption is specified, only count live objects");
|
||||||
System.out.println(" -clstats to print class loader statistics");
|
System.err.println(" -clstats to print class loader statistics");
|
||||||
System.out.println(" -finalizerinfo to print information on objects awaiting finalization");
|
System.err.println(" -finalizerinfo to print information on objects awaiting finalization");
|
||||||
System.out.println(" -dump:<dump-options> to dump java heap in hprof binary format");
|
System.err.println(" -dump:<dump-options> to dump java heap in hprof binary format");
|
||||||
System.out.println(" dump-options:");
|
System.err.println(" dump-options:");
|
||||||
System.out.println(" live dump only live objects; if not specified,");
|
System.err.println(" live dump only live objects; if not specified,");
|
||||||
System.out.println(" all objects in the heap are dumped.");
|
System.err.println(" all objects in the heap are dumped.");
|
||||||
System.out.println(" format=b binary format");
|
System.err.println(" format=b binary format");
|
||||||
System.out.println(" file=<file> dump heap to <file>");
|
System.err.println(" file=<file> dump heap to <file>");
|
||||||
System.out.println(" Example: jmap -dump:live,format=b,file=heap.bin <pid>");
|
System.err.println(" Example: jmap -dump:live,format=b,file=heap.bin <pid>");
|
||||||
System.out.println(" -F force. Use with -dump:<dump-options> <pid> or -histo");
|
System.err.println(" -F force. Use with -dump:<dump-options> <pid> or -histo");
|
||||||
System.out.println(" to force a heap dump or histogram when <pid> does not");
|
System.err.println(" to force a heap dump or histogram when <pid> does not");
|
||||||
System.out.println(" respond. The \"live\" suboption is not supported");
|
System.err.println(" respond. The \"live\" suboption is not supported");
|
||||||
System.out.println(" in this mode.");
|
System.err.println(" in this mode.");
|
||||||
System.out.println(" -h | -help to print this help message");
|
System.err.println(" -h | -help to print this help message");
|
||||||
System.out.println(" -J<flag> to pass <flag> directly to the runtime system");
|
System.err.println(" -J<flag> to pass <flag> directly to the runtime system");
|
||||||
} else {
|
} else {
|
||||||
System.out.println(" jmap -histo <pid>");
|
System.err.println(" jmap -histo <pid>");
|
||||||
System.out.println(" (to connect to running process and print histogram of java object heap");
|
System.err.println(" (to connect to running process and print histogram of java object heap");
|
||||||
System.out.println(" jmap -dump:<dump-options> <pid>");
|
System.err.println(" jmap -dump:<dump-options> <pid>");
|
||||||
System.out.println(" (to connect to running process and dump java heap)");
|
System.err.println(" (to connect to running process and dump java heap)");
|
||||||
System.out.println("");
|
System.err.println("");
|
||||||
System.out.println(" dump-options:");
|
System.err.println(" dump-options:");
|
||||||
System.out.println(" format=b binary default");
|
System.err.println(" format=b binary default");
|
||||||
System.out.println(" file=<file> dump heap to <file>");
|
System.err.println(" file=<file> dump heap to <file>");
|
||||||
System.out.println("");
|
System.err.println("");
|
||||||
System.out.println(" Example: jmap -dump:format=b,file=heap.bin <pid>");
|
System.err.println(" Example: jmap -dump:format=b,file=heap.bin <pid>");
|
||||||
}
|
}
|
||||||
|
|
||||||
System.exit(1);
|
System.exit(exit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,11 +45,11 @@ public class Jps {
|
|||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
System.err.println(e.getMessage());
|
System.err.println(e.getMessage());
|
||||||
Arguments.printUsage(System.err);
|
Arguments.printUsage(System.err);
|
||||||
return;
|
System.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arguments.isHelp()) {
|
if (arguments.isHelp()) {
|
||||||
Arguments.printUsage(System.out);
|
Arguments.printUsage(System.err);
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,6 +165,7 @@ public class Jps {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
System.exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ import sun.tools.attach.HotSpotVirtualMachine;
|
|||||||
public class JStack {
|
public class JStack {
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
usage(); // no arguments
|
usage(1); // no arguments
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean useSA = false;
|
boolean useSA = false;
|
||||||
@ -56,16 +56,20 @@ public class JStack {
|
|||||||
if (!arg.startsWith("-")) {
|
if (!arg.startsWith("-")) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (arg.equals("-F")) {
|
if (arg.equals("-help") || arg.equals("-h")) {
|
||||||
|
usage(0);
|
||||||
|
}
|
||||||
|
else if (arg.equals("-F")) {
|
||||||
useSA = true;
|
useSA = true;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
if (arg.equals("-m")) {
|
if (arg.equals("-m")) {
|
||||||
mixed = true;
|
mixed = true;
|
||||||
} else {
|
} else {
|
||||||
if (arg.equals("-l")) {
|
if (arg.equals("-l")) {
|
||||||
locks = true;
|
locks = true;
|
||||||
} else {
|
} else {
|
||||||
usage();
|
usage(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -81,7 +85,7 @@ public class JStack {
|
|||||||
// we assume core file and executable so we use SA.
|
// we assume core file and executable so we use SA.
|
||||||
int paramCount = args.length - optionCount;
|
int paramCount = args.length - optionCount;
|
||||||
if (paramCount == 0 || paramCount > 2) {
|
if (paramCount == 0 || paramCount > 2) {
|
||||||
usage();
|
usage(1);
|
||||||
}
|
}
|
||||||
if (paramCount == 2) {
|
if (paramCount == 2) {
|
||||||
useSA = true;
|
useSA = true;
|
||||||
@ -118,7 +122,7 @@ public class JStack {
|
|||||||
private static void runJStackTool(boolean mixed, boolean locks, String args[]) throws Exception {
|
private static void runJStackTool(boolean mixed, boolean locks, String args[]) throws Exception {
|
||||||
Class<?> cl = loadSAClass();
|
Class<?> cl = loadSAClass();
|
||||||
if (cl == null) {
|
if (cl == null) {
|
||||||
usage(); // SA not available
|
usage(1); // SA not available
|
||||||
}
|
}
|
||||||
|
|
||||||
// JStack tool also takes -m and -l arguments
|
// JStack tool also takes -m and -l arguments
|
||||||
@ -199,31 +203,31 @@ public class JStack {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// print usage message
|
// print usage message
|
||||||
private static void usage() {
|
private static void usage(int exit) {
|
||||||
System.out.println("Usage:");
|
System.err.println("Usage:");
|
||||||
System.out.println(" jstack [-l] <pid>");
|
System.err.println(" jstack [-l] <pid>");
|
||||||
System.out.println(" (to connect to running process)");
|
System.err.println(" (to connect to running process)");
|
||||||
|
|
||||||
if (loadSAClass() != null) {
|
if (loadSAClass() != null) {
|
||||||
System.out.println(" jstack -F [-m] [-l] <pid>");
|
System.err.println(" jstack -F [-m] [-l] <pid>");
|
||||||
System.out.println(" (to connect to a hung process)");
|
System.err.println(" (to connect to a hung process)");
|
||||||
System.out.println(" jstack [-m] [-l] <executable> <core>");
|
System.err.println(" jstack [-m] [-l] <executable> <core>");
|
||||||
System.out.println(" (to connect to a core file)");
|
System.err.println(" (to connect to a core file)");
|
||||||
System.out.println(" jstack [-m] [-l] [server_id@]<remote server IP or hostname>");
|
System.err.println(" jstack [-m] [-l] [server_id@]<remote server IP or hostname>");
|
||||||
System.out.println(" (to connect to a remote debug server)");
|
System.err.println(" (to connect to a remote debug server)");
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("");
|
System.err.println("");
|
||||||
System.out.println("Options:");
|
System.err.println("Options:");
|
||||||
|
|
||||||
if (loadSAClass() != null) {
|
if (loadSAClass() != null) {
|
||||||
System.out.println(" -F to force a thread dump. Use when jstack <pid> does not respond" +
|
System.err.println(" -F to force a thread dump. Use when jstack <pid> does not respond" +
|
||||||
" (process is hung)");
|
" (process is hung)");
|
||||||
System.out.println(" -m to print both java and native frames (mixed mode)");
|
System.err.println(" -m to print both java and native frames (mixed mode)");
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println(" -l long listing. Prints additional information about locks");
|
System.err.println(" -l long listing. Prints additional information about locks");
|
||||||
System.out.println(" -h or -help to print this help message");
|
System.err.println(" -h or -help to print this help message");
|
||||||
System.exit(1);
|
System.exit(exit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user