2
|
1 |
#!/bin/sh
|
|
2 |
|
|
3 |
#
|
|
4 |
# Copyright 2005 Sun Microsystems, Inc. All Rights Reserved.
|
|
5 |
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
6 |
#
|
|
7 |
# This code is free software; you can redistribute it and/or modify it
|
|
8 |
# under the terms of the GNU General Public License version 2 only, as
|
|
9 |
# published by the Free Software Foundation.
|
|
10 |
#
|
|
11 |
# This code is distributed in the hope that it will be useful, but WITHOUT
|
|
12 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
13 |
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
14 |
# version 2 for more details (a copy is included in the LICENSE file that
|
|
15 |
# accompanied this code).
|
|
16 |
#
|
|
17 |
# You should have received a copy of the GNU General Public License version
|
|
18 |
# 2 along with this work; if not, write to the Free Software Foundation,
|
|
19 |
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
20 |
#
|
|
21 |
# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
22 |
# CA 95054 USA or visit www.sun.com if you need additional information or
|
|
23 |
# have any questions.
|
|
24 |
#
|
|
25 |
|
|
26 |
# @test
|
|
27 |
# @bug 6224859
|
|
28 |
# @summary JDWP: Mixing application suspends and debugger suspends can cause hangs
|
|
29 |
#
|
|
30 |
# @author Jim Holmlund
|
|
31 |
#
|
|
32 |
# @run build TestScaffold VMConnection TargetListener TargetAdapter
|
|
33 |
# @run shell MixedSuspendTest.sh
|
|
34 |
|
|
35 |
classname=MixedSuspendTarg
|
|
36 |
|
|
37 |
createJavaFile()
|
|
38 |
{
|
|
39 |
cat <<EOF > $classname.java.1
|
|
40 |
|
|
41 |
import java.util.*;
|
|
42 |
|
|
43 |
public class $classname extends Thread {
|
|
44 |
|
|
45 |
static volatile boolean started = true;
|
|
46 |
static String lock = "startLock";
|
|
47 |
|
|
48 |
public static void main(String[] args){
|
|
49 |
System.out.println("Howdy from MixedSuspendTarg");
|
|
50 |
|
|
51 |
MixedSuspendTarg mytarg = new MixedSuspendTarg();
|
|
52 |
|
|
53 |
synchronized(lock) {
|
|
54 |
mytarg.start();
|
|
55 |
try {
|
|
56 |
lock.wait();
|
|
57 |
} catch(InterruptedException ee) {
|
|
58 |
}
|
|
59 |
}
|
|
60 |
mytarg.suspend();
|
|
61 |
bkpt();
|
|
62 |
System.out.println("Debuggee: resuming thread");
|
|
63 |
|
|
64 |
// If the bug occurs, this resume hangs in the back-end
|
|
65 |
mytarg.resume();
|
|
66 |
System.out.println("Debuggee: resumed thread");
|
|
67 |
synchronized(lock) {
|
|
68 |
started = false;
|
|
69 |
}
|
|
70 |
System.out.println("Debuggee: exitting, started = " + started);
|
|
71 |
}
|
|
72 |
|
|
73 |
public void run() {
|
|
74 |
synchronized(lock) {
|
|
75 |
lock.notifyAll();
|
|
76 |
}
|
|
77 |
while (true) {
|
|
78 |
synchronized(lock) {
|
|
79 |
if (!started) {
|
|
80 |
break;
|
|
81 |
}
|
|
82 |
int i = 0;
|
|
83 |
}
|
|
84 |
}
|
|
85 |
|
|
86 |
System.out.println("Debuggee: end of thread");
|
|
87 |
}
|
|
88 |
|
|
89 |
static void bkpt() {
|
|
90 |
//System.out.println("bkpt reached, thread = " + this.getName());
|
|
91 |
int i = 0; // @1 breakpoint
|
|
92 |
}
|
|
93 |
}
|
|
94 |
|
|
95 |
EOF
|
|
96 |
}
|
|
97 |
|
|
98 |
dojdbCmds()
|
|
99 |
{
|
|
100 |
setBkpts @1
|
|
101 |
runToBkpt @1
|
|
102 |
cmd cont
|
|
103 |
cmd quit
|
|
104 |
}
|
|
105 |
|
|
106 |
|
|
107 |
mysetup()
|
|
108 |
{
|
|
109 |
if [ -z "$TESTSRC" ] ; then
|
|
110 |
TESTSRC=.
|
|
111 |
fi
|
|
112 |
|
|
113 |
for ii in . $TESTSRC $TESTSRC/.. ; do
|
|
114 |
if [ -r "$ii/ShellScaffold.sh" ] ; then
|
|
115 |
. $ii/ShellScaffold.sh
|
|
116 |
break
|
|
117 |
fi
|
|
118 |
done
|
|
119 |
}
|
|
120 |
|
|
121 |
# You could replace this next line with the contents
|
|
122 |
# of ShellScaffold.sh and this script will run just the same.
|
|
123 |
mysetup
|
|
124 |
|
|
125 |
runit
|
|
126 |
## This test fails by timing out.
|
|
127 |
pass
|