Hi all,

We cannot change heapdump name (heap.bin) when we genarate heapdump via jhsdb.
I want to set it like a jmap.

I think we can change SALauncher and JMap.
For example, in SALauncher side, I think we can add --dumpfile option as below:
----------------------
diff -r 3d289e4ba366 
src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/SALauncher.java
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/SALauncher.java       
Fri Apr 22 19:40:39 2016 +0200
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/SALauncher.java       
Mon Apr 25 22:48:03 2016 +0900
@@ -73,6 +73,7 @@
         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");
@@ -241,13 +242,15 @@
     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")) {
@@ -267,7 +270,11 @@
                 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")) {
@@ -284,6 +291,16 @@
             }
         }

+        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()]));
     }
----------------------

What do you think about it?
If it is accepted, I will file it to JBS and send review request.


Thanks,

Yasumasa


Reply via email to