Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdb/kill/kill002/kill002.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/kill002.
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 (kill002a.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 are
36
* waiting for notification for lock objects and then tries to kill them.
37
* If these threads are killed then a value of the special
38
* "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
*
43
* @library /vmTestbase
44
* /test/lib
45
* @build nsk.jdb.kill.kill002.kill002a
46
* @run main/othervm
47
* nsk.jdb.kill.kill002.kill002
48
* -arch=${os.family}-${os.simpleArch}
49
* -waittime=5
50
* -debugee.vmkind=java
51
* -transport.address=dynamic
52
* -jdb=${test.jdk}/bin/jdb
53
* -java.options="${test.vm.opts} ${test.java.opts}"
54
* -workdir=.
55
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
56
*/
57
58
package nsk.jdb.kill.kill002;
59
60
import nsk.share.*;
61
import nsk.share.jdb.*;
62
63
import java.io.*;
64
import java.util.*;
65
66
public class kill002 extends JdbTest {
67
68
public static void main (String argv[]) {
69
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
70
}
71
72
public static int run(String argv[], PrintStream out) {
73
debuggeeClass = DEBUGGEE_CLASS;
74
firstBreak = FIRST_BREAK;
75
return new kill002().runTest(argv, out);
76
}
77
78
static final String PACKAGE_NAME = "nsk.jdb.kill.kill002";
79
static final String TEST_CLASS = PACKAGE_NAME + ".kill002";
80
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
81
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
82
static final String LAST_BREAK = DEBUGGEE_CLASS + ".breakHere";
83
static final String MYTHREAD = "MyThread";
84
static final String DEBUGGEE_THREAD = PACKAGE_NAME + "." + MYTHREAD;
85
static final String DEBUGGEE_RESULT = DEBUGGEE_CLASS + ".notKilled";
86
static final String DEBUGGEE_EXCEPTIONS = DEBUGGEE_CLASS + ".exceptions";
87
88
static int numThreads = nsk.jdb.kill.kill002.kill002a.numThreads;
89
90
protected void runCases() {
91
String[] reply;
92
Paragrep grep;
93
int count;
94
Vector v;
95
String found;
96
String[] threads;
97
98
jdb.setBreakpointInMethod(LAST_BREAK);
99
reply = jdb.receiveReplyFor(JdbCommand.cont);
100
101
threads = jdb.getThreadIds(DEBUGGEE_THREAD);
102
103
if (threads.length != numThreads) {
104
log.complain("jdb should report " + numThreads + " instance of " + DEBUGGEE_THREAD);
105
log.complain("Found: " + threads.length);
106
success = false;
107
}
108
109
for (int i = 0; i < threads.length; i++) {
110
reply = jdb.receiveReplyForWithMessageWait(JdbCommand.kill + threads[i] + " " +
111
DEBUGGEE_EXCEPTIONS + "[" + i + "]",
112
"killed");
113
}
114
reply = jdb.receiveReplyFor(JdbCommand.threads);
115
reply = jdb.receiveReplyFor(JdbCommand.cont);
116
117
// make sure the debugger is at a breakpoint
118
if (!jdb.isAtBreakpoint(reply, LAST_BREAK)) {
119
log.display("Expected breakpoint has not been hit yet");
120
jdb.waitForMessage(0, LAST_BREAK);
121
}
122
log.display("Breakpoint has been hit");
123
124
reply = jdb.receiveReplyForWithMessageWait(JdbCommand.eval + DEBUGGEE_RESULT,
125
DEBUGGEE_RESULT + " =");
126
grep = new Paragrep(reply);
127
found = grep.findFirst(DEBUGGEE_RESULT + " =" );
128
if (found.length() > 0) {
129
if (found.indexOf(DEBUGGEE_RESULT + " = 0") < 0) {
130
log.complain("Not all " + MYTHREAD + "s were killed. " + found + " remaining");
131
success = false;
132
}
133
} else {
134
log.complain("Value for " + DEBUGGEE_RESULT + " is not found.");
135
success = false;
136
}
137
138
jdb.contToExit(numThreads + 1);
139
}
140
}
141
142