Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdb/suspend/suspend001/suspend001.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/suspend/suspend001.
29
* VM Testbase keywords: [jpda, jdb]
30
* VM Testbase readme:
31
* DESCRIPTION
32
* A positive test case for the 'suspend <thread id>' command.
33
* The debugged application (suspend001a.java) creates two addional threads.
34
* First thead is of Suspended class, second one is of MyThread class.
35
* The jdb stops debuggee at a moment after addional thread have started and
36
* before their completion. Then jdb calls 'suspend' command with id of
37
* the Suspended thread and resumes debuggee. The suspended thread should
38
* not modify special int 'notSuspended' variable of the suspend001a class.
39
* The test passes if suspend001a.notSuspended variable equals to 1, i.e.
40
* only not-suspended MyThread thread had modified it.
41
* The test consists of two program:
42
* suspend001.java - launches jdb and debuggee, writes commands to jdb, reads the jdb output,
43
* suspend001a.java - the debugged application.
44
* COMMENTS
45
*
46
* @library /vmTestbase
47
* /test/lib
48
* @build nsk.jdb.suspend.suspend001.suspend001a
49
* @run main/othervm
50
* nsk.jdb.suspend.suspend001.suspend001
51
* -arch=${os.family}-${os.simpleArch}
52
* -waittime=5
53
* -debugee.vmkind=java
54
* -transport.address=dynamic
55
* -jdb=${test.jdk}/bin/jdb
56
* -java.options="${test.vm.opts} ${test.java.opts}"
57
* -workdir=.
58
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
59
*/
60
61
package nsk.jdb.suspend.suspend001;
62
63
import nsk.share.*;
64
import nsk.share.jdb.*;
65
66
import java.io.*;
67
import java.util.*;
68
69
public class suspend001 extends JdbTest {
70
71
public static void main (String argv[]) {
72
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
73
}
74
75
public static int run(String argv[], PrintStream out) {
76
debuggeeClass = DEBUGGEE_CLASS;
77
firstBreak = FIRST_BREAK;
78
lastBreak = LAST_BREAK;
79
return new suspend001().runTest(argv, out);
80
}
81
82
static final String PACKAGE_NAME = "nsk.jdb.suspend.suspend001";
83
static final String TEST_CLASS = PACKAGE_NAME + ".suspend001";
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
88
static final String SUSPENDED = "Suspended";
89
static final String DEBUGGEE_THREAD = PACKAGE_NAME + "." + SUSPENDED;
90
static final String DEBUGGEE_RESULT = DEBUGGEE_CLASS + ".notSuspended";
91
92
protected void runCases() {
93
String[] reply;
94
Paragrep grep;
95
int count;
96
Vector v;
97
String found;
98
String[] threads;
99
100
jdb.setBreakpointInMethod(LAST_BREAK);
101
reply = jdb.receiveReplyFor(JdbCommand.cont);
102
while (true) {
103
threads = jdb.getThreadIds(DEBUGGEE_THREAD);
104
if (threads.length != 1) {
105
log.complain("jdb should report 1 instance of " + DEBUGGEE_THREAD);
106
log.complain("Found: " + threads.length);
107
success = false;
108
break;
109
}
110
111
reply = jdb.receiveReplyFor(JdbCommand.suspend + threads[0]);
112
113
reply = jdb.receiveReplyFor(JdbCommand.cont);
114
if (!jdb.isAtBreakpoint(reply)) {
115
log.complain("Debugge does not reached second breakHere breakpoint");
116
success = false;
117
break;
118
}
119
120
reply = jdb.receiveReplyFor(JdbCommand.eval + DEBUGGEE_RESULT);
121
grep = new Paragrep(reply);
122
found = grep.findFirst(DEBUGGEE_RESULT + " =" );
123
if (found.length() > 0 && found.indexOf(DEBUGGEE_RESULT + " = null") < 0) {
124
if (found.indexOf(DEBUGGEE_RESULT + " = 1") < 0) {
125
log.complain("Wrong value of " + DEBUGGEE_RESULT);
126
log.complain(found);
127
success = false;
128
}
129
} else {
130
log.complain("TEST BUG: not found value for " + DEBUGGEE_RESULT);
131
success = false;
132
}
133
134
break;
135
}
136
137
jdb.contToExit(2);
138
}
139
}
140
141