Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/serviceability/sa/ClhsdbPrintAs.java
41152 views
1
/*
2
* Copyright (c) 2017, 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 8192985
27
* @summary Test the clhsdb 'printas' command
28
* @requires vm.hasSA
29
* @library /test/lib
30
* @run main/othervm ClhsdbPrintAs
31
*/
32
33
import java.util.HashMap;
34
import java.util.List;
35
import java.util.Map;
36
import java.util.ArrayList;
37
import jdk.test.lib.apps.LingeredApp;
38
import jtreg.SkippedException;
39
40
public class ClhsdbPrintAs {
41
42
public static void main(String[] args) throws Exception {
43
System.out.println("Starting the ClhsdbPrintAs test");
44
45
LingeredApp theApp = null;
46
try {
47
ClhsdbLauncher test = new ClhsdbLauncher();
48
theApp = LingeredApp.startApp();
49
System.out.println("Started LingeredApp with pid " + theApp.getPid());
50
51
// Run the 'jstack -v' command to get the address of a the Method*
52
// representing LingeredApp.steadyState
53
List<String> cmds = List.of("jstack -v");
54
Map<String, List<String>> expStrMap;
55
56
String jstackOutput = test.run(theApp.getPid(), cmds, null, null);
57
58
String[] snippets = jstackOutput.split("LingeredApp.steadyState");
59
String addressString = null;
60
61
String[] tokens = snippets[1].split("Method\\*=");
62
String[] words = tokens[1].split(" ");
63
addressString = words[0];
64
65
cmds = new ArrayList<String>();
66
expStrMap = new HashMap<>();
67
68
String cmd = "printas Method " + addressString;
69
cmds.add(cmd);
70
expStrMap.put(cmd, List.of
71
("ConstMethod", "MethodCounters", "Method::_access_flags"));
72
73
// Run the printas Method <addr> command to obtain the address
74
// of ConstMethod*
75
String methodDetailsOutput = test.run(theApp.getPid(), cmds, expStrMap, null);
76
snippets = methodDetailsOutput.split("ConstMethod*");
77
78
tokens = snippets[1].split(" ");
79
for (String token : tokens) {
80
if (token.contains("0x")) {
81
addressString = token.replace("\n", "");
82
break;
83
}
84
}
85
86
cmds = new ArrayList<String>();
87
expStrMap = new HashMap<>();
88
89
cmd = "printas ConstMethod " + addressString;
90
cmds.add(cmd);
91
expStrMap.put(cmd, List.of
92
("ConstantPool", "_max_locals", "_flags"));
93
94
// Run the printas constMethod <addr> command to obtain the address
95
// of ConstantPool*
96
String constMethodDetailsOutput = test.run(theApp.getPid(), cmds, expStrMap, null);
97
snippets = constMethodDetailsOutput.split("ConstantPool*");
98
99
tokens = snippets[1].split(" ");
100
for (String token : tokens) {
101
if (token.contains("0x")) {
102
addressString = token.replace("\n", "");
103
break;
104
}
105
}
106
107
cmds = new ArrayList<String>();
108
expStrMap = new HashMap<>();
109
110
cmd = "printas ConstantPool " + addressString;
111
cmds.add(cmd);
112
expStrMap.put(cmd, List.of
113
("ConstantPoolCache", "_pool_holder", "InstanceKlass*"));
114
test.run(theApp.getPid(), cmds, expStrMap, null);
115
} catch (SkippedException e) {
116
throw e;
117
} catch (Exception ex) {
118
throw new RuntimeException("Test ERROR " + ex, ex);
119
} finally {
120
LingeredApp.stopApp(theApp);
121
}
122
System.out.println("Test PASSED");
123
}
124
}
125
126