< prev index next >
src/jdk.jcmd/share/classes/sun/tools/jstack/JStack.java
Print this page
rev 50303 : Thread Dump Extension (memory allocation)
@@ -46,10 +46,11 @@
}
checkForUnsupportedOptions(args);
boolean locks = false;
+ boolean extended = false;
// Parse the options (arguments starting with "-" )
int optionCount = 0;
while (optionCount < args.length) {
String arg = args[optionCount];
@@ -65,13 +66,17 @@
}
else {
if (arg.equals("-l")) {
locks = true;
} else {
+ if (arg.equals("-e")) {
+ extended = true;
+ } else {
usage(1);
}
}
+ }
optionCount++;
}
// Next we check the parameter count.
int paramCount = args.length - optionCount;
@@ -79,16 +84,18 @@
usage(1);
}
// pass -l to thread dump operation to get extra lock info
String pidArg = args[optionCount];
- String params[];
+ String params[]= new String[] { "" };
+ if (extended) {
+ params[0] += "-e ";
+ }
if (locks) {
- params = new String[] { "-l" };
- } else {
- params = new String[0];
+ params[0] += "-l";
}
+
ProcessArgumentMatcher ap = new ProcessArgumentMatcher(pidArg);
Collection<String> pids = ap.getVirtualMachinePids(JStack.class);
if (pids.isEmpty()) {
System.err.println("Could not find any processes matching : '" + pidArg + "'");
@@ -168,14 +175,15 @@
}
// print usage message
private static void usage(int exit) {
System.err.println("Usage:");
- System.err.println(" jstack [-l] <pid>");
+ System.err.println(" jstack [-l][-e] <pid>");
System.err.println(" (to connect to running process)");
System.err.println("");
System.err.println("Options:");
System.err.println(" -l long listing. Prints additional information about locks");
+ System.err.println(" -e extended listing. Prints additional information about threads");
System.err.println(" -? -h --help -help to print this help message");
System.exit(exit);
}
}
< prev index next >