< prev index next >

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/SALauncher.java

Print this page

        

@@ -71,10 +71,11 @@
         // --finalizerinfo -> -finalizerinfo
 
         System.out.println("    <no option>\tto print same info as Solaris pmap");
         System.out.println("    --heap\tto print java heap summary");
         System.out.println("    --binaryheap\tto dump java heap in hprof binary format");
+        System.out.println("    --dumpfile\tname of the dump file");
         System.out.println("    --histo\tto print histogram of java object heap");
         System.out.println("    --clstats\tto print class loader statistics");
         System.out.println("    --finalizerinfo\tto print information on objects awaiting finalization");
         return commonHelp();
     }

@@ -239,17 +240,19 @@
     }
 
     private static void runJMAP(String[] oldArgs) {
         SAGetopt sg = new SAGetopt(oldArgs);
         String[] longOpts = {"exe=", "core=", "pid=",
-              "heap", "binaryheap", "histo", "clstats", "finalizerinfo"};
+              "heap", "binaryheap", "dumpfile=", "histo", "clstats", "finalizerinfo"};
 
         ArrayList<String> newArgs = new ArrayList();
         String pid = null;
         String exe = null;
         String core = null;
         String s = null;
+        String dumpfile = null;
+        boolean requestHeapdump = false;
 
         while((s = sg.next(null, longOpts)) != null) {
             if (s.equals("exe")) {
                 exe = sg.getOptarg();
                 continue;

@@ -265,11 +268,15 @@
             if (s.equals("heap")) {
                 newArgs.add("-heap");
                 continue;
             }
             if (s.equals("binaryheap")) {
-                newArgs.add("-heap:format=b");
+                requestHeapdump = true;
+                continue;
+            }
+            if (s.equals("dumpfile")) {
+                dumpfile = sg.getOptarg();
                 continue;
             }
             if (s.equals("histo")) {
                 newArgs.add("-histo");
                 continue;

@@ -282,10 +289,20 @@
                 newArgs.add("-finalizerinfo");
                 continue;
             }
         }
 
+        if (requestHeapdump) {
+            if (dumpfile == null) {
+                newArgs.add("-heap:format=b");
+            } else {
+                newArgs.add("-heap:format=b,file=" + dumpfile);
+            }
+        } else if (dumpfile != null) {
+            throw new IllegalArgumentException("dumpfile does not need.");
+        }
+
         buildAttachArgs(newArgs, pid, exe, core, false);
         JMap.main(newArgs.toArray(new String[newArgs.size()]));
     }
 
     private static void runJINFO(String[] oldArgs) {
< prev index next >