Skip to content

Commit 6b1e88a

Browse files
committed
8356329: Report compact object headers in hs_err
Reviewed-by: stuefe, lmesnik, zgu
1 parent c6ffacb commit 6b1e88a

File tree

2 files changed

+105
-1
lines changed

2 files changed

+105
-1
lines changed

src/hotspot/share/utilities/vmError.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,8 @@ static void report_vm_version(outputStream* st, char* buf, int buflen) {
530530
"", "",
531531
#endif
532532
UseCompressedOops ? ", compressed oops" : "",
533-
UseCompressedClassPointers ? ", compressed class ptrs" : "",
533+
UseCompactObjectHeaders ? ", compact obj headers"
534+
: (UseCompressedClassPointers ? ", compressed class ptrs" : ""),
534535
GCConfig::hs_err_name(),
535536
VM_Version::vm_platform_string()
536537
);
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
/*
2+
* Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
25+
/*
26+
* @test
27+
* @summary Test that we see VM configs reported correctly in hs_err file
28+
* @library /test/lib
29+
* @requires vm.flagless
30+
* @requires vm.debug
31+
* @modules java.base/jdk.internal.misc
32+
* java.management
33+
* @run driver TestVMConfigInHsErrFile
34+
*/
35+
36+
import jdk.test.lib.process.OutputAnalyzer;
37+
import jdk.test.lib.process.ProcessTools;
38+
import java.io.File;
39+
import java.util.ArrayList;
40+
import java.util.regex.Pattern;
41+
42+
public class TestVMConfigInHsErrFile {
43+
44+
public static void main(String[] args) throws Exception {
45+
testCompactObjectHeaders();
46+
testCompressedClassPointers();
47+
}
48+
49+
private static void testCompactObjectHeaders() throws Exception {
50+
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(
51+
"-XX:+UnlockDiagnosticVMOptions",
52+
"-XX:+UnlockExperimentalVMOptions",
53+
"-XX:+UseCompactObjectHeaders",
54+
"-Xmx100M",
55+
"-XX:-CreateCoredumpOnCrash",
56+
"-XX:ErrorHandlerTest=14",
57+
"-version");
58+
59+
OutputAnalyzer output = new OutputAnalyzer(pb.start());
60+
output.shouldNotHaveExitValue(0);
61+
62+
// extract hs-err file
63+
File f = HsErrFileUtils.openHsErrFileFromOutput(output);
64+
65+
Pattern[] expectedPatterns = new Pattern[] {
66+
Pattern.compile("# Java VM: .*compact obj headers.*")
67+
};
68+
Pattern[] notExpectedPatterns = new Pattern[] {
69+
Pattern.compile("# Java VM: .*compressed class ptrs.*")
70+
};
71+
72+
HsErrFileUtils.checkHsErrFileContent(f, expectedPatterns, notExpectedPatterns, true, true);
73+
74+
}
75+
76+
private static void testCompressedClassPointers() throws Exception {
77+
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(
78+
"-XX:+UnlockDiagnosticVMOptions",
79+
"-XX:+UnlockExperimentalVMOptions",
80+
"-XX:-UseCompactObjectHeaders",
81+
"-XX:+UseCompressedClassPointers",
82+
"-Xmx100M",
83+
"-XX:-CreateCoredumpOnCrash",
84+
"-XX:ErrorHandlerTest=14",
85+
"-version");
86+
87+
OutputAnalyzer output = new OutputAnalyzer(pb.start());
88+
output.shouldNotHaveExitValue(0);
89+
90+
// extract hs-err file
91+
File f = HsErrFileUtils.openHsErrFileFromOutput(output);
92+
93+
Pattern[] expectedPatterns = new Pattern[] {
94+
Pattern.compile("# Java VM: .*compressed class ptrs.*")
95+
};
96+
Pattern[] notExpectedPatterns = new Pattern[] {
97+
Pattern.compile("# Java VM: .*compact obj headers.*")
98+
};
99+
100+
HsErrFileUtils.checkHsErrFileContent(f, expectedPatterns, notExpectedPatterns, true, true);
101+
102+
}
103+
}

0 commit comments

Comments
 (0)