Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdb/watch/watch001/watch001.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/watch/watch001.
29
* VM Testbase keywords: [jpda, jdb]
30
* VM Testbase readme:
31
* DECSRIPTION
32
* A positive test case for the 'watch access <class id>.<field name>' command.
33
* There are two test cases:
34
* - access watch set for the fields defined in class,
35
* - access watch set for the fields defined in inner class.
36
* The debugged application invokes the methods in which all checked fields
37
* participate in assigned expressions.
38
* The test passes jdb correctly reports on access event for all checked fields.
39
* Correct report message in jdb stdout should contain full name of the field
40
* and "access encountered" words.
41
* The test consists of two program:
42
* watch001.java - launches jdb and debuggee, writes commands to jdb, reads the jdb output,
43
* watch001a.java - the debugged application.
44
* COMMENTS
45
* Test fixed according to test bug:
46
* 5045859 TEST_BUG: some JDB tests do not recognize JDB prompt
47
*
48
* @library /vmTestbase
49
* /test/lib
50
* @build nsk.jdb.watch.watch001.watch001a
51
* @run main/othervm
52
* nsk.jdb.watch.watch001.watch001
53
* -arch=${os.family}-${os.simpleArch}
54
* -waittime=5
55
* -debugee.vmkind=java
56
* -transport.address=dynamic
57
* -jdb=${test.jdk}/bin/jdb
58
* -java.options="${test.vm.opts} ${test.java.opts}"
59
* -workdir=.
60
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
61
*/
62
63
package nsk.jdb.watch.watch001;
64
65
import nsk.share.*;
66
import nsk.share.jdb.*;
67
68
import java.io.*;
69
import java.util.*;
70
71
public class watch001 extends JdbTest {
72
73
public static void main (String argv[]) {
74
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
75
}
76
77
public static int run(String argv[], PrintStream out) {
78
debuggeeClass = DEBUGGEE_CLASS;
79
firstBreak = FIRST_BREAK;
80
lastBreak = LAST_BREAK;
81
compoundPromptIdent = COMPOUND_PROMPT_IDENT;
82
return new watch001().runTest(argv, out);
83
}
84
85
static final String PACKAGE_NAME = "nsk.jdb.watch.watch001";
86
static final String TEST_CLASS = PACKAGE_NAME + ".watch001";
87
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
88
static final String DEBUGGEE_CLASS2 = DEBUGGEE_CLASS + "$CheckedFields";
89
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
90
static final String LAST_BREAK = DEBUGGEE_CLASS + ".breakHere";
91
static final String COMPOUND_PROMPT_IDENT = "main";
92
93
static String[] checkedFields = { "fS0", "FS1" };
94
static String[] checkedFields2 = { "FP0", "FU1", "FR0", "FT1", "FV0" };
95
96
protected void runCases() {
97
String[] reply;
98
Paragrep grep;
99
int count;
100
Vector v;
101
String found;
102
103
jdb.setBreakpointInMethod(LAST_BREAK);
104
105
reply = jdb.receiveReplyFor(JdbCommand.fields + DEBUGGEE_CLASS);
106
107
reply = jdb.receiveReplyFor(JdbCommand.fields + DEBUGGEE_CLASS2);
108
109
watchFields (DEBUGGEE_CLASS, checkedFields);
110
watchFields (DEBUGGEE_CLASS2, checkedFields2);
111
112
jdb.contToExit(checkedFields.length + checkedFields2.length + 2);
113
114
reply = jdb.getTotalReply();
115
if (!checkFields (DEBUGGEE_CLASS, reply, checkedFields)) {
116
success = false;
117
}
118
if (!checkFields (DEBUGGEE_CLASS2, reply, checkedFields2)) {
119
success = false;
120
}
121
}
122
123
private void watchFields (String className, String[] checkedFields) {
124
String[] reply;
125
126
for (int i = 0; i < checkedFields.length; i++) {
127
reply = jdb.receiveReplyFor(JdbCommand.watch + " access " + className + "." + checkedFields[i]);
128
}
129
130
}
131
132
private boolean checkFields (String className, String[] reply, String[] checkedFields) {
133
Paragrep grep;
134
String found;
135
boolean result = true;
136
int count;
137
Vector v = new Vector();
138
139
grep = new Paragrep(reply);
140
v.add("access encountered");
141
for (int i = 0; i < checkedFields.length; i++) {
142
v.removeAllElements();
143
v.add("access encountered");
144
v.add(className + "." + checkedFields[i]);
145
146
found = grep.findFirst(v);
147
if (found.length() == 0) {
148
log.complain("Failed to report access to field " + className + "." + checkedFields[i]);
149
result = false;
150
}
151
}
152
return result;
153
}
154
}
155
156