--- old/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/SALauncher.java 2016-03-03 23:40:12.114045577 +0900 +++ new/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/SALauncher.java 2016-03-03 23:40:11.972046406 +0900 @@ -30,6 +30,7 @@ import sun.jvm.hotspot.tools.JStack; import sun.jvm.hotspot.tools.JMap; import sun.jvm.hotspot.tools.JInfo; +import sun.jvm.hotspot.tools.JSnap; public class SALauncher { @@ -39,6 +40,7 @@ System.out.println(" jstack --help\tto get more information"); System.out.println(" jmap --help\tto get more information"); System.out.println(" jinfo --help\tto get more information"); + System.out.println(" jsnap \tdump PerfCounter"); return false; } @@ -95,7 +97,7 @@ if (toolName.equals("jmap")) { return jmapHelp(); } - if (toolName.equals("hsdb") || toolName.equals("clhsdb")) { + if (toolName.equals("hsdb") || toolName.equals("clhsdb") || toolName.equals("jsnap")) { return commonHelp(); } return launcherHelp(); @@ -308,6 +310,40 @@ JInfo.main(newArgs.toArray(new String[newArgs.size()])); } + private static void runJSNAP(String[] oldArgs) { + SAGetopt sg = new SAGetopt(oldArgs); + String[] longOpts = {"exe=", "core=", "pid="}; + + ArrayList newArgs = new ArrayList(); + String exeORpid = null; + String core = null; + String s = null; + + while((s = sg.next(null, longOpts)) != null) { + if (s.equals("exe")) { + exeORpid = sg.getOptarg(); + continue; + } + if (s.equals("core")) { + core = sg.getOptarg(); + continue; + } + if (s.equals("pid")) { + exeORpid = sg.getOptarg(); + continue; + } + } + + if (exeORpid != null) { + newArgs.add(exeORpid); + if (core != null) { + newArgs.add(core); + } + } + + JSnap.main(newArgs.toArray(new String[newArgs.size()])); + } + public static void main(String[] args) { // Provide a help if (args.length == 0) { @@ -355,5 +391,10 @@ runJINFO(oldArgs); return; } + + if (args[0].equals("jsnap")) { + runJSNAP(oldArgs); + return; + } } }