Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdb/clear/clear002/clear002.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/clear/clear002.
29
* VM Testbase keywords: [jpda, jdb]
30
* VM Testbase readme:
31
* DECSRIPTION
32
* A positive test case for the 'clear <class_id>.<method>' command.
33
* The test sets 3 breakpoints and then clears two of them after the
34
* first breakpoint is reached. The tests verifies that jdb does not
35
* halt execution at the cleared breakpoint.
36
* COMMENTS
37
*
38
* @library /vmTestbase
39
* /test/lib
40
* @build nsk.jdb.clear.clear002.clear002a
41
* @run main/othervm
42
* nsk.jdb.clear.clear002.clear002
43
* -arch=${os.family}-${os.simpleArch}
44
* -waittime=5
45
* -debugee.vmkind=java
46
* -transport.address=dynamic
47
* -jdb=${test.jdk}/bin/jdb
48
* -java.options="${test.vm.opts} ${test.java.opts}"
49
* -workdir=.
50
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
51
*/
52
53
package nsk.jdb.clear.clear002;
54
55
import nsk.share.*;
56
import nsk.share.jdb.*;
57
58
import java.io.*;
59
import java.util.*;
60
61
public class clear002 extends JdbTest {
62
63
public static void main (String argv[]) {
64
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
65
}
66
67
public static int run(String argv[], PrintStream out) {
68
debuggeeClass = DEBUGGEE_CLASS;
69
firstBreak = FIRST_BREAK;
70
lastBreak = LAST_BREAK;
71
return new clear002().runTest(argv, out);
72
}
73
74
static final String PACKAGE_NAME = "nsk.jdb.clear.clear002";
75
static final String TEST_CLASS = PACKAGE_NAME + ".clear002";
76
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
77
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
78
static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";
79
static final String METHOD_TO_STOP = DEBUGGEE_CLASS + ".func5";
80
static final String METHOD1_TO_CLEAR = DEBUGGEE_CLASS + ".func4";
81
static final String METHOD2_TO_CLEAR = DEBUGGEE_CLASS + "$A.func7";
82
static final String REMOVED_SAMPLE = "Removed:";
83
84
protected void runCases() {
85
String[] reply;
86
Paragrep grep;
87
int count;
88
Vector v;
89
String found;
90
91
log.display("Setting breakpoint in method: " + METHOD1_TO_CLEAR);
92
jdb.setBreakpointInMethod(METHOD1_TO_CLEAR);
93
94
log.display("Setting breakpoint in method: " + METHOD2_TO_CLEAR);
95
jdb.setBreakpointInMethod(METHOD2_TO_CLEAR);
96
97
log.display("Setting breakpoint in method: " + METHOD_TO_STOP);
98
jdb.setBreakpointInMethod(METHOD_TO_STOP);
99
100
if (!checkClear (METHOD1_TO_CLEAR)) {
101
success = false;
102
}
103
104
if (!checkClear (METHOD2_TO_CLEAR)) {
105
success = false;
106
}
107
108
jdb.contToExit(2);
109
110
grep = new Paragrep(jdb.getTotalReply());
111
count = grep.find(Jdb.BREAKPOINT_HIT);
112
if (count != 2) {
113
log.complain("Should hit 2 breakpoints.");
114
log.complain("Breakpoint hit count reported: " + count);
115
success = false;
116
}
117
118
if (!checkBreakpoint (METHOD1_TO_CLEAR, grep)) {
119
success = false;
120
}
121
122
if (!checkBreakpoint (METHOD2_TO_CLEAR, grep)) {
123
success = false;
124
}
125
}
126
127
private boolean checkBreakpoint (String methodName, Paragrep grep) {
128
String found;
129
boolean result = true;
130
int count;
131
Vector v;
132
133
v = new Vector();
134
v.add(Jdb.BREAKPOINT_HIT);
135
v.add(methodName);
136
137
found = grep.findFirst(v);
138
if (found.length() > 0) {
139
log.complain("Wrong hit at removed breakpoint in method:" + methodName);
140
result = false;
141
}
142
return result;
143
}
144
145
private boolean checkClear (String methodName) {
146
Paragrep grep;
147
String found;
148
String[] reply;
149
boolean result = true;
150
int count;
151
Vector v;
152
153
v = new Vector();
154
v.add(REMOVED_SAMPLE);
155
v.add(methodName);
156
157
log.display("Clearing breakpoint in method:" + methodName);
158
reply = jdb.receiveReplyFor(JdbCommand.clear + methodName);
159
grep = new Paragrep(reply);
160
161
found = grep.findFirst(v);
162
if (found.length() == 0) {
163
log.complain("Failed to clear breakpoint in method: " + methodName);
164
result = false;
165
}
166
return result;
167
}
168
}
169
170