Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdb/set/set002/set002.java
40951 views
1
/*
2
* Copyright (c) 2007, 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/set/set002.
29
* VM Testbase keywords: [jpda, jdb]
30
* VM Testbase readme:
31
* DECSRIPTION
32
* A positive test for the 'set <lvalue> = <expr>' command.
33
* The test checks if jdb correctly sets value for the following
34
* fields and variables:
35
* - element of array field,
36
* - local variable
37
* Probably needs to be merged with set001
38
* The jdb suspends the debuggee inside the method runIt and then tries
39
* to set new values for the fields and variables using checked command.
40
* Then the debuggee checks if modified fields/variables have expected
41
* values. If not, then special errorMessage variable is appended with
42
* the info of wrong values. The test passes when length of errorMessage
43
* is equal to 0, and fails otherwise.
44
* The test consists of two programs:
45
* set002.java - launches jdb and debuggee, writes commands to jdb, reads the jdb output,
46
* set002a.java - the debugged application.
47
*
48
* @library /vmTestbase
49
* /test/lib
50
* @build nsk.jdb.set.set002.set002
51
*
52
* @comment make sure set002a is compiled w/ full debug info
53
* @clean nsk.jdb.set.set002.set002a
54
* @compile -g:lines,source,vars set002a.java
55
*
56
* @run main/othervm
57
* nsk.jdb.set.set002.set002
58
* -arch=${os.family}-${os.simpleArch}
59
* -waittime=5
60
* -debugee.vmkind=java
61
* -transport.address=dynamic
62
* -jdb=${test.jdk}/bin/jdb
63
* -java.options="${test.vm.opts} ${test.java.opts}"
64
* -workdir=.
65
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
66
*/
67
68
package nsk.jdb.set.set002;
69
70
import nsk.share.*;
71
import nsk.share.jdb.*;
72
73
import java.io.*;
74
import java.util.*;
75
76
public class set002 extends JdbTest {
77
78
public static void main (String argv[]) {
79
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
80
}
81
82
public static int run(String argv[], PrintStream out) {
83
debuggeeClass = DEBUGGEE_CLASS;
84
firstBreak = FIRST_BREAK;
85
lastBreak = LAST_BREAK;
86
87
return new set002().runTest(argv, out);
88
}
89
90
static final String PACKAGE_NAME = "nsk.jdb.set.set002";
91
static final String TEST_CLASS = PACKAGE_NAME + ".set002";
92
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
93
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
94
static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";
95
96
static final String ERROR_MESSAGE = DEBUGGEE_CLASS + ".errorMessage";
97
98
static final String[][] checkedExpr = { //not broken, can be run safely even if 4660158 is not fixed
99
{ DEBUGGEE_CLASS + "._set002a.myArrayField[0][0].line", "\"ABCDE\"" },
100
{ "localInt", "java.lang.Integer.MIN_VALUE"}
101
};
102
103
protected void runCases() {
104
String[] reply;
105
Paragrep grep;
106
int count;
107
Vector v;
108
String found;
109
110
jdb.setBreakpointInMethod(LAST_BREAK);
111
reply = jdb.receiveReplyFor(JdbCommand.cont);
112
113
// to get out of lastBreak()
114
reply = jdb.receiveReplyFor(JdbCommand.step);
115
116
// set values
117
for (int i = 0; i < checkedExpr.length; i++) {
118
reply = jdb.receiveReplyFor(JdbCommand.set + checkedExpr[i][0] + " = " + checkedExpr[i][1]);
119
}
120
121
reply = jdb.receiveReplyFor(JdbCommand.cont);
122
// check value of debuggeeResult
123
reply = jdb.receiveReplyFor(JdbCommand.eval + ERROR_MESSAGE);
124
125
//if everything is OK reply will look like this
126
// nsk.jdb.set.set002.set002a.errorMessage = ""
127
if (!reply[0].contains("\"\"")) {
128
log.complain("jdb failed to set value for expression(s): ");
129
for (int i = 0; i < reply.length; i++) {
130
log.complain(reply[i]);
131
}
132
success = false;
133
}
134
135
jdb.contToExit(1);
136
}
137
}
138
139