Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdb/reenter/reenter001/reenter001.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/reenter/reenter001.
29
* VM Testbase keywords: [jpda, jdb]
30
* VM Testbase readme:
31
* DESCRIPTION
32
* A positive test case for the 'reenter' command.
33
* The debugged application (reenter001a.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 'reenter' command is called. The test passes if after execution of
40
* tested command the 'func2()' frame reentered, i.e. top frame of the stack.
41
* The test consists of two program:
42
* reenter001.java - launches jdb and debuggee, writes commands to jdb, reads the jdb output,
43
* reenter001a.java - the debugged application.
44
* COMMENTS
45
*
46
* @library /vmTestbase
47
* /test/lib
48
* @build nsk.jdb.reenter.reenter001.reenter001a
49
* @run main/othervm
50
* nsk.jdb.reenter.reenter001.reenter001
51
* -arch=${os.family}-${os.simpleArch}
52
* -waittime=5
53
* -debugee.vmkind=java
54
* -transport.address=dynamic
55
* -jdb=${test.jdk}/bin/jdb
56
* -java.options="${test.vm.opts} ${test.java.opts}"
57
* -workdir=.
58
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
59
*/
60
61
package nsk.jdb.reenter.reenter001;
62
63
import nsk.share.*;
64
import nsk.share.jdb.*;
65
66
import java.io.*;
67
import java.util.*;
68
69
public class reenter001 extends JdbTest {
70
71
public static void main (String argv[]) {
72
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
73
}
74
75
public static int run(String argv[], PrintStream out) {
76
debuggeeClass = DEBUGGEE_CLASS;
77
firstBreak = FIRST_BREAK;
78
lastBreak = LAST_BREAK;
79
return new reenter001().runTest(argv, out);
80
}
81
82
static final String PACKAGE_NAME = "nsk.jdb.reenter.reenter001";
83
static final String TEST_CLASS = PACKAGE_NAME + ".reenter001";
84
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
85
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
86
static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";
87
88
static final String MYTHREAD = "MyThread";
89
static final String DEBUGGEE_THREAD = PACKAGE_NAME + "." + MYTHREAD;
90
static final String[] CHECKED_METHODS = {"func1", "func2", "func3", "func4", "func5"};
91
92
protected void runCases() {
93
String[] reply;
94
Paragrep grep;
95
int count;
96
Vector v;
97
String found;
98
99
jdb.setBreakpointInMethod(LAST_BREAK);
100
reply = jdb.receiveReplyFor(JdbCommand.cont);
101
102
while (true) {
103
String[] threads = jdb.getThreadIds(DEBUGGEE_THREAD);
104
if (threads.length != 1) {
105
log.complain("jdb should report 1 instance of " + DEBUGGEE_THREAD);
106
log.complain("Found: " + threads.length);
107
success = false;
108
break;
109
}
110
111
reply = jdb.receiveReplyFor(JdbCommand.thread + threads[0]);
112
113
reply = jdb.receiveReplyFor(JdbCommand.step); // to get out of lastBreak()
114
115
reply = jdb.receiveReplyFor(JdbCommand.where);
116
if (!checkStack(reply, "func5", "[1]", "lastBreak", false)) {
117
success = false;
118
}
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.reenter);
128
129
reply = jdb.receiveReplyFor(JdbCommand.where);
130
if (!checkStack(reply, "func2", "[1]", "func3", 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 reenter ) {
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 " + ( reenter? "after 'reenter' 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 " + ( reenter? "after 'reenter' command": ""));
169
log.complain("Found wrong frame: " + DEBUGGEE_THREAD + "." + shouldNotBe);
170
result = false;
171
}
172
173
return result;
174
}
175
}
176
177