Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdb/eval/eval001/eval001.java
40955 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/eval/eval001.
29
* VM Testbase keywords: [jpda, jdb]
30
* VM Testbase readme:
31
* DECSRIPTION
32
* A positive test for the 'eval <expr>' command.
33
* The test checks if jdb correctly prints values for the following
34
* expressions:
35
* - static field,
36
* - instance field,
37
* - element of array field,
38
* - return value of a method,
39
* - arithmetic expression of local variables,
40
* - return value of public method of the java.lang.String class.
41
* The test passes when all printed values are equal to expected ones.
42
* The test consists of two program:
43
* eval001.java - launches jdb and debuggee, writes commands to jdb, reads the jdb output,
44
* eval001a.java - the debugged application.
45
* COMMENTS
46
*
47
* @library /vmTestbase
48
* /test/lib
49
* @build nsk.jdb.eval.eval001.eval001
50
*
51
* @comment make sure eval001a is compiled w/ full debug info
52
* @clean nsk.jdb.eval.eval001.eval001a
53
* @compile -g:lines,source,vars eval001a.java
54
*
55
* @run main/othervm
56
* nsk.jdb.eval.eval001.eval001
57
* -arch=${os.family}-${os.simpleArch}
58
* -waittime=5
59
* -debugee.vmkind=java
60
* -transport.address=dynamic
61
* -jdb=${test.jdk}/bin/jdb
62
* -java.options="${test.vm.opts} ${test.java.opts}"
63
* -workdir=.
64
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
65
*/
66
67
package nsk.jdb.eval.eval001;
68
69
import nsk.share.*;
70
import nsk.share.jdb.*;
71
72
import java.io.*;
73
import java.util.*;
74
75
public class eval001 extends JdbTest {
76
77
public static void main (String argv[]) {
78
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
79
}
80
81
public static int run(String argv[], PrintStream out) {
82
debuggeeClass = DEBUGGEE_CLASS;
83
firstBreak = FIRST_BREAK;
84
lastBreak = LAST_BREAK;
85
return new eval001().runTest(argv, out);
86
}
87
88
static final String PACKAGE_NAME = "nsk.jdb.eval.eval001";
89
static final String TEST_CLASS = PACKAGE_NAME + ".eval001";
90
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
91
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
92
static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";
93
94
static final String[][] checkedExpr = {
95
{ DEBUGGEE_CLASS + ".myStaticField", "-2147483648" },
96
{ DEBUGGEE_CLASS + "._eval001a.myInstanceField", "9223372036854775807" },
97
{ DEBUGGEE_CLASS + "._eval001a.myArrayField[0][0].toString()", "ABCDE" },
98
{ DEBUGGEE_CLASS + "._eval001a.myMethod()", "2147483647" },
99
{ "myClass.toString().equals(\"abcde\")", "true"},
100
{ "i + j + k", "777"},
101
{ "new java.lang.String(\"Hello, World\").length()", "12"},
102
{ DEBUGGEE_CLASS + "._eval001a.testPrimitiveArray(test)", "1.0" }
103
};
104
105
protected void runCases() {
106
String[] reply;
107
Paragrep grep;
108
int count;
109
Vector v;
110
String found;
111
112
jdb.setBreakpointInMethod(LAST_BREAK);
113
reply = jdb.receiveReplyFor(JdbCommand.cont);
114
115
// to get out of lastBreak()
116
reply = jdb.receiveReplyFor(JdbCommand.step);
117
118
for (int i = 0; i < checkedExpr.length; i++) {
119
if (!checkValue(checkedExpr[i][0], checkedExpr[i][1])) {
120
success = false;
121
}
122
}
123
124
jdb.contToExit(1);
125
}
126
127
private boolean checkValue (String expr, String value) {
128
Paragrep grep;
129
String[] reply;
130
String found;
131
Vector v;
132
boolean result = true;
133
134
reply = jdb.receiveReplyFor(JdbCommand.eval + expr);
135
grep = new Paragrep(reply);
136
found = grep.findFirst(value);
137
if (found.length() <= 0) {
138
log.complain("jdb failed to report value of expression: " + expr);
139
log.complain("expected : " + value + " ;\nreported: " + (reply.length > 0? reply[0]: ""));
140
result = false;
141
}
142
return result;
143
}
144
}
145
146