Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdb/wherei/wherei001/wherei001.java
40951 views
1
/*
2
* Copyright (c) 2002, 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
/*
26
* @test
27
*
28
* @summary converted from VM Testbase nsk/jdb/wherei/wherei001.
29
* VM Testbase keywords: [jpda, jdb]
30
* VM Testbase readme:
31
* DECSRIPTION
32
* A positive test case for the 'wherei <thread id>' command.
33
* The test checks if jdb correctly reports stack trace for
34
* every checked thread id.
35
* COMMENTS
36
*
37
* @library /vmTestbase
38
* /test/lib
39
* @build nsk.jdb.wherei.wherei001.wherei001a
40
* @run main/othervm
41
* nsk.jdb.wherei.wherei001.wherei001
42
* -arch=${os.family}-${os.simpleArch}
43
* -waittime=5
44
* -debugee.vmkind=java
45
* -transport.address=dynamic
46
* -jdb=${test.jdk}/bin/jdb
47
* -java.options="${test.vm.opts} ${test.java.opts}"
48
* -workdir=.
49
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
50
*/
51
52
package nsk.jdb.wherei.wherei001;
53
54
import nsk.share.*;
55
import nsk.share.jdb.*;
56
57
import java.io.*;
58
import java.util.*;
59
60
public class wherei001 extends JdbTest {
61
62
public static void main (String argv[]) {
63
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
64
}
65
66
public static int run(String argv[], PrintStream out) {
67
debuggeeClass = DEBUGGEE_CLASS;
68
firstBreak = FIRST_BREAK;
69
lastBreak = LAST_BREAK;
70
return new wherei001().runTest(argv, out);
71
}
72
73
static final String PACKAGE_NAME = "nsk.jdb.wherei.wherei001";
74
static final String TEST_CLASS = PACKAGE_NAME + ".wherei001";
75
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
76
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
77
static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";
78
static final String DEBUGGEE_THREAD = PACKAGE_NAME + ".MyThread";
79
80
protected void runCases() {
81
String[] reply;
82
Paragrep grep;
83
int count;
84
Vector v;
85
String found;
86
String[] threads;
87
88
jdb.setBreakpointInMethod(LAST_BREAK);
89
reply = jdb.receiveReplyFor(JdbCommand.cont);
90
91
threads = jdb.getThreadIds(DEBUGGEE_THREAD);
92
93
if (threads.length != 5) {
94
log.complain("jdb should report 5 instance of " + DEBUGGEE_THREAD);
95
log.complain("Found: " + threads.length);
96
success = false;
97
}
98
99
for (int i = 0; i < threads.length; i++) {
100
if (!checkStack(threads[i])) {
101
success = false;
102
}
103
}
104
105
jdb.contToExit(1);
106
}
107
108
private boolean checkStack (String threadId) {
109
Paragrep grep;
110
String[] reply;
111
String found;
112
int count;
113
Vector v;
114
boolean result = true;
115
String[] func = { "func5", "func4", "func3", "func2", "func1", "run" };
116
117
reply = jdb.receiveReplyFor(JdbCommand.wherei + threadId);
118
119
grep = new Paragrep(reply);
120
for (int i = 0; i < func.length; i++) {
121
count = grep.find(DEBUGGEE_THREAD + "." + func[i]);
122
if (count != 1) {
123
log.complain("Contents of stack trace is incorrect for thread " + threadId);
124
log.complain("Searched for: " + DEBUGGEE_THREAD + "." + func[i]);
125
log.complain("Count : " + count);
126
result= false;
127
}
128
}
129
return result;
130
}
131
}
132
133