72 output.shouldHaveExitValue(0);
73 }
74
75 private static void run(boolean useArchive) throws Exception {
76 String flag = useArchive ? "auto" : "off";
77
78 // (1) Launch the attachee process
79 ProcessBuilder attachee = ProcessTools.createJavaProcessBuilder(
80 "-XX:+UnlockDiagnosticVMOptions",
81 "-XX:SharedArchiveFile=" + jsaName,
82 "-Xshare:" + flag,
83 "-showversion", // so we can see "sharing" in the output
84 "SASymbolTableTestAttachee");
85
86 final Process p = attachee.start();
87
88 // (2) Launch the agent process
89 long pid = p.getPid();
90 System.out.println("Attaching agent " + pid);
91 ProcessBuilder tool = ProcessTools.createJavaProcessBuilder(
92 "-XaddExports:jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED",
93 "-XaddExports:jdk.hotspot.agent/sun.jvm.hotspot.memory=ALL-UNNAMED",
94 "-XaddExports:jdk.hotspot.agent/sun.jvm.hotspot.runtime=ALL-UNNAMED",
95 "-XaddExports:jdk.hotspot.agent/sun.jvm.hotspot.tools=ALL-UNNAMED",
96 "SASymbolTableTestAgent",
97 Long.toString(pid));
98 OutputAnalyzer output = ProcessTools.executeProcess(tool);
99 System.out.println(output.getOutput());
100 output.shouldHaveExitValue(0);
101
102 Thread t = new Thread() {
103 public void run() {
104 try {
105 OutputAnalyzer output = new OutputAnalyzer(p);
106 System.out.println("STDOUT[");
107 System.out.print(output.getStdout());
108 System.out.println("]");
109 System.out.println("STDERR[");
110 System.out.print(output.getStderr());
111 System.out.println("]");
112 } catch (Throwable t) {
113 t.printStackTrace();
114 }
115 }
|
72 output.shouldHaveExitValue(0);
73 }
74
75 private static void run(boolean useArchive) throws Exception {
76 String flag = useArchive ? "auto" : "off";
77
78 // (1) Launch the attachee process
79 ProcessBuilder attachee = ProcessTools.createJavaProcessBuilder(
80 "-XX:+UnlockDiagnosticVMOptions",
81 "-XX:SharedArchiveFile=" + jsaName,
82 "-Xshare:" + flag,
83 "-showversion", // so we can see "sharing" in the output
84 "SASymbolTableTestAttachee");
85
86 final Process p = attachee.start();
87
88 // (2) Launch the agent process
89 long pid = p.getPid();
90 System.out.println("Attaching agent " + pid);
91 ProcessBuilder tool = ProcessTools.createJavaProcessBuilder(
92 "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED",
93 "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.memory=ALL-UNNAMED",
94 "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.runtime=ALL-UNNAMED",
95 "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.tools=ALL-UNNAMED",
96 "SASymbolTableTestAgent",
97 Long.toString(pid));
98 OutputAnalyzer output = ProcessTools.executeProcess(tool);
99 System.out.println(output.getOutput());
100 output.shouldHaveExitValue(0);
101
102 Thread t = new Thread() {
103 public void run() {
104 try {
105 OutputAnalyzer output = new OutputAnalyzer(p);
106 System.out.println("STDOUT[");
107 System.out.print(output.getStdout());
108 System.out.println("]");
109 System.out.println("STDERR[");
110 System.out.print(output.getStderr());
111 System.out.println("]");
112 } catch (Throwable t) {
113 t.printStackTrace();
114 }
115 }
|