Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdb/dump/dump002/dump002.java
40951 views
1
/*
2
* Copyright (c) 2003, 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/dump/dump002.
29
* VM Testbase keywords: [quick, jpda, jdb]
30
* VM Testbase readme:
31
* DESCRIPTION
32
* This is a test for the 'dump' command.
33
* The test works as follows. Upon the debuggee is suspended
34
* on breakpoint, jdb issues 'dump' command for an object
35
* of debugged class and for element in array fields.
36
* The test passes if all checked fields with their values
37
* are listed.
38
* The test consists of two parts:
39
* dump002.java - test driver, i.e. launches jdb and debuggee,
40
* writes commands to jdb, reads the jdb output,
41
* dump002a.java - the debugged application.
42
* COMMENTS
43
* The test replaces the nsk/jdb/dump/dump001 one.
44
* Test fixed according to test bug:
45
* 5045859 TEST_BUG: some JDB tests do not recognize JDB prompt
46
*
47
* @library /vmTestbase
48
* /test/lib
49
* @build nsk.jdb.dump.dump002.dump002a
50
* @run main/othervm
51
* nsk.jdb.dump.dump002.dump002
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.dump.dump002;
63
64
import nsk.share.*;
65
import nsk.share.jdb.*;
66
67
import java.io.*;
68
import java.util.*;
69
70
public class dump002 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
compoundPromptIdent = COMPOUND_PROMPT_IDENT;
81
return new dump002().runTest(argv, out);
82
}
83
84
static final String PACKAGE_NAME = "nsk.jdb.dump.dump002";
85
static final String TEST_CLASS = PACKAGE_NAME + ".dump002";
86
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
87
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
88
static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";
89
static final String COMPOUND_PROMPT_IDENT = "main";
90
91
static final String[] CHECKED_FIELDS = {
92
"_dump002a",
93
"iStatic",
94
"iPrivate",
95
"iProtect",
96
"iPublic",
97
"iFinal",
98
"iTransient",
99
"iVolatile",
100
"iArray",
101
"sStatic",
102
"sPrivate",
103
"sProtected",
104
"sPublic",
105
"sFinal",
106
"sTransient",
107
"sVolatile",
108
"sArray",
109
"fBoolean",
110
"fByte",
111
"fChar",
112
"fDouble",
113
"fFloat",
114
"fInt",
115
"fLong",
116
"fShort"
117
};
118
119
protected void runCases() {
120
String[] reply;
121
Paragrep grep;
122
int count;
123
Vector v = new Vector();
124
String found;
125
126
jdb.setBreakpointInMethod(LAST_BREAK);
127
reply = jdb.receiveReplyFor(JdbCommand.cont);
128
129
reply = jdb.receiveReplyFor(JdbCommand.dump + DEBUGGEE_CLASS + "._dump002a");
130
grep = new Paragrep(reply);
131
for (int i = 0; i < CHECKED_FIELDS.length; i++) {
132
v.setSize(0);
133
v.add(CHECKED_FIELDS[i]);
134
v.add("null");
135
if (grep.find(v) > 0) {
136
failure("The field is not dumped : " + CHECKED_FIELDS[i]);
137
}
138
}
139
140
String checkedField = DEBUGGEE_CLASS + ".iArray[0]";
141
reply = jdb.receiveReplyFor(JdbCommand.dump + checkedField);
142
checkField(reply, checkedField);
143
144
checkedField = DEBUGGEE_CLASS + ".sArray[0]";
145
reply = jdb.receiveReplyFor(JdbCommand.dump + checkedField);
146
checkField(reply, checkedField);
147
148
jdb.contToExit(1);
149
}
150
151
void checkField (String[] reply, String fieldName) {
152
Paragrep grep;
153
Vector v = new Vector();
154
155
grep = new Paragrep(reply);
156
v.setSize(0);
157
v.add(fieldName);
158
v.add("null");
159
if (grep.find(v) > 0) {
160
failure("The field is not dumped : " + fieldName);
161
}
162
}
163
}
164
165