author | mikejwre |
Thu, 25 Mar 2010 15:05:15 -0700 | |
changeset 5074 | 9c9bfe8f3a47 |
parent 836 | d81b1f62fb82 |
child 5506 | 202f599c92aa |
permissions | -rw-r--r-- |
836
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
1 |
/* |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
2 |
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
4 |
* |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
8 |
* |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
13 |
* accompanied this code). |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
14 |
* |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
18 |
* |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
19 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
20 |
* CA 95054 USA or visit www.sun.com if you need additional information or |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
21 |
* have any questions. |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
22 |
*/ |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
23 |
|
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
24 |
/** |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
25 |
* @test |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
26 |
* @bug 6700889 |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
27 |
* @summary Thread resume invalidates all stack frames, even from other threads |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
28 |
* |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
29 |
* @author jjh |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
30 |
* |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
31 |
* @run build TestScaffold VMConnection TargetListener TargetAdapter |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
32 |
* @run compile -g ResumeOneThreadTest.java |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
33 |
* @run main ResumeOneThreadTest |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
34 |
*/ |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
35 |
import com.sun.jdi.*; |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
36 |
import com.sun.jdi.event.*; |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
37 |
import com.sun.jdi.request.*; |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
38 |
|
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
39 |
import java.util.*; |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
40 |
|
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
41 |
class ResumeOneThreadTarg extends Thread { |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
42 |
static String name1 = "Thread 1"; |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
43 |
static String name2 = "Thread 2"; |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
44 |
|
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
45 |
public ResumeOneThreadTarg(String name) { |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
46 |
super(name); |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
47 |
} |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
48 |
|
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
49 |
public static void main(String[] args) { |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
50 |
System.out.println(" Debuggee: Howdy!"); |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
51 |
ResumeOneThreadTarg t1 = new ResumeOneThreadTarg(name1); |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
52 |
ResumeOneThreadTarg t2 = new ResumeOneThreadTarg(name2); |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
53 |
|
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
54 |
t1.start(); |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
55 |
t2.start(); |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
56 |
} |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
57 |
|
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
58 |
// This just starts two threads. Each runs to a bkpt. |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
59 |
public void run() { |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
60 |
if (getName().equals(name1)) { |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
61 |
run1(); |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
62 |
} else { |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
63 |
run2(); |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
64 |
} |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
65 |
} |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
66 |
|
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
67 |
public void bkpt1(String p1) { |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
68 |
System.out.println(" Debuggee: bkpt 1"); |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
69 |
} |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
70 |
|
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
71 |
public void run1() { |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
72 |
bkpt1("Hello Alviso!"); |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
73 |
} |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
74 |
|
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
75 |
|
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
76 |
|
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
77 |
public void bkpt2() { |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
78 |
System.out.println(" Debuggee: bkpt 2"); |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
79 |
} |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
80 |
|
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
81 |
public void run2() { |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
82 |
bkpt2(); |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
83 |
} |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
84 |
} |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
85 |
|
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
86 |
/********** test program **********/ |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
87 |
|
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
88 |
public class ResumeOneThreadTest extends TestScaffold { |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
89 |
ReferenceType targetClass; |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
90 |
ThreadReference mainThread; |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
91 |
|
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
92 |
BreakpointRequest request1; |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
93 |
BreakpointRequest request2; |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
94 |
|
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
95 |
ThreadReference thread1 = null; |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
96 |
ThreadReference thread2 = null;; |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
97 |
boolean theVMisDead = false; |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
98 |
|
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
99 |
ResumeOneThreadTest (String args[]) { |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
100 |
super(args); |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
101 |
} |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
102 |
|
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
103 |
public static void main(String[] args) throws Exception { |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
104 |
new ResumeOneThreadTest(args).startTests(); |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
105 |
} |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
106 |
|
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
107 |
|
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
108 |
synchronized public void breakpointReached(BreakpointEvent event) { |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
109 |
println("-- Got bkpt at: " + event.location()); |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
110 |
ThreadReference eventThread = event.thread(); |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
111 |
|
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
112 |
if (eventThread.name().equals(ResumeOneThreadTarg.name1)) { |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
113 |
thread1 = eventThread; |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
114 |
} |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
115 |
|
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
116 |
if (eventThread.name().equals(ResumeOneThreadTarg.name2)) { |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
117 |
thread2 = eventThread; |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
118 |
} |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
119 |
} |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
120 |
|
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
121 |
public void vmDied(VMDeathEvent event) { |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
122 |
theVMisDead = true; |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
123 |
} |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
124 |
|
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
125 |
synchronized public void eventSetComplete(EventSet set) { |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
126 |
if (theVMisDead) { |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
127 |
return; |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
128 |
} |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
129 |
if (thread1 == null || thread2 == null) { |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
130 |
// Don't do a set.resume(), just let the other thread |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
131 |
// keep running until it hits its bkpt. |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
132 |
return; |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
133 |
} |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
134 |
|
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
135 |
// Both threads are stopped at their bkpts. Get a StackFrame from |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
136 |
// Thread 1 then resume Thread 2 and verify that the saved StackFrame is |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
137 |
// still valid. |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
138 |
|
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
139 |
// suspend everything. |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
140 |
println("-- All threads suspended"); |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
141 |
vm().suspend(); |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
142 |
|
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
143 |
StackFrame t1sf0 = null; |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
144 |
try { |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
145 |
t1sf0 = thread1.frame(0); |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
146 |
} catch (IncompatibleThreadStateException ee) { |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
147 |
failure("FAILED: Exception: " + ee); |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
148 |
} |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
149 |
|
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
150 |
println("-- t1sf0 args: " + t1sf0.getArgumentValues()); |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
151 |
|
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
152 |
// Ok, we have a StackFrame for thread 1. Resume just thread 2 |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
153 |
// Note that thread 2 has been suspended twice - by the SUSPEND_ALL |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
154 |
// bkpt, and by the above vm().suspend(), so we have to resume |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
155 |
// it twice. |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
156 |
request2.disable(); |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
157 |
|
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
158 |
thread2.resume(); |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
159 |
thread2.resume(); |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
160 |
println("-- Did Resume on thread 2"); |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
161 |
|
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
162 |
// Can we get frames for thread1? |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
163 |
try { |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
164 |
StackFrame t1sf0_1 = thread1.frame(0); |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
165 |
if (!t1sf0.equals(t1sf0_1)) { |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
166 |
failure("FAILED: Got a different frame 0 for thread 1 after resuming thread 2"); |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
167 |
} |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
168 |
} catch (IncompatibleThreadStateException ee) { |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
169 |
failure("FAILED: Could not get frames for thread 1: Exception: " + ee); |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
170 |
} catch (Exception ee) { |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
171 |
failure("FAILED: Could not get frames for thread 1: Exception: " + ee); |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
172 |
} |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
173 |
|
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
174 |
|
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
175 |
try { |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
176 |
println("-- t1sf0 args: " + t1sf0.getArgumentValues()); |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
177 |
} catch (InvalidStackFrameException ee) { |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
178 |
// This is the failure. |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
179 |
failure("FAILED Got InvalidStackFrameException"); |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
180 |
vm().dispose(); |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
181 |
throw(ee); |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
182 |
} |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
183 |
|
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
184 |
// Let the debuggee finish |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
185 |
request1.disable(); |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
186 |
thread1.resume(); |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
187 |
vm().resume(); |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
188 |
println("--------------"); |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
189 |
} |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
190 |
|
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
191 |
/********** test core **********/ |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
192 |
|
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
193 |
protected void runTests() throws Exception { |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
194 |
|
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
195 |
/* |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
196 |
* Get to the top of main() |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
197 |
* to determine targetClass and mainThread |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
198 |
*/ |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
199 |
BreakpointEvent bpe = startToMain("ResumeOneThreadTarg"); |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
200 |
targetClass = bpe.location().declaringType(); |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
201 |
mainThread = bpe.thread(); |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
202 |
EventRequestManager erm = vm().eventRequestManager(); |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
203 |
final Thread mainThread = Thread.currentThread(); |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
204 |
|
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
205 |
/* |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
206 |
* Set event requests |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
207 |
*/ |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
208 |
|
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
209 |
Location loc1 = findMethod(targetClass, "bkpt1", "(Ljava/lang/String;)V").location(); |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
210 |
request1 = erm.createBreakpointRequest(loc1); |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
211 |
request1.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD); |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
212 |
request1.enable(); |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
213 |
|
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
214 |
Location loc2 = findMethod(targetClass, "bkpt2", "()V").location(); |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
215 |
request2 = erm.createBreakpointRequest(loc2); |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
216 |
request2.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD); |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
217 |
request2.enable(); |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
218 |
|
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
219 |
/* |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
220 |
* resume the target, listening for events |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
221 |
*/ |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
222 |
listenUntilVMDisconnect(); |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
223 |
/* |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
224 |
* deal with results of test |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
225 |
* if anything has called failure("foo") testFailed will be true |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
226 |
*/ |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
227 |
if (!testFailed) { |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
228 |
println("ResumeOneThreadTest: passed"); |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
229 |
} else { |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
230 |
throw new Exception("ResumeOneThreadTest: failed"); |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
231 |
} |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
232 |
} |
d81b1f62fb82
6700889: Thread resume invalidates all stack frames, even from other threads
jjh
parents:
diff
changeset
|
233 |
} |