Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/jdk17u
Path: blob/master/test/hotspot/jtreg/runtime/ErrorHandling/ShowRegistersOnAssertTest.java
64474 views
1
/*
2
* Copyright (c) 2018, 2020, Oracle and/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
* @bug 8191101
28
* @summary Show Registers on assert/guarantee
29
* @library /test/lib
30
* @requires (vm.debug == true) & (os.family == "linux")
31
* @author Thomas Stuefe (SAP)
32
* @modules java.base/jdk.internal.misc
33
* java.management
34
* @run driver ShowRegistersOnAssertTest
35
*/
36
37
// Note: this test can only run on debug since it relies on VMError::controlled_crash() which
38
// only exists in debug builds.
39
import java.io.BufferedReader;
40
import java.io.File;
41
import java.io.FileInputStream;
42
import java.io.InputStreamReader;
43
import java.util.regex.Pattern;
44
45
import jdk.test.lib.process.OutputAnalyzer;
46
import jdk.test.lib.Platform;
47
import jdk.test.lib.process.ProcessTools;
48
49
public class ShowRegistersOnAssertTest {
50
51
private static void do_test(boolean do_assert, // true - assert, false - guarantee
52
boolean suppress_assert,
53
boolean show_registers_on_assert) throws Exception
54
{
55
System.out.println("Testing " + (suppress_assert ? "suppressed" : "normal") + " " + (do_assert ? "assert" : "guarantee") +
56
" with " + (show_registers_on_assert ? "-XX:+ShowRegistersOnAssert" : "-XX:-ShowRegistersOnAssert") + "...");
57
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
58
"-XX:+UnlockDiagnosticVMOptions", "-Xmx100M", "-XX:-CreateCoredumpOnCrash",
59
"-XX:ErrorHandlerTest=" + (do_assert ? "1" : "2"),
60
(suppress_assert ? "-XX:SuppressErrorAt=/vmError.cpp" : ""),
61
(show_registers_on_assert ? "-XX:+ShowRegistersOnAssert" : "-XX:-ShowRegistersOnAssert"),
62
"-version");
63
64
OutputAnalyzer output_detail = new OutputAnalyzer(pb.start());
65
66
if (suppress_assert) {
67
// we should have not have crashed. See VMError::controlled_crash().
68
output_detail.shouldMatch(".*survived intentional crash.*");
69
} else {
70
// we should have crashed with an internal error. We should definitly NOT have crashed with a segfault
71
// (which would be a sign that the assert poison page mechanism does not work).
72
output_detail.shouldMatch("# A fatal error has been detected by the Java Runtime Environment:.*");
73
output_detail.shouldMatch("# +Internal Error.*");
74
}
75
}
76
77
public static void main(String[] args) throws Exception {
78
// Note: for now, this is only a regression test testing that the addition of ShowRegistersOnAssert does
79
// not break normal assert/guarantee handling. The feature is not implemented on all platforms and really testing
80
// it requires more effort.
81
do_test(false, false, false);
82
do_test(false, false, true);
83
do_test(false, true, false);
84
do_test(false, true, true);
85
do_test(true, false, false);
86
do_test(true, false, true);
87
do_test(true, true, false);
88
do_test(true, true, true);
89
}
90
91
}
92
93
94