Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdb/exclude/exclude001/exclude001.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/exclude/exclude001.
29
* VM Testbase keywords: [jpda, jdb, quarantine]
30
* VM Testbase comments: 8191037
31
* VM Testbase readme:
32
* DECSRIPTION
33
* A positive test for the 'exclude' command.
34
* The debuggee program (exclude001a.java) starts three
35
* addional threads of MyThread class. The 'run' method of these
36
* threads invokes java.lang.System.currentTimeMillis() and
37
* sun.util.calendar.Gregorian() methods.
38
* There are three test cases:
39
* - block all exclude filter;
40
* - modified exclude filter allowing tracing events for java.* methods,
41
* which is set with 'exclude javax.*,sun.*,com.sun.*,jdk.*' command;
42
* - modified exclude filter allowing tracing events for sun.* methods,
43
* which is set with 'exclude java.*,javax.*,com.sun.*,jdk.*' command.
44
* - non-modified, predefined exclude filter;
45
* - modified exclude filter allowing tracing events for java.* methods,
46
* which is set with 'exclude javax.*,sun.*,com.sun.*' command;
47
* - modified exclude filter allowing tracing events for all system methods,
48
* which is set with 'exclude none' command.
49
* For each test case the correspondent MyThread thread is started and
50
* suspended at a breakpoint. Then method tracing is turned on with
51
* 'trace methods <thread id>' command with correspondent exclude filtering.
52
* The test passes if debuggee suspends on method enter/exit of only
53
* filtered classes, i.e. in comply with exclude filter previously set.
54
* The test consists of two program:
55
* exclude001.java - launches jdb and debuggee, writes commands to jdb, reads the jdb output,
56
* exclude001a.java - the debugged application.
57
* COMMENTS
58
*
59
* @library /vmTestbase
60
* /test/lib
61
* @build nsk.jdb.exclude.exclude001.exclude001a
62
* @run main/othervm/timeout=600
63
* nsk.jdb.exclude.exclude001.exclude001
64
* -arch=${os.family}-${os.simpleArch}
65
* -waittime=10
66
* -debugee.vmkind=java
67
* -transport.address=dynamic
68
* -jdb=${test.jdk}/bin/jdb
69
* -java.options="${test.vm.opts} ${test.java.opts}"
70
* -workdir=.
71
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
72
*/
73
74
package nsk.jdb.exclude.exclude001;
75
76
import nsk.share.*;
77
import nsk.share.jdb.*;
78
79
import java.io.*;
80
import java.util.*;
81
82
public class exclude001 extends JdbTest {
83
84
public static void main (String argv[]) {
85
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
86
}
87
88
public static int run(String argv[], PrintStream out) {
89
debuggeeClass = DEBUGGEE_CLASS;
90
firstBreak = FIRST_BREAK;
91
lastBreak = LAST_BREAK;
92
return new exclude001().runTest(argv, out);
93
}
94
95
static final String PACKAGE_NAME = "nsk.jdb.exclude.exclude001";
96
static final String TEST_CLASS = PACKAGE_NAME + ".exclude001";
97
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
98
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
99
static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";
100
static final String MYTHREAD = "MyThread";
101
static final String DEBUGGEE_THREAD = PACKAGE_NAME + "." + MYTHREAD;
102
103
static final String JAVA_CORE_METHOD = "java.lang.System.currentTimeMillis";
104
static final String SUN_METHOD = "sun.util.calendar.Gregorian";
105
106
protected void runCases() {
107
String[] reply;
108
Paragrep grep;
109
int count;
110
Vector v;
111
String found;
112
String[] threads;
113
114
String oldExclude = "";
115
boolean javaTraced = false;
116
boolean comTraced = false;
117
boolean nskTraced = false;
118
119
jdb.setBreakpointInMethod(LAST_BREAK);
120
121
// getting predefined 'exclude' value
122
reply = jdb.receiveReplyFor(JdbCommand.exclude);
123
if (reply.length == 0) {
124
log.complain("Predefined excluded lists of classes is empty");
125
success = false;
126
} else {
127
128
oldExclude = reply[0];
129
130
for (int testCase = 0; testCase < exclude001a.numThreads; testCase++) {
131
String expectedPrompt = MYTHREAD + "-" + testCase + "[1]";
132
reply = jdb.receiveReplyFor(JdbCommand.cont);
133
134
if (jdb.isAtBreakpoint(reply, LAST_BREAK)) {
135
136
threads = jdb.getThreadIds(DEBUGGEE_THREAD);
137
138
if (threads.length != 1) {
139
log.complain("jdb should report 1 instance of " + DEBUGGEE_THREAD);
140
log.complain("Found: " + threads.length);
141
success = false;
142
} else {
143
144
reply = jdb.receiveReplyFor(JdbCommand.step); // to get out of lastBreak;
145
146
switch (testCase) {
147
case 0: // block all
148
reply = jdb.receiveReplyFor(JdbCommand.exclude + "java.*,javax.*,sun.*,com.sun.*,jdk.*");
149
150
break;
151
case 1: // allow java.*
152
reply = jdb.receiveReplyFor(JdbCommand.exclude + "javax.*,sun.*,com.sun.*,jdk.*");
153
break;
154
case 2: // allow sun.*
155
reply = jdb.receiveReplyFor(JdbCommand.exclude + "java.*,javax.*,com.sun.*,jdk.*");
156
break;
157
}
158
159
reply = jdb.receiveReplyFor(JdbCommand.trace + "methods " + threads[0]);
160
161
while (true) {
162
reply = jdb.receiveReplyForWithMessageWait(JdbCommand.cont, expectedPrompt);
163
164
grep = new Paragrep(reply);
165
count = grep.find(JAVA_CORE_METHOD);
166
if (count > 0) {
167
if (testCase != 0) {
168
javaTraced = true;
169
} else {
170
log.complain("Trace message for excluded method: " + JAVA_CORE_METHOD);
171
}
172
}
173
174
count = grep.find(SUN_METHOD);
175
if (count > 0) {
176
if (testCase == 2) {
177
comTraced = true;
178
} else {
179
log.complain("Trace message for excluded method: " + SUN_METHOD);
180
}
181
}
182
183
count = grep.find(DEBUGGEE_THREAD + ".run");
184
if (count > 0) {
185
nskTraced = true;
186
187
reply = jdb.receiveReplyFor(JdbCommand.exclude + oldExclude);
188
reply = jdb.receiveReplyFor(JdbCommand.untrace + "methods "+ threads[0]);
189
break;
190
}
191
}
192
}
193
}
194
}
195
}
196
197
jdb.contToExit(2);
198
199
if (!javaTraced) {
200
log.complain("There were no tracing events for " + JAVA_CORE_METHOD + "() method while turned off filter");
201
success = false;
202
}
203
if (!comTraced) {
204
log.complain("There were no tracing events for " + SUN_METHOD + "() method while turned off filter");
205
success = false;
206
}
207
if (!nskTraced) {
208
log.complain("There were no tracing events for " + DEBUGGEE_THREAD + ".run() method ");
209
success = false;
210
}
211
}
212
}
213
214