--- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/SALauncher.java Wed Mar 23 10:31:46 2016 +0100
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/SALauncher.java Wed Mar 23 12:26:14 2016 +0900
@@ -88,7 +88,7 @@
}
private static boolean jsnapHelp() {
- System.out.println(" <no option>\tdump performance counters");
+ System.out.println(" --all\tto print all performance counters");
return commonHelp();
}
@@ -331,7 +331,7 @@
private static void runJSNAP(String[] oldArgs) {
SAGetopt sg = new SAGetopt(oldArgs);
- String[] longOpts = {"exe=", "core=", "pid="};
+ String[] longOpts = {"exe=", "core=", "pid=", "all"};
ArrayList<String> newArgs = new ArrayList();
String exe = null;
@@ -352,6 +352,10 @@
pid = sg.getOptarg();
continue;
}
+ if (s.equals("all")) {
+ newArgs.add("-a");
+ continue;
+ }
}
buildAttachArgs(newArgs, pid, exe, core);
--- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/JSnap.java Wed Mar 23 10:31:46 2016 +0100
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/JSnap.java Wed Mar 23 12:26:14 2016 +0900
@@ -25,11 +25,15 @@
package sun.jvm.hotspot.tools;
import java.io.*;
+import java.util.*;
+import java.util.stream.*;
import sun.jvm.hotspot.debugger.JVMDebugger;
import sun.jvm.hotspot.runtime.*;
public class JSnap extends Tool {
+ private boolean all;
+
public JSnap() {
super();
}
@@ -45,7 +49,7 @@
if (prologue.accessible()) {
PerfMemory.iterate(new PerfMemory.PerfDataEntryVisitor() {
public boolean visit(PerfDataEntry pde) {
- if (pde.supported()) {
+ if (all || pde.supported()) {
out.print(pde.name());
out.print('=');
out.println(pde.valueAsString());
@@ -62,8 +66,24 @@
}
}
+ @Override
+ protected void printFlagsUsage() {
+ System.out.println(" -a\tto print all performance counters");
+ super.printFlagsUsage();
+ }
+
public static void main(String[] args) {
JSnap js = new JSnap();
+ js.all = Arrays.stream(args)
+ .anyMatch(s -> s.equals("-a"));
+
+ if (js.all) {
+ args = Arrays.stream(args)
+ .filter(s -> !s.equals("-a"))
+ .collect(Collectors.toList())
+ .toArray(new String[0]);
+ }
+
js.execute(args);
}
}