author | kvn |
Thu, 16 Apr 2015 14:01:18 -0700 | |
changeset 30083 | 385348cd698e |
parent 26687 | eb6c5d0d1d6b |
child 35061 | be6025ebffea |
permissions | -rw-r--r-- |
12366
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
1 |
/* |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
2 |
* Copyright 2012 SAP AG. All Rights Reserved. |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
4 |
* |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
8 |
* |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
13 |
* accompanied this code). |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
14 |
* |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
18 |
* |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
21 |
* questions. |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
22 |
*/ |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
23 |
|
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
24 |
/* |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
25 |
* @test FieldMonitor.java |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
26 |
* @bug 7158988 |
15459
b0c59cfcaa15
8000363: runtime/7158988/FieldMonitor.java fails with exception
ctornqvi
parents:
12366
diff
changeset
|
27 |
* @key regression |
12366
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
28 |
* @summary verify jvm does not crash while debugging |
15459
b0c59cfcaa15
8000363: runtime/7158988/FieldMonitor.java fails with exception
ctornqvi
parents:
12366
diff
changeset
|
29 |
* @run compile TestPostFieldModification.java |
b0c59cfcaa15
8000363: runtime/7158988/FieldMonitor.java fails with exception
ctornqvi
parents:
12366
diff
changeset
|
30 |
* @run main/othervm FieldMonitor |
12366
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
31 |
* @author axel.siebenborn@sap.com |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
32 |
*/ |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
33 |
import java.io.BufferedReader; |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
34 |
import java.io.IOException; |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
35 |
import java.io.InputStream; |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
36 |
import java.io.InputStreamReader; |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
37 |
import java.util.Iterator; |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
38 |
import java.util.List; |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
39 |
import java.util.Map; |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
40 |
|
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
41 |
import com.sun.jdi.Bootstrap; |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
42 |
import com.sun.jdi.Field; |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
43 |
import com.sun.jdi.ReferenceType; |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
44 |
import com.sun.jdi.VirtualMachine; |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
45 |
import com.sun.jdi.connect.Connector; |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
46 |
import com.sun.jdi.connect.IllegalConnectorArgumentsException; |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
47 |
import com.sun.jdi.connect.LaunchingConnector; |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
48 |
import com.sun.jdi.connect.VMStartException; |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
49 |
import com.sun.jdi.event.ClassPrepareEvent; |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
50 |
import com.sun.jdi.event.Event; |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
51 |
import com.sun.jdi.event.EventQueue; |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
52 |
import com.sun.jdi.event.EventSet; |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
53 |
import com.sun.jdi.event.ModificationWatchpointEvent; |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
54 |
import com.sun.jdi.event.VMDeathEvent; |
22793
05cb9f38b9c7
8007710: runtime/7158988/FieldMonitor.java fails with com.sun.jdi.VMDisconnectedException: Connection closed
sjiang
parents:
15459
diff
changeset
|
55 |
import com.sun.jdi.event.VMStartEvent; |
12366
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
56 |
import com.sun.jdi.event.VMDisconnectEvent; |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
57 |
import com.sun.jdi.request.ClassPrepareRequest; |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
58 |
import com.sun.jdi.request.EventRequest; |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
59 |
import com.sun.jdi.request.EventRequestManager; |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
60 |
import com.sun.jdi.request.ModificationWatchpointRequest; |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
61 |
|
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
62 |
public class FieldMonitor { |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
63 |
|
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
64 |
public static final String CLASS_NAME = "TestPostFieldModification"; |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
65 |
public static final String FIELD_NAME = "value"; |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
66 |
public static final String ARGUMENTS = "-Xshare:off -XX:+PrintGC"; |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
67 |
|
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
68 |
public static void main(String[] args) |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
69 |
throws IOException, InterruptedException { |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
70 |
|
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
71 |
//VirtualMachine vm = launchTarget(sb.toString()); |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
72 |
VirtualMachine vm = launchTarget(CLASS_NAME); |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
73 |
|
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
74 |
System.out.println("Vm launched"); |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
75 |
|
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
76 |
// process events |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
77 |
EventQueue eventQueue = vm.eventQueue(); |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
78 |
// resume the vm |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
79 |
|
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
80 |
Process process = vm.process(); |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
81 |
|
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
82 |
|
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
83 |
// Copy target's output and error to our output and error. |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
84 |
Thread outThread = new StreamRedirectThread("out reader", process.getInputStream()); |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
85 |
Thread errThread = new StreamRedirectThread("error reader", process.getErrorStream()); |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
86 |
|
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
87 |
errThread.start(); |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
88 |
outThread.start(); |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
89 |
|
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
90 |
boolean connected = true; |
22793
05cb9f38b9c7
8007710: runtime/7158988/FieldMonitor.java fails with com.sun.jdi.VMDisconnectedException: Connection closed
sjiang
parents:
15459
diff
changeset
|
91 |
int watched = 0; |
12366
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
92 |
while (connected) { |
26687
eb6c5d0d1d6b
8055145: [TESTBUG] runtime/7158988/FieldMonitor.java fails with VMDisconnectedException
coleenp
parents:
26140
diff
changeset
|
93 |
try { |
eb6c5d0d1d6b
8055145: [TESTBUG] runtime/7158988/FieldMonitor.java fails with VMDisconnectedException
coleenp
parents:
26140
diff
changeset
|
94 |
EventSet eventSet = eventQueue.remove(); |
eb6c5d0d1d6b
8055145: [TESTBUG] runtime/7158988/FieldMonitor.java fails with VMDisconnectedException
coleenp
parents:
26140
diff
changeset
|
95 |
for (Event event : eventSet) { |
eb6c5d0d1d6b
8055145: [TESTBUG] runtime/7158988/FieldMonitor.java fails with VMDisconnectedException
coleenp
parents:
26140
diff
changeset
|
96 |
System.out.println("FieldMonitor-main receives: "+event); |
eb6c5d0d1d6b
8055145: [TESTBUG] runtime/7158988/FieldMonitor.java fails with VMDisconnectedException
coleenp
parents:
26140
diff
changeset
|
97 |
if (event instanceof VMStartEvent) { |
eb6c5d0d1d6b
8055145: [TESTBUG] runtime/7158988/FieldMonitor.java fails with VMDisconnectedException
coleenp
parents:
26140
diff
changeset
|
98 |
addClassWatch(vm); |
eb6c5d0d1d6b
8055145: [TESTBUG] runtime/7158988/FieldMonitor.java fails with VMDisconnectedException
coleenp
parents:
26140
diff
changeset
|
99 |
} else if (event instanceof VMDeathEvent |
eb6c5d0d1d6b
8055145: [TESTBUG] runtime/7158988/FieldMonitor.java fails with VMDisconnectedException
coleenp
parents:
26140
diff
changeset
|
100 |
|| event instanceof VMDisconnectEvent) { |
eb6c5d0d1d6b
8055145: [TESTBUG] runtime/7158988/FieldMonitor.java fails with VMDisconnectedException
coleenp
parents:
26140
diff
changeset
|
101 |
// exit |
eb6c5d0d1d6b
8055145: [TESTBUG] runtime/7158988/FieldMonitor.java fails with VMDisconnectedException
coleenp
parents:
26140
diff
changeset
|
102 |
connected = false; |
eb6c5d0d1d6b
8055145: [TESTBUG] runtime/7158988/FieldMonitor.java fails with VMDisconnectedException
coleenp
parents:
26140
diff
changeset
|
103 |
} else if (event instanceof ClassPrepareEvent) { |
eb6c5d0d1d6b
8055145: [TESTBUG] runtime/7158988/FieldMonitor.java fails with VMDisconnectedException
coleenp
parents:
26140
diff
changeset
|
104 |
// watch field on loaded class |
eb6c5d0d1d6b
8055145: [TESTBUG] runtime/7158988/FieldMonitor.java fails with VMDisconnectedException
coleenp
parents:
26140
diff
changeset
|
105 |
System.out.println("ClassPrepareEvent"); |
eb6c5d0d1d6b
8055145: [TESTBUG] runtime/7158988/FieldMonitor.java fails with VMDisconnectedException
coleenp
parents:
26140
diff
changeset
|
106 |
ClassPrepareEvent classPrepEvent = (ClassPrepareEvent) event; |
eb6c5d0d1d6b
8055145: [TESTBUG] runtime/7158988/FieldMonitor.java fails with VMDisconnectedException
coleenp
parents:
26140
diff
changeset
|
107 |
ReferenceType refType = classPrepEvent |
eb6c5d0d1d6b
8055145: [TESTBUG] runtime/7158988/FieldMonitor.java fails with VMDisconnectedException
coleenp
parents:
26140
diff
changeset
|
108 |
.referenceType(); |
eb6c5d0d1d6b
8055145: [TESTBUG] runtime/7158988/FieldMonitor.java fails with VMDisconnectedException
coleenp
parents:
26140
diff
changeset
|
109 |
addFieldWatch(vm, refType); |
eb6c5d0d1d6b
8055145: [TESTBUG] runtime/7158988/FieldMonitor.java fails with VMDisconnectedException
coleenp
parents:
26140
diff
changeset
|
110 |
} else if (event instanceof ModificationWatchpointEvent) { |
eb6c5d0d1d6b
8055145: [TESTBUG] runtime/7158988/FieldMonitor.java fails with VMDisconnectedException
coleenp
parents:
26140
diff
changeset
|
111 |
watched++; |
eb6c5d0d1d6b
8055145: [TESTBUG] runtime/7158988/FieldMonitor.java fails with VMDisconnectedException
coleenp
parents:
26140
diff
changeset
|
112 |
System.out.println("sleep for 500 ms"); |
eb6c5d0d1d6b
8055145: [TESTBUG] runtime/7158988/FieldMonitor.java fails with VMDisconnectedException
coleenp
parents:
26140
diff
changeset
|
113 |
Thread.sleep(500); |
12366
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
114 |
|
26687
eb6c5d0d1d6b
8055145: [TESTBUG] runtime/7158988/FieldMonitor.java fails with VMDisconnectedException
coleenp
parents:
26140
diff
changeset
|
115 |
ModificationWatchpointEvent modEvent = (ModificationWatchpointEvent) event; |
eb6c5d0d1d6b
8055145: [TESTBUG] runtime/7158988/FieldMonitor.java fails with VMDisconnectedException
coleenp
parents:
26140
diff
changeset
|
116 |
System.out.println("old=" |
eb6c5d0d1d6b
8055145: [TESTBUG] runtime/7158988/FieldMonitor.java fails with VMDisconnectedException
coleenp
parents:
26140
diff
changeset
|
117 |
+ modEvent.valueCurrent()); |
eb6c5d0d1d6b
8055145: [TESTBUG] runtime/7158988/FieldMonitor.java fails with VMDisconnectedException
coleenp
parents:
26140
diff
changeset
|
118 |
System.out.println("new=" + modEvent.valueToBe()); |
eb6c5d0d1d6b
8055145: [TESTBUG] runtime/7158988/FieldMonitor.java fails with VMDisconnectedException
coleenp
parents:
26140
diff
changeset
|
119 |
} |
eb6c5d0d1d6b
8055145: [TESTBUG] runtime/7158988/FieldMonitor.java fails with VMDisconnectedException
coleenp
parents:
26140
diff
changeset
|
120 |
} |
eb6c5d0d1d6b
8055145: [TESTBUG] runtime/7158988/FieldMonitor.java fails with VMDisconnectedException
coleenp
parents:
26140
diff
changeset
|
121 |
System.out.println("resume..."); |
eb6c5d0d1d6b
8055145: [TESTBUG] runtime/7158988/FieldMonitor.java fails with VMDisconnectedException
coleenp
parents:
26140
diff
changeset
|
122 |
eventSet.resume(); |
eb6c5d0d1d6b
8055145: [TESTBUG] runtime/7158988/FieldMonitor.java fails with VMDisconnectedException
coleenp
parents:
26140
diff
changeset
|
123 |
} catch (com.sun.jdi.VMDisconnectedException exc) { |
eb6c5d0d1d6b
8055145: [TESTBUG] runtime/7158988/FieldMonitor.java fails with VMDisconnectedException
coleenp
parents:
26140
diff
changeset
|
124 |
// Guess this means it's not connected anymore, |
eb6c5d0d1d6b
8055145: [TESTBUG] runtime/7158988/FieldMonitor.java fails with VMDisconnectedException
coleenp
parents:
26140
diff
changeset
|
125 |
// sometimes this happens and everything else hangs, just return. |
eb6c5d0d1d6b
8055145: [TESTBUG] runtime/7158988/FieldMonitor.java fails with VMDisconnectedException
coleenp
parents:
26140
diff
changeset
|
126 |
return; |
12366
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
127 |
} |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
128 |
} |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
129 |
// Shutdown begins when event thread terminates |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
130 |
try { |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
131 |
errThread.join(); // Make sure output is forwarded |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
132 |
outThread.join(); |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
133 |
} catch (InterruptedException exc) { |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
134 |
// we don't interrupt |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
135 |
} |
22793
05cb9f38b9c7
8007710: runtime/7158988/FieldMonitor.java fails with com.sun.jdi.VMDisconnectedException: Connection closed
sjiang
parents:
15459
diff
changeset
|
136 |
|
05cb9f38b9c7
8007710: runtime/7158988/FieldMonitor.java fails with com.sun.jdi.VMDisconnectedException: Connection closed
sjiang
parents:
15459
diff
changeset
|
137 |
if (watched != 11) { // init + 10 modifications in TestPostFieldModification class |
05cb9f38b9c7
8007710: runtime/7158988/FieldMonitor.java fails with com.sun.jdi.VMDisconnectedException: Connection closed
sjiang
parents:
15459
diff
changeset
|
138 |
throw new Error("Expected to receive 11 times ModificationWatchpointEvent, but got "+watched); |
05cb9f38b9c7
8007710: runtime/7158988/FieldMonitor.java fails with com.sun.jdi.VMDisconnectedException: Connection closed
sjiang
parents:
15459
diff
changeset
|
139 |
} |
12366
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
140 |
} |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
141 |
|
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
142 |
/** |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
143 |
* Find a com.sun.jdi.CommandLineLaunch connector |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
144 |
*/ |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
145 |
static LaunchingConnector findLaunchingConnector() { |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
146 |
List <Connector> connectors = Bootstrap.virtualMachineManager().allConnectors(); |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
147 |
Iterator <Connector> iter = connectors.iterator(); |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
148 |
while (iter.hasNext()) { |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
149 |
Connector connector = iter.next(); |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
150 |
if (connector.name().equals("com.sun.jdi.CommandLineLaunch")) { |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
151 |
return (LaunchingConnector)connector; |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
152 |
} |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
153 |
} |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
154 |
throw new Error("No launching connector"); |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
155 |
} |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
156 |
/** |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
157 |
* Return the launching connector's arguments. |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
158 |
*/ |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
159 |
static Map <String,Connector.Argument> connectorArguments(LaunchingConnector connector, String mainArgs) { |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
160 |
Map<String,Connector.Argument> arguments = connector.defaultArguments(); |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
161 |
for (String key : arguments.keySet()) { |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
162 |
System.out.println(key); |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
163 |
} |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
164 |
|
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
165 |
Connector.Argument mainArg = (Connector.Argument)arguments.get("main"); |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
166 |
if (mainArg == null) { |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
167 |
throw new Error("Bad launching connector"); |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
168 |
} |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
169 |
mainArg.setValue(mainArgs); |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
170 |
|
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
171 |
Connector.Argument optionsArg = (Connector.Argument)arguments.get("options"); |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
172 |
if (optionsArg == null) { |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
173 |
throw new Error("Bad launching connector"); |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
174 |
} |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
175 |
optionsArg.setValue(ARGUMENTS); |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
176 |
return arguments; |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
177 |
} |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
178 |
|
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
179 |
static VirtualMachine launchTarget(String mainArgs) { |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
180 |
LaunchingConnector connector = findLaunchingConnector(); |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
181 |
Map arguments = connectorArguments(connector, mainArgs); |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
182 |
try { |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
183 |
return (VirtualMachine) connector.launch(arguments); |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
184 |
} catch (IOException exc) { |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
185 |
throw new Error("Unable to launch target VM: " + exc); |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
186 |
} catch (IllegalConnectorArgumentsException exc) { |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
187 |
throw new Error("Internal error: " + exc); |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
188 |
} catch (VMStartException exc) { |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
189 |
throw new Error("Target VM failed to initialize: " + |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
190 |
exc.getMessage()); |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
191 |
} |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
192 |
} |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
193 |
|
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
194 |
|
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
195 |
private static void addClassWatch(VirtualMachine vm) { |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
196 |
EventRequestManager erm = vm.eventRequestManager(); |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
197 |
ClassPrepareRequest classPrepareRequest = erm |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
198 |
.createClassPrepareRequest(); |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
199 |
classPrepareRequest.addClassFilter(CLASS_NAME); |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
200 |
classPrepareRequest.setEnabled(true); |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
201 |
} |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
202 |
|
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
203 |
|
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
204 |
private static void addFieldWatch(VirtualMachine vm, |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
205 |
ReferenceType refType) { |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
206 |
EventRequestManager erm = vm.eventRequestManager(); |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
207 |
Field field = refType.fieldByName(FIELD_NAME); |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
208 |
ModificationWatchpointRequest modificationWatchpointRequest = erm |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
209 |
.createModificationWatchpointRequest(field); |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
210 |
modificationWatchpointRequest.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD); |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
211 |
modificationWatchpointRequest.setEnabled(true); |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
212 |
} |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
213 |
} |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
214 |
|
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
215 |
class StreamRedirectThread extends Thread { |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
216 |
|
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
217 |
private final BufferedReader in; |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
218 |
|
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
219 |
private static final int BUFFER_SIZE = 2048; |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
220 |
|
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
221 |
/** |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
222 |
* Set up for copy. |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
223 |
* @param name Name of the thread |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
224 |
* @param in Stream to copy from |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
225 |
* @param out Stream to copy to |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
226 |
*/ |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
227 |
StreamRedirectThread(String name, InputStream in) { |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
228 |
super(name); |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
229 |
this.in = new BufferedReader(new InputStreamReader(in)); |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
230 |
} |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
231 |
|
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
232 |
/** |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
233 |
* Copy. |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
234 |
*/ |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
235 |
public void run() { |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
236 |
try { |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
237 |
String line; |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
238 |
while ((line = in.readLine ()) != null) { |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
239 |
System.out.println ("testvm: " + line); |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
240 |
} |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
241 |
System.out.flush(); |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
242 |
} catch(IOException exc) { |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
243 |
System.err.println("Child I/O Transfer - " + exc); |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
244 |
} |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
245 |
} |
76be8878c0cd
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
246 |
} |