Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSJstackPrintAll.java
41149 views
1
/*
2
* Copyright (c) 2018, 2021, 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
* @test
26
* @bug 8174994
27
* @summary Test the clhsdb commands 'jstack', 'printall', 'where' with CDS enabled
28
* @requires vm.hasSA & vm.cds
29
* @library /test/lib
30
* @run main/othervm/timeout=2400 -Xmx1g ClhsdbCDSJstackPrintAll
31
*/
32
33
import java.util.List;
34
import java.util.Arrays;
35
import java.util.Map;
36
import java.util.HashMap;
37
import jdk.test.lib.cds.CDSTestUtils;
38
import jdk.test.lib.cds.CDSOptions;
39
import jdk.test.lib.apps.LingeredApp;
40
import jtreg.SkippedException;
41
42
public class ClhsdbCDSJstackPrintAll {
43
44
public static void main(String[] args) throws Exception {
45
System.out.println("Starting ClhsdbCDSJstackPrintAll test");
46
String sharedArchiveName = "ArchiveForClhsdbJstackPrintAll.jsa";
47
LingeredApp theApp = null;
48
49
try {
50
CDSOptions opts = (new CDSOptions()).setArchiveName(sharedArchiveName);
51
CDSTestUtils.createArchiveAndCheck(opts);
52
53
ClhsdbLauncher test = new ClhsdbLauncher();
54
theApp = LingeredApp.startApp(
55
"-XX:+UnlockDiagnosticVMOptions",
56
"-XX:SharedArchiveFile=" + sharedArchiveName,
57
"-Xshare:auto");
58
System.out.println("Started LingeredApp with pid " + theApp.getPid());
59
60
// Ensure that UseSharedSpaces is turned on.
61
List<String> cmds = List.of("flags UseSharedSpaces");
62
63
String useSharedSpacesOutput = test.run(theApp.getPid(), cmds,
64
null, null);
65
66
if (useSharedSpacesOutput == null) {
67
LingeredApp.stopApp(theApp);
68
// Attach permission issues.
69
throw new SkippedException("Could not determine the UseSharedSpaces value");
70
}
71
72
if (useSharedSpacesOutput.contains("UseSharedSpaces = false")) {
73
// CDS archive is not mapped. Skip the rest of the test.
74
LingeredApp.stopApp(theApp);
75
throw new SkippedException("The CDS archive is not mapped");
76
}
77
78
cmds = List.of("jstack -v", "printall", "where -a");
79
80
Map<String, List<String>> expStrMap = new HashMap<>();
81
Map<String, List<String>> unExpStrMap = new HashMap<>();
82
expStrMap.put("jstack -v", List.of(
83
"No deadlocks found",
84
"Common-Cleaner",
85
"Signal Dispatcher",
86
"Method*",
87
"LingeredApp.steadyState"));
88
unExpStrMap.put("jstack -v", List.of(
89
"sun.jvm.hotspot.types.WrongTypeException",
90
"No suitable match for type of address"));
91
expStrMap.put("printall", List.of(
92
"aload_0",
93
"_nofast_aload_0",
94
"_nofast_getfield",
95
"_nofast_putfield",
96
"Constant Pool of",
97
"public static void main\\(java.lang.String\\[\\]\\)",
98
"Bytecode",
99
"invokevirtual",
100
"checkcast",
101
"Exception Table",
102
"invokedynamic"));
103
unExpStrMap.put("printall", List.of(
104
"No suitable match for type of address",
105
"illegal code",
106
"Failure occurred at bci"));
107
expStrMap.put("where -a", List.of(
108
"Java Stack Trace for SteadyStateThread",
109
"private static void steadyState"));
110
unExpStrMap.put("where -a", List.of(
111
"illegal code",
112
"Failure occurred at bci"));
113
test.run(theApp.getPid(), cmds, expStrMap, unExpStrMap);
114
} catch (SkippedException e) {
115
throw e;
116
} catch (Exception ex) {
117
throw new RuntimeException("Test ERROR " + ex, ex);
118
} finally {
119
LingeredApp.stopApp(theApp);
120
}
121
System.out.println("Test PASSED");
122
}
123
}
124
125