author | dtitov |
Thu, 28 Feb 2019 13:12:26 -0800 | |
changeset 53960 | 6c3fd94de35a |
parent 50018 | 3ba0d8631f24 |
permissions | -rw-r--r-- |
50018 | 1 |
/* |
53960
6c3fd94de35a
8207367: 10 vmTestbase/nsk/jdi tests timed out when running with jtreg
dtitov
parents:
50018
diff
changeset
|
2 |
* Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved. |
50018 | 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 |
package nsk.jdi.VirtualMachine.dispose; |
|
25 |
||
26 |
import nsk.share.*; |
|
27 |
import nsk.share.jpda.*; |
|
28 |
import nsk.share.jdi.*; |
|
29 |
||
30 |
||
31 |
/** |
|
32 |
* This class is used as debuggee application for the dispose003 JDI test. |
|
33 |
*/ |
|
34 |
||
35 |
public class dispose003a { |
|
36 |
||
37 |
//----------------------------------------------------- templete section |
|
38 |
||
39 |
static final int PASSED = 0; |
|
40 |
static final int FAILED = 2; |
|
41 |
static final int PASS_BASE = 95; |
|
42 |
||
43 |
//-------------------------------------------------- log procedures |
|
44 |
||
45 |
static boolean verbMode = false; |
|
46 |
||
47 |
private static void log1(String message) { |
|
48 |
if (verbMode) |
|
49 |
System.err.println("**> dispose003a: " + message); |
|
50 |
} |
|
51 |
||
52 |
public static void log2(String message) { |
|
53 |
if (verbMode) |
|
54 |
System.err.println("**> " + message); |
|
55 |
} |
|
56 |
||
57 |
private static void logErr(String message) { |
|
58 |
if (verbMode) |
|
59 |
System.err.println("!!**> dispose003a: " + message); |
|
60 |
} |
|
61 |
||
62 |
//====================================================== test program |
|
63 |
//---------------------------------------------------- main method |
|
64 |
||
65 |
public static void main (String argv[]) { |
|
66 |
||
67 |
for (int i=0; i<argv.length; i++) { |
|
68 |
if ( argv[i].equals("-vbs") || argv[i].equals("-verbose") ) { |
|
69 |
verbMode = true; |
|
70 |
break; |
|
71 |
} |
|
72 |
} |
|
73 |
log1("debuggee started!"); |
|
74 |
||
75 |
// informing a debugger of readyness |
|
76 |
ArgumentHandler argHandler = new ArgumentHandler(argv); |
|
77 |
IOPipe pipe = argHandler.createDebugeeIOPipe(); |
|
78 |
pipe.println("ready"); |
|
79 |
||
80 |
||
81 |
int exitCode = PASSED; |
|
82 |
for (int i = 0; ; i++) { |
|
83 |
||
84 |
String instruction; |
|
85 |
||
86 |
log1("waiting for an instruction from the debugger ..."); |
|
87 |
instruction = pipe.readln(); |
|
88 |
if (instruction.equals("quit")) { |
|
89 |
log1("'quit' recieved"); |
|
90 |
break ; |
|
91 |
||
92 |
} else if (instruction.equals("newcheck")) { |
|
93 |
switch (i) { |
|
94 |
||
95 |
//------------------------------------------------------ section tested |
|
96 |
||
97 |
case 0: |
|
98 |
Threaddispose003a test_thread = |
|
99 |
new Threaddispose003a("testedThread"); |
|
100 |
log1(" thread2 is created"); |
|
101 |
||
102 |
label: |
|
103 |
synchronized (Threaddispose003a.lockingObject) { |
|
104 |
synchronized (Threaddispose003a.waitnotifyObj) { |
|
105 |
log1(" synchronized (waitnotifyObj) { enter"); |
|
106 |
log1(" before: test_thread.start()"); |
|
107 |
test_thread.start(); |
|
108 |
||
109 |
try { |
|
110 |
log1(" before: waitnotifyObj.wait();"); |
|
111 |
Threaddispose003a.waitnotifyObj.wait(); |
|
112 |
log1(" after: waitnotifyObj.wait();"); |
|
113 |
pipe.println("checkready"); |
|
114 |
instruction = pipe.readln(); |
|
115 |
if (!instruction.equals("continue")) { |
|
116 |
logErr("ERROR: unexpected instruction: " + instruction); |
|
117 |
exitCode = FAILED; |
|
118 |
break label; |
|
119 |
} |
|
120 |
pipe.println("docontinue"); |
|
121 |
} catch ( Exception e2) { |
|
122 |
log1(" Exception e2 exception: " + e2 ); |
|
123 |
pipe.println("waitnotifyerr"); |
|
124 |
} |
|
125 |
} |
|
126 |
} |
|
127 |
log1("mainThread is out of: synchronized (lockingObject)"); |
|
128 |
||
53960
6c3fd94de35a
8207367: 10 vmTestbase/nsk/jdi tests timed out when running with jtreg
dtitov
parents:
50018
diff
changeset
|
129 |
while (true) { |
6c3fd94de35a
8207367: 10 vmTestbase/nsk/jdi tests timed out when running with jtreg
dtitov
parents:
50018
diff
changeset
|
130 |
instruction = pipe.readln(); |
6c3fd94de35a
8207367: 10 vmTestbase/nsk/jdi tests timed out when running with jtreg
dtitov
parents:
50018
diff
changeset
|
131 |
if (instruction.equals("check_done")) { |
6c3fd94de35a
8207367: 10 vmTestbase/nsk/jdi tests timed out when running with jtreg
dtitov
parents:
50018
diff
changeset
|
132 |
if (test_thread.isAlive()) { |
6c3fd94de35a
8207367: 10 vmTestbase/nsk/jdi tests timed out when running with jtreg
dtitov
parents:
50018
diff
changeset
|
133 |
logErr("ERROR: thread2 thread is still alive"); |
6c3fd94de35a
8207367: 10 vmTestbase/nsk/jdi tests timed out when running with jtreg
dtitov
parents:
50018
diff
changeset
|
134 |
exitCode = FAILED; |
6c3fd94de35a
8207367: 10 vmTestbase/nsk/jdi tests timed out when running with jtreg
dtitov
parents:
50018
diff
changeset
|
135 |
} |
6c3fd94de35a
8207367: 10 vmTestbase/nsk/jdi tests timed out when running with jtreg
dtitov
parents:
50018
diff
changeset
|
136 |
break; |
6c3fd94de35a
8207367: 10 vmTestbase/nsk/jdi tests timed out when running with jtreg
dtitov
parents:
50018
diff
changeset
|
137 |
} else if (instruction.equals("check_alive")) { |
6c3fd94de35a
8207367: 10 vmTestbase/nsk/jdi tests timed out when running with jtreg
dtitov
parents:
50018
diff
changeset
|
138 |
log1("checking on: thread2.isAlive"); |
6c3fd94de35a
8207367: 10 vmTestbase/nsk/jdi tests timed out when running with jtreg
dtitov
parents:
50018
diff
changeset
|
139 |
if (test_thread.isAlive()) { |
6c3fd94de35a
8207367: 10 vmTestbase/nsk/jdi tests timed out when running with jtreg
dtitov
parents:
50018
diff
changeset
|
140 |
test_thread.resume(); |
6c3fd94de35a
8207367: 10 vmTestbase/nsk/jdi tests timed out when running with jtreg
dtitov
parents:
50018
diff
changeset
|
141 |
pipe.println("alive"); |
6c3fd94de35a
8207367: 10 vmTestbase/nsk/jdi tests timed out when running with jtreg
dtitov
parents:
50018
diff
changeset
|
142 |
} else { |
6c3fd94de35a
8207367: 10 vmTestbase/nsk/jdi tests timed out when running with jtreg
dtitov
parents:
50018
diff
changeset
|
143 |
pipe.println("not_alive"); |
6c3fd94de35a
8207367: 10 vmTestbase/nsk/jdi tests timed out when running with jtreg
dtitov
parents:
50018
diff
changeset
|
144 |
} |
50018 | 145 |
} else { |
53960
6c3fd94de35a
8207367: 10 vmTestbase/nsk/jdi tests timed out when running with jtreg
dtitov
parents:
50018
diff
changeset
|
146 |
logErr("ERROR: unexpected instruction: " + instruction); |
6c3fd94de35a
8207367: 10 vmTestbase/nsk/jdi tests timed out when running with jtreg
dtitov
parents:
50018
diff
changeset
|
147 |
exitCode = FAILED; |
6c3fd94de35a
8207367: 10 vmTestbase/nsk/jdi tests timed out when running with jtreg
dtitov
parents:
50018
diff
changeset
|
148 |
break; |
50018 | 149 |
} |
150 |
} |
|
151 |
||
152 |
break ; |
|
153 |
||
154 |
//------------------------------------------------- standard end section |
|
155 |
||
156 |
default: |
|
157 |
pipe.println("checkend"); |
|
158 |
break ; |
|
159 |
} |
|
160 |
||
161 |
} else { |
|
162 |
logErr("ERRROR: unexpected instruction: " + instruction); |
|
163 |
exitCode = FAILED; |
|
164 |
break ; |
|
165 |
} |
|
166 |
} |
|
167 |
||
168 |
System.exit(exitCode + PASS_BASE); |
|
169 |
} |
|
170 |
} |
|
171 |
||
172 |
||
173 |
class Threaddispose003a extends Thread { |
|
174 |
||
175 |
public Threaddispose003a(String threadName) { |
|
176 |
super(threadName); |
|
177 |
} |
|
178 |
||
179 |
public static Object waitnotifyObj = new Object(); |
|
180 |
public static Object lockingObject = new Object(); |
|
181 |
||
182 |
||
183 |
public void run() { |
|
184 |
log("method 'run' enter"); |
|
185 |
||
186 |
synchronized (waitnotifyObj) { |
|
187 |
log("entered into block: synchronized (waitnotifyObj)"); |
|
188 |
waitnotifyObj.notify(); |
|
189 |
} |
|
190 |
log("exited from block: synchronized (waitnotifyObj)"); |
|
191 |
synchronized (lockingObject) { |
|
192 |
log("entered into block: synchronized (lockingObject)"); |
|
193 |
} |
|
194 |
log("exited from block: synchronized (lockingObject)"); |
|
195 |
log("call to the method 'runt1'"); |
|
196 |
runt1(); |
|
197 |
log("returned from the method 'runt1'"); |
|
198 |
log("method 'run' exit"); |
|
199 |
return; |
|
200 |
} |
|
201 |
||
202 |
public void runt1() { |
|
203 |
||
204 |
int i0 = 0; |
|
205 |
log("method 'runt1': enter"); |
|
206 |
i0 = 1; |
|
207 |
log("method 'runt1': body: i0 == " + i0); |
|
208 |
log("method 'runt1': exit"); |
|
209 |
return; |
|
210 |
} |
|
211 |
||
212 |
public static final int breakpointLineNumber1 = 3; |
|
213 |
||
214 |
||
215 |
void log(String str) { |
|
216 |
dispose003a.log2("thread2: " + str); |
|
217 |
} |
|
218 |
} |