Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdb/pop/pop001/pop001.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/pop/pop001.
29
* VM Testbase keywords: [jpda, jdb]
30
* VM Testbase readme:
31
* DESCRIPTION
32
* A positive test case for the 'pop' command.
33
* The debugged application (pop001a.java) starts additional thread of MyThread
34
* class. The 'run()' method of the this class invokes recursively a number of
35
* int methods. The jdb sets breakpoint in the last called 'func5()' method
36
* to suspend the debugged VM when all the methods, i.e. from 'func1()' to
37
* 'func5()', are in MyThread's stack. Then jdb steps up three frame on stack
38
* by 'up 3' command. At this moment frame with 'func2()' is current.
39
* Then the 'pop' command is called. The test passes if after execution of
40
* tested command the 'func1()' frame becomes current and jdb correctly reports
41
* the thread stack and local variable(s) of the current frame.
42
* The test consists of two program:
43
* pop001.java - launches jdb and debuggee, writes commands to jdb, reads the jdb output,
44
* pop001a.java - the debugged application.
45
* COMMENTS
46
*
47
* @library /vmTestbase
48
* /test/lib
49
* @build nsk.jdb.pop.pop001.pop001a
50
* @run main/othervm
51
* nsk.jdb.pop.pop001.pop001
52
* -arch=${os.family}-${os.simpleArch}
53
* -waittime=5
54
* -debugee.vmkind=java
55
* -transport.address=dynamic
56
* -jdb=${test.jdk}/bin/jdb
57
* -java.options="${test.vm.opts} ${test.java.opts}"
58
* -workdir=.
59
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
60
*/
61
62
package nsk.jdb.pop.pop001;
63
64
import nsk.share.*;
65
import nsk.share.jdb.*;
66
67
import java.io.*;
68
import java.util.*;
69
70
public class pop001 extends JdbTest {
71
72
public static void main (String argv[]) {
73
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
74
}
75
76
public static int run(String argv[], PrintStream out) {
77
debuggeeClass = DEBUGGEE_CLASS;
78
firstBreak = FIRST_BREAK;
79
lastBreak = LAST_BREAK;
80
return new pop001().runTest(argv, out);
81
}
82
83
static final String PACKAGE_NAME = "nsk.jdb.pop.pop001";
84
static final String TEST_CLASS = PACKAGE_NAME + ".pop001";
85
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
86
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
87
static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";
88
89
static final String MYTHREAD = "MyThread";
90
static final String DEBUGGEE_THREAD = PACKAGE_NAME + "." + MYTHREAD;
91
static final String[] CHECKED_METHODS = {"func1", "func2", "func3", "func4", "func5"};
92
93
protected void runCases() {
94
String[] reply;
95
Paragrep grep;
96
int count;
97
Vector v;
98
String found;
99
100
jdb.setBreakpointInMethod(LAST_BREAK);
101
reply = jdb.receiveReplyFor(JdbCommand.cont);
102
103
while (true) {
104
String[] threads = jdb.getThreadIds(DEBUGGEE_THREAD);
105
if (threads.length != 1) {
106
log.complain("jdb should report 1 instance of " + DEBUGGEE_THREAD);
107
log.complain("Found: " + threads.length);
108
success = false;
109
break;
110
}
111
112
reply = jdb.receiveReplyFor(JdbCommand.thread + threads[0]);
113
114
reply = jdb.receiveReplyFor(JdbCommand.step); // to get out of lastBreak()
115
116
reply = jdb.receiveReplyFor(JdbCommand.where);
117
if (!checkStack(reply, "func5", "[1]", "lastBreak", false)) {
118
success = false;
119
}
120
reply = jdb.receiveReplyFor(JdbCommand.up + " 3");
121
122
reply = jdb.receiveReplyFor(JdbCommand.where);
123
if (!checkStack(reply, "func2", "[4]", "func3", false)) {
124
success = false;
125
}
126
127
reply = jdb.receiveReplyFor(JdbCommand.pop);
128
129
reply = jdb.receiveReplyFor(JdbCommand.where);
130
if (!checkStack(reply, "func1", "[1]", "func2", true)) {
131
success = false;
132
}
133
134
reply = jdb.receiveReplyFor(JdbCommand.locals);
135
grep = new Paragrep(reply);
136
if (grep.find("Internal exception") > 0) {
137
log.complain("Internal exception was thrown while 'locals' command");
138
for (int i = 0; i < reply.length; i++) {
139
log.complain(reply[i]);
140
}
141
success = false;
142
}
143
144
break;
145
}
146
147
jdb.contToExit(2);
148
}
149
150
private boolean checkStack (String[] reply, String shouldBe, String frameNum, String shouldNotBe, boolean pop ) {
151
Paragrep grep;
152
String found;
153
Vector v = new Vector();
154
boolean result = true;
155
int count;
156
157
grep = new Paragrep(reply);
158
v.add(frameNum);
159
v.add(DEBUGGEE_THREAD + "." + shouldBe);
160
if ((count = grep.find(v)) != 1) {
161
log.complain("Contents of stack trace is incorrect " + ( pop? "after 'pop' command": ""));
162
log.complain("Searched for: " + DEBUGGEE_THREAD + "." + shouldBe);
163
log.complain("Count : " + count);
164
result = false;
165
}
166
167
if (grep.find(DEBUGGEE_THREAD + "." + shouldNotBe) > 0) {
168
log.complain("Contents of stack trace is incorrect " + ( pop? "after 'pop' command": ""));
169
log.complain("Found wrong frame: " + DEBUGGEE_THREAD + "." + shouldNotBe);
170
result = false;
171
}
172
173
return result;
174
}
175
}
176
177