changeset 57442:2069b4bfd23b jdk-14+28

8234277: ClhsdbLauncher should enable verbose exceptions and do a better job of detecting SA failures Reviewed-by: sspitsyn, ysuenaga
author cjplummer
date Wed, 18 Dec 2019 11:49:30 -0800
parents 26bb0fe2270a
children 169e9680821c
files test/hotspot/jtreg/ProblemList.txt test/hotspot/jtreg/serviceability/sa/ClhsdbLauncher.java
diffstat 2 files changed, 19 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/test/hotspot/jtreg/ProblemList.txt	Wed Dec 18 11:51:22 2019 -0500
+++ b/test/hotspot/jtreg/ProblemList.txt	Wed Dec 18 11:49:30 2019 -0800
@@ -115,7 +115,7 @@
 serviceability/sa/ClhsdbPrintStatics.java 8193639 solaris-all
 serviceability/sa/ClhsdbPstack.java 8193639 solaris-all
 serviceability/sa/ClhsdbRegionDetailsScanOopsForG1.java 8193639 solaris-all
-serviceability/sa/ClhsdbScanOops.java 8193639 solaris-all
+serviceability/sa/ClhsdbScanOops.java 8193639,8235220,8230731 solaris-all,linux-x64,macosx-x64,windows-x64
 serviceability/sa/ClhsdbSource.java 8193639 solaris-all
 serviceability/sa/ClhsdbThread.java 8193639 solaris-all
 serviceability/sa/ClhsdbVmStructsDump.java 8193639 solaris-all
--- a/test/hotspot/jtreg/serviceability/sa/ClhsdbLauncher.java	Wed Dec 18 11:51:22 2019 -0500
+++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbLauncher.java	Wed Dec 18 11:49:30 2019 -0800
@@ -71,7 +71,6 @@
             cmdStringList = SATestUtils.addPrivileges(cmdStringList);
         }
         ProcessBuilder processBuilder = new ProcessBuilder(cmdStringList);
-        processBuilder.redirectError(ProcessBuilder.Redirect.INHERIT);
         toolProcess = processBuilder.start();
     }
 
@@ -91,8 +90,6 @@
                            " and exe " + JDKToolFinder.getTestJDKTool("java"));
 
         ProcessBuilder processBuilder = new ProcessBuilder(launcher.getCommand());
-        processBuilder.redirectError(ProcessBuilder.Redirect.INHERIT);
-
         toolProcess = processBuilder.start();
     }
 
@@ -116,6 +113,17 @@
             throw new RuntimeException("CLHSDB command must be provided\n");
         }
 
+        // Enable verbose exception tracing so we see the full exception backtrace
+        // when there is a failure. We need to insert this command into the start
+        // of the commands list. We can't just issue the "verbose true" command seperately
+        // because code below won't work correctly if all executed commands are
+        // not in the commands list. And since it's immutable, we need to allocate
+        // a mutable one.
+        List<String> savedCommands = commands;
+        commands = new java.util.LinkedList<String>();
+        commands.add("verbose true");
+        commands.addAll(savedCommands);
+
         try (OutputStream out = toolProcess.getOutputStream()) {
             for (String cmd : commands) {
                 out.write((cmd + "\n").getBytes());
@@ -134,8 +142,15 @@
 
         oa.shouldHaveExitValue(0);
         output = oa.getOutput();
+        System.out.println("Output: ");
         System.out.println(output);
 
+        // This will detect most SA failures, including during the attach.
+        oa.shouldNotMatch("^sun.jvm.hotspot.debugger.DebuggerException:.*$");
+        // This will detect unexpected exceptions, like NPEs and asserts, that are caught
+        // by sun.jvm.hotspot.CommandProcessor.
+        oa.shouldNotMatch("^Error: .*$");
+
         String[] parts = output.split("hsdb>");
         for (String cmd : commands) {
             int index = commands.indexOf(cmd) + 1;