equal
deleted
inserted
replaced
46 } |
46 } |
47 |
47 |
48 checkForUnsupportedOptions(args); |
48 checkForUnsupportedOptions(args); |
49 |
49 |
50 boolean locks = false; |
50 boolean locks = false; |
|
51 boolean extended = false; |
51 |
52 |
52 // Parse the options (arguments starting with "-" ) |
53 // Parse the options (arguments starting with "-" ) |
53 int optionCount = 0; |
54 int optionCount = 0; |
54 while (optionCount < args.length) { |
55 while (optionCount < args.length) { |
55 String arg = args[optionCount]; |
56 String arg = args[optionCount]; |
65 } |
66 } |
66 else { |
67 else { |
67 if (arg.equals("-l")) { |
68 if (arg.equals("-l")) { |
68 locks = true; |
69 locks = true; |
69 } else { |
70 } else { |
70 usage(1); |
71 if (arg.equals("-e")) { |
|
72 extended = true; |
|
73 } else { |
|
74 usage(1); |
|
75 } |
71 } |
76 } |
72 } |
77 } |
73 optionCount++; |
78 optionCount++; |
74 } |
79 } |
75 |
80 |
79 usage(1); |
84 usage(1); |
80 } |
85 } |
81 |
86 |
82 // pass -l to thread dump operation to get extra lock info |
87 // pass -l to thread dump operation to get extra lock info |
83 String pidArg = args[optionCount]; |
88 String pidArg = args[optionCount]; |
84 String params[]; |
89 String params[]= new String[] { "" }; |
|
90 if (extended) { |
|
91 params[0] += "-e "; |
|
92 } |
85 if (locks) { |
93 if (locks) { |
86 params = new String[] { "-l" }; |
94 params[0] += "-l"; |
87 } else { |
|
88 params = new String[0]; |
|
89 } |
95 } |
|
96 |
90 ProcessArgumentMatcher ap = new ProcessArgumentMatcher(pidArg); |
97 ProcessArgumentMatcher ap = new ProcessArgumentMatcher(pidArg); |
91 Collection<String> pids = ap.getVirtualMachinePids(JStack.class); |
98 Collection<String> pids = ap.getVirtualMachinePids(JStack.class); |
92 |
99 |
93 if (pids.isEmpty()) { |
100 if (pids.isEmpty()) { |
94 System.err.println("Could not find any processes matching : '" + pidArg + "'"); |
101 System.err.println("Could not find any processes matching : '" + pidArg + "'"); |
168 } |
175 } |
169 |
176 |
170 // print usage message |
177 // print usage message |
171 private static void usage(int exit) { |
178 private static void usage(int exit) { |
172 System.err.println("Usage:"); |
179 System.err.println("Usage:"); |
173 System.err.println(" jstack [-l] <pid>"); |
180 System.err.println(" jstack [-l][-e] <pid>"); |
174 System.err.println(" (to connect to running process)"); |
181 System.err.println(" (to connect to running process)"); |
175 System.err.println(""); |
182 System.err.println(""); |
176 System.err.println("Options:"); |
183 System.err.println("Options:"); |
177 System.err.println(" -l long listing. Prints additional information about locks"); |
184 System.err.println(" -l long listing. Prints additional information about locks"); |
|
185 System.err.println(" -e extended listing. Prints additional information about threads"); |
178 System.err.println(" -? -h --help -help to print this help message"); |
186 System.err.println(" -? -h --help -help to print this help message"); |
179 System.exit(exit); |
187 System.exit(exit); |
180 } |
188 } |
181 } |
189 } |