Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdb/kill/kill001/kill001.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/kill/kill001.
29
* VM Testbase keywords: [jpda, jdb]
30
* VM Testbase readme:
31
* DECSRIPTION
32
* A positive test case for the 'kill <thread id> <expr>' command.
33
* The debuggee program (kill001a.java) creates a number of additional
34
* threads with name like "MyThread-<number>" and starts them. The jdb
35
* suspends debuggee at moment when additional threads try to obtain
36
* lock on synchronized object (previously locked in main thread)
37
* and then tries to kill them. If these threads are killed then
38
* a value of the special "notKilled" variable should not be modified.
39
* Value of "notKilled" variable is checked by "eval <expr>" command.
40
* The test passes if the value is equal to 0 and fails otherwise..
41
* COMMENTS
42
* Modified due to fix of the test bug:
43
* 4940902 TEST_BUG: race in nsk/jdb/kill/kill001
44
* Modified due to fix of the bug:
45
* 5024081 TEST_BUG: nsk/jdb/kill/kill001 is slow
46
*
47
* @library /vmTestbase
48
* /test/lib
49
* @build nsk.jdb.kill.kill001.kill001a
50
* @run main/othervm
51
* nsk.jdb.kill.kill001.kill001
52
* -arch=${os.family}-${os.simpleArch}
53
* -waittime=5
54
* -debugee.vmkind=java
55
* -transport.address=dynamic
56
* -jdb=${test.jdk}/bin/jdb
57
* -java.options="${test.vm.opts} ${test.java.opts}"
58
* -workdir=.
59
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
60
*/
61
62
package nsk.jdb.kill.kill001;
63
64
import nsk.share.*;
65
import nsk.share.jdb.*;
66
67
import java.io.*;
68
import java.util.*;
69
70
public class kill001 extends JdbTest {
71
72
public static void main (String argv[]) {
73
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
74
}
75
76
public static int run(String argv[], PrintStream out) {
77
debuggeeClass = DEBUGGEE_CLASS;
78
firstBreak = FIRST_BREAK;
79
return new kill001().runTest(argv, out);
80
}
81
82
static final String PACKAGE_NAME = "nsk.jdb.kill.kill001";
83
static final String TEST_CLASS = PACKAGE_NAME + ".kill001";
84
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
85
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
86
static final String LAST_BREAK = DEBUGGEE_CLASS + ".breakHere";
87
static final String MYTHREAD = "MyThread";
88
static final String DEBUGGEE_THREAD = PACKAGE_NAME + "." + MYTHREAD;
89
static final String DEBUGGEE_RESULT = DEBUGGEE_CLASS + ".notKilled";
90
static final String DEBUGGEE_EXCEPTIONS = DEBUGGEE_CLASS + ".exceptions";
91
92
static int numThreads = nsk.jdb.kill.kill001.kill001a.numThreads;
93
94
protected void runCases() {
95
String[] reply;
96
Paragrep grep;
97
int count;
98
Vector v;
99
String found;
100
String[] threads;
101
102
jdb.setBreakpointInMethod(LAST_BREAK);
103
reply = jdb.receiveReplyFor(JdbCommand.cont);
104
105
threads = jdb.getThreadIds(DEBUGGEE_THREAD);
106
107
if (threads.length != numThreads) {
108
log.complain("jdb should report " + numThreads + " instance of " + DEBUGGEE_THREAD);
109
log.complain("Found: " + threads.length);
110
success = false;
111
}
112
113
for (int i = 0; i < threads.length; i++) {
114
reply = jdb.receiveReplyForWithMessageWait(JdbCommand.kill + threads[i] + " " +
115
DEBUGGEE_EXCEPTIONS + "[" + i + "]",
116
"killed");
117
}
118
119
for (int i = 0; i <= numThreads; i++) {
120
reply = jdb.receiveReplyFor(JdbCommand.cont);
121
}
122
123
// make sure the debugger is at a breakpoint
124
if (!jdb.isAtBreakpoint(reply, LAST_BREAK)) {
125
log.display("Expected breakpoint has not been hit yet");
126
jdb.waitForMessage(0, LAST_BREAK);
127
}
128
log.display("Breakpoint has been hit");
129
130
reply = jdb.receiveReplyForWithMessageWait(JdbCommand.eval + DEBUGGEE_RESULT,
131
DEBUGGEE_RESULT + " =");
132
grep = new Paragrep(reply);
133
found = grep.findFirst(DEBUGGEE_RESULT + " =" );
134
if (found.length() > 0) {
135
if (found.indexOf(DEBUGGEE_RESULT + " = 0") < 0) {
136
log.complain("Not all " + MYTHREAD + "s were killed. " + found + " remaining");
137
success = false;
138
}
139
} else {
140
log.complain("Value for " + DEBUGGEE_RESULT + " is not found.");
141
success = false;
142
}
143
144
reply = jdb.receiveReplyFor(JdbCommand.threads);
145
jdb.contToExit(1);
146
}
147
}
148
149