Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/serviceability/sa/ClhsdbThread.java
41149 views
1
/*
2
* Copyright (c) 2018, 2019, 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
import jdk.test.lib.apps.LingeredApp;
28
import jtreg.SkippedException;
29
30
/**
31
* @test
32
* @bug 8193352
33
* @summary Test clhsdb 'thread' and 'threads' commands
34
* @requires vm.hasSA
35
* @library /test/lib
36
* @run main/othervm ClhsdbThread
37
*/
38
39
public class ClhsdbThread {
40
41
public static void main(String[] args) throws Exception {
42
System.out.println("Starting ClhsdbThread test");
43
44
LingeredApp theApp = null;
45
try {
46
ClhsdbLauncher test = new ClhsdbLauncher();
47
theApp = LingeredApp.startApp();
48
System.out.println("Started LingeredApp with pid " + theApp.getPid());
49
50
List<String> cmds = List.of("thread", "thread -a", "threads");
51
52
Map<String, List<String>> expStrMap = new HashMap<>();
53
// Check for the presence of the usage string
54
expStrMap.put("thread", List.of( "Usage: thread \\{ \\-a \\| id \\}"));
55
expStrMap.put("thread -a", List.of(
56
"State: BLOCKED",
57
"Stack in use by Java",
58
"Base of Stack",
59
"Last_Java_SP:",
60
"Address"));
61
expStrMap.put("threads", List.of(
62
"Finalizer",
63
"Signal Dispatcher",
64
"Common-Cleaner",
65
"Stack in use by Java:",
66
"State:",
67
"Base of Stack:",
68
"main"));
69
Map<String, List<String>> unExpStrMap = new HashMap<>();
70
unExpStrMap.put(
71
"thread -a",
72
List.of("Couldn't find thread \\-a"));
73
74
String consolidatedOutput = test.run(
75
theApp.getPid(),
76
cmds,
77
expStrMap,
78
unExpStrMap);
79
80
// Test the thread <id> command now. Obtain <id> from the
81
// output of the previous 'threads' command. The word before
82
// the token 'Finalizer' should denote the thread id of the
83
// 'Finalizer' thread.
84
85
String[] snippets = consolidatedOutput.split("Finalizer");
86
String[] wordTokens = snippets[0].split(" ");
87
String threadIdObtained = wordTokens[wordTokens.length - 1];
88
89
// Weed out newlines and blurb before that.
90
if (threadIdObtained.contains("\n")) {
91
String[] threadIdTokens = threadIdObtained.split("\n");
92
threadIdObtained = threadIdTokens[threadIdTokens.length - 1];
93
}
94
95
expStrMap = new HashMap<>();
96
System.out.println("Thread Id obtained is: " + threadIdObtained);
97
98
String cmd = "thread " + threadIdObtained;
99
expStrMap.put(cmd, List.of(
100
"Base of Stack:",
101
"State:",
102
"Last_Java_SP"));
103
cmds = List.of(cmd);
104
test.run(theApp.getPid(), cmds, expStrMap, null);
105
} catch (SkippedException se) {
106
throw se;
107
} catch (Exception ex) {
108
throw new RuntimeException("Test ERROR " + ex, ex);
109
} finally {
110
LingeredApp.stopApp(theApp);
111
}
112
System.out.println("Test PASSED");
113
}
114
}
115
116