Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdb/set/set001/set001.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/set/set001.
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
* - static field,
36
* - instance field
37
* The jdb suspends the debuggee inside the method runIt and then tries
38
* to set new values for the fields and variables using checked command.
39
* Then the debuggee checks if modified fields/variables have expected
40
* values. If not, then special errorMessage variable is appended with
41
* the info of wrong values. The test passes when length of errorMessage
42
* is equal to 0, and fails otherwise.
43
* The test consists of two program:
44
* set001.java - launches jdb and debuggee, writes commands to jdb, reads the jdb output,
45
* set001a.java - the debugged application.
46
* COMMENTS
47
*
48
* @library /vmTestbase
49
* /test/lib
50
* @build nsk.jdb.set.set001.set001
51
*
52
* @comment make sure set001a is compiled w/ full debug info
53
* @clean nsk.jdb.set.set001.set001a
54
* @compile -g:lines,source,vars set001a.java
55
*
56
* @run main/othervm
57
* nsk.jdb.set.set001.set001
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.set001;
69
70
import nsk.share.*;
71
import nsk.share.jdb.*;
72
73
import java.io.*;
74
import java.util.*;
75
76
public class set001 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
return new set001().runTest(argv, out);
87
}
88
89
static final String PACKAGE_NAME = "nsk.jdb.set.set001";
90
static final String TEST_CLASS = PACKAGE_NAME + ".set001";
91
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
92
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
93
static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";
94
95
static final String ERROR_MESSAGE = DEBUGGEE_CLASS + ".errorMessage";
96
97
static final String[][] checkedExpr = {
98
{ DEBUGGEE_CLASS + ".myStaticField", "-2147483648" },
99
{ DEBUGGEE_CLASS + "._set001a.myInstanceField", "9223372036854775807" },
100
};
101
102
protected void runCases() {
103
String[] reply;
104
Paragrep grep;
105
int count;
106
Vector v;
107
String found;
108
109
jdb.setBreakpointInMethod(LAST_BREAK);
110
reply = jdb.receiveReplyFor(JdbCommand.cont);
111
112
// to get out of lastBreak()
113
reply = jdb.receiveReplyFor(JdbCommand.step);
114
115
// set values
116
for (int i = 0; i < checkedExpr.length; i++) {
117
reply = jdb.receiveReplyFor(JdbCommand.set + checkedExpr[i][0] + " = " + checkedExpr[i][1]);
118
}
119
120
reply = jdb.receiveReplyFor(JdbCommand.cont);
121
// check value of debuggeeResult
122
reply = jdb.receiveReplyFor(JdbCommand.eval + ERROR_MESSAGE);
123
//if everything is OK reply will look like this
124
// nsk.jdb.set.set001.set001a.errorMessage = ""
125
if (!reply[0].contains("\"\"")) {
126
log.complain("jdb failed to set value for expression(s): ");
127
for (int i = 0; i < reply.length; i++) {
128
log.complain(reply[i]);
129
}
130
success = false;
131
}
132
133
jdb.contToExit(1);
134
}
135
}
136
137