Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/serviceability/sa/ClhsdbScanOops.java
41149 views
1
/*
2
* Copyright (c) 2017, 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
* @test
26
* @bug 8192985
27
* @summary Test the clhsdb 'scanoops' command
28
* @requires vm.gc.Parallel
29
* @requires vm.hasSA
30
* @library /test/lib
31
* @run main/othervm/timeout=1200 ClhsdbScanOops UseParallelGC
32
*/
33
34
/**
35
* @test
36
* @bug 8192985
37
* @summary Test the clhsdb 'scanoops' command
38
* @requires vm.gc.Serial
39
* @requires vm.hasSA
40
* @library /test/lib
41
* @run main/othervm/timeout=1200 ClhsdbScanOops UseSerialGC
42
*/
43
44
import java.util.HashMap;
45
import java.util.List;
46
import java.util.Map;
47
import java.util.ArrayList;
48
import jdk.test.lib.Utils;
49
import jdk.test.lib.apps.LingeredApp;
50
import jtreg.SkippedException;
51
52
public class ClhsdbScanOops {
53
54
private static void testWithGcType(String gc) throws Exception {
55
56
LingeredApp theApp = null;
57
58
try {
59
ClhsdbLauncher test = new ClhsdbLauncher();
60
theApp = LingeredApp.startApp(gc);
61
62
System.out.println ("Started LingeredApp with the GC option " + gc +
63
" and pid " + theApp.getPid());
64
65
// Run the 'universe' command to get the address ranges
66
List<String> cmds = List.of("universe");
67
68
String universeOutput = test.run(theApp.getPid(), cmds, null, null);
69
70
cmds = new ArrayList<String>();
71
Map<String, List<String>> expStrMap = new HashMap<>();
72
Map<String, List<String>> unExpStrMap = new HashMap<>();
73
74
String startAddress = null;
75
String endAddress = null;
76
String[] snippets = null;
77
78
if (gc.contains("UseParallelGC")) {
79
snippets = universeOutput.split("eden = ");
80
} else {
81
snippets = universeOutput.split("eden \\[");
82
}
83
String[] words = snippets[1].split(",");
84
// Get the addresses from Eden
85
startAddress = words[0].replace("[", "");
86
endAddress = words[1];
87
String cmd = "scanoops " + startAddress + " " + endAddress;
88
cmds.add(cmd);
89
90
expStrMap.put(cmd, List.of
91
("java/lang/Object", "java/lang/Class", "java/lang/Thread",
92
"java/lang/String", "\\[B", "\\[I"));
93
94
// Test the 'type' option also
95
// scanoops <start addr> <end addr> java/lang/String
96
// Ensure that only the java/lang/String oops are printed.
97
cmd = cmd + " java/lang/String";
98
cmds.add(cmd);
99
expStrMap.put(cmd, List.of("java/lang/String"));
100
unExpStrMap.put(cmd, List.of("java/lang/Thread"));
101
102
test.run(theApp.getPid(), cmds, expStrMap, unExpStrMap);
103
} catch (SkippedException e) {
104
throw e;
105
} catch (Exception ex) {
106
throw new RuntimeException("Test ERROR " + ex, ex);
107
} finally {
108
LingeredApp.stopApp(theApp);
109
}
110
}
111
112
public static void main(String[] args) throws Exception {
113
String gc = args[0];
114
System.out.println("Starting the ClhsdbScanOops test");
115
testWithGcType("-XX:+" + gc);
116
System.out.println("Test PASSED");
117
}
118
}
119
120