Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/serviceability/sa/ClhsdbPstack.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
import java.util.HashMap;
25
import java.util.List;
26
import java.util.Map;
27
28
import jdk.test.lib.apps.LingeredApp;
29
import jdk.test.lib.util.CoreUtils;
30
import jdk.test.lib.Platform;
31
import jtreg.SkippedException;
32
33
/**
34
* @test
35
* @bug 8190198
36
* @summary Test clhsdb pstack command on a live process
37
* @requires vm.hasSA
38
* @library /test/lib
39
* @run main/othervm ClhsdbPstack false
40
*/
41
42
/**
43
* @test
44
* @bug 8190198
45
* @summary Test clhsdb pstack command on a core file
46
* @requires vm.hasSA
47
* @library /test/lib
48
* @run main/othervm/timeout=480 ClhsdbPstack true
49
*/
50
51
public class ClhsdbPstack {
52
53
public static void main(String[] args) throws Exception {
54
boolean withCore = Boolean.parseBoolean(args[0]);
55
System.out.println("Starting ClhsdbPstack test: withCore==" + withCore);
56
57
LingeredApp theApp = null;
58
String coreFileName = null;
59
try {
60
ClhsdbLauncher test = new ClhsdbLauncher();
61
theApp = new LingeredApp();
62
theApp.setForceCrash(withCore);
63
LingeredApp.startApp(theApp);
64
System.out.println("Started LingeredApp with pid " + theApp.getPid());
65
66
if (withCore) {
67
String crashOutput = theApp.getOutput().getStdout();
68
coreFileName = CoreUtils.getCoreFileLocation(crashOutput, theApp.getPid());
69
}
70
71
List<String> cmds = List.of("pstack -v");
72
73
Map<String, List<String>> expStrMap = new HashMap<>();
74
if (!withCore && Platform.isOSX()) {
75
expStrMap.put("pstack -v", List.of(
76
"Not available for Mac OS X processes"));
77
} else {
78
expStrMap.put("pstack -v", List.of(
79
"No deadlocks found", "Common-Cleaner",
80
"Signal Dispatcher", "CompilerThread",
81
"Sweeper thread", "Service Thread",
82
"Reference Handler", "Finalizer", "main"));
83
}
84
85
if (withCore) {
86
test.runOnCore(coreFileName, cmds, expStrMap, null);
87
} else {
88
test.run(theApp.getPid(), cmds, expStrMap, null);
89
}
90
} catch (SkippedException se) {
91
throw se;
92
} catch (Exception ex) {
93
throw new RuntimeException("Test ERROR " + ex, ex);
94
} finally {
95
if (!withCore) {
96
LingeredApp.stopApp(theApp);
97
}
98
}
99
System.out.println("Test PASSED");
100
}
101
}
102
103