Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8292880: Improve debuggee logging for com/sun/jdi/ClassUnloadEventTest.java #10004

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 25 additions & 3 deletions test/jdk/com/sun/jdi/ClassUnloadEventTest.java
Expand Up @@ -54,7 +54,12 @@ public class ClassUnloadEventTest {

public static void main(String[] args) throws Exception {
if (args.length == 0) {
runDebuggee();
try {
runDebuggee();
} catch (Exception e) {
e.printStackTrace();
throw e;
}
} else {
runDebugger();
}
Expand Down Expand Up @@ -96,7 +101,7 @@ private static void runDebuggee() {
Class.forName(CLASS_NAME_PREFIX + index, true, loader);
}
} catch (Exception e) {
throw new RuntimeException("Failed to create Sample class");
throw new RuntimeException("Failed to create Sample class", e);
}
}
loader = null;
Expand All @@ -109,6 +114,8 @@ private static void runDebuggee() {
Thread.sleep(5000);
} catch (InterruptedException e) {
}

System.out.println("Exiting debuggee");
}

private static void runDebugger() throws Exception {
Expand Down Expand Up @@ -169,6 +176,21 @@ private static void runDebugger() throws Exception {
eventSet.resume();
}

/* Dump debuggee output. */
Process p = vm.process();
BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
BufferedReader err = new BufferedReader(new InputStreamReader(p.getErrorStream()));
String line = in.readLine();
while (line != null) {
System.out.println("stdout: " + line);
line = in.readLine();
}
line = err.readLine();
while (line != null) {
System.out.println("stderr: " + line);
line = err.readLine();
}

if (unloadedSampleClasses.size() != NUM_CLASSES) {
throw new RuntimeException("Wrong number of class unload events: expected " + NUM_CLASSES + " got " + unloadedSampleClasses.size());
}
Expand All @@ -183,7 +205,7 @@ private static VirtualMachine connectAndLaunchVM() throws IOException,
LaunchingConnector launchingConnector = Bootstrap.virtualMachineManager().defaultConnector();
Map<String, Connector.Argument> arguments = launchingConnector.defaultArguments();
arguments.get("main").setValue(ClassUnloadEventTest.class.getName());
arguments.get("options").setValue("--add-exports java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI");
arguments.get("options").setValue("--add-exports java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xlog:class+unload=info -Xlog:gc");
return launchingConnector.launch(arguments);
}
}