Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/serviceability/sa/ClhsdbJdis.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 8193124
27
* @summary Test the clhsdb 'jdis' command
28
* @requires vm.hasSA
29
* @library /test/lib
30
* @run main/othervm ClhsdbJdis
31
*/
32
33
import java.util.HashMap;
34
import java.util.List;
35
import java.util.Map;
36
import java.util.ArrayList;
37
38
import jdk.test.lib.apps.LingeredApp;
39
import jtreg.SkippedException;
40
41
public class ClhsdbJdis {
42
43
public static void main(String[] args) throws Exception {
44
LingeredApp theApp = null;
45
System.out.println("Starting the ClhsdbJdis test");
46
47
try {
48
ClhsdbLauncher test = new ClhsdbLauncher();
49
theApp = LingeredApp.startApp();
50
System.out.println("Started LingeredApp with pid " + theApp.getPid());
51
52
// Run 'jstack -v' command to get the Method Address
53
List<String> cmds = List.of("jstack -v");
54
String output = test.run(theApp.getPid(), cmds, null, null);
55
56
// Test the 'jdis' command passing in the address obtained from
57
// the 'jstack -v' command
58
cmds = new ArrayList<String>();
59
60
String cmdStr = null;
61
String[] parts = output.split("LingeredApp.steadyState");
62
String[] tokens = parts[1].split(" ");
63
for (String token : tokens) {
64
if (token.contains("Method")) {
65
String[] address = token.split("=");
66
// address[1] represents the address of the Method
67
cmdStr = "jdis " + address[1];
68
cmds.add(cmdStr);
69
break;
70
}
71
}
72
73
Map<String, List<String>> expStrMap = new HashMap<>();
74
expStrMap.put(cmdStr, List.of(
75
"private static void steadyState\\(java\\.lang\\.Object\\)",
76
"Holder Class",
77
"public class jdk.test.lib.apps.LingeredApp @",
78
"public class jdk\\.test\\.lib\\.apps\\.LingeredApp @",
79
"Bytecode",
80
"line bci bytecode",
81
"Exception Table",
82
"start bci end bci handler bci catch type",
83
"Constant Pool of \\[public class jdk\\.test\\.lib\\.apps\\.LingeredApp @"));
84
85
test.run(theApp.getPid(), cmds, expStrMap, null);
86
} catch (SkippedException e) {
87
throw e;
88
} catch (Exception ex) {
89
throw new RuntimeException("Test ERROR " + ex, ex);
90
} finally {
91
LingeredApp.stopApp(theApp);
92
}
93
System.out.println("Test PASSED");
94
}
95
}
96
97