Merge
authordsamersoff
Wed, 23 Mar 2016 17:36:18 +0000
changeset 37178 32d0f7759879
parent 37176 663bdc7d0b86 (current diff)
parent 37177 49d02f305b29 (diff)
child 37179 4dbcb3a642d2
Merge
--- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/SALauncher.java	Wed Mar 23 10:52:35 2016 +0100
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/SALauncher.java	Wed Mar 23 17:36:18 2016 +0000
@@ -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:52:35 2016 +0100
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/JSnap.java	Wed Mar 23 17:36:18 2016 +0000
@@ -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);
     }
 }