Mercurial > hg > graal-compiler
annotate test/runtime/7158988/FieldMonitor.java @ 18249:e41787b05c98
StandardMethodSubstitutionsTest: get valid code for each iteration.
Solves the InvalidInstalledCodeException issue that occurred in case of a deopt.
author | Josef Eisl <josef.eisl@jku.at> |
---|---|
date | Wed, 05 Nov 2014 11:20:39 +0100 |
parents | 52b4284cb496 |
children |
rev | line source |
---|---|
5995
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
1 /* |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
2 * Copyright 2012 SAP AG. All Rights Reserved. |
19e197e2a1af
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. |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
4 * |
19e197e2a1af
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 |
19e197e2a1af
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 |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
8 * |
19e197e2a1af
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 |
19e197e2a1af
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 |
19e197e2a1af
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 |
19e197e2a1af
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 |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
13 * accompanied this code). |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
14 * |
19e197e2a1af
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 |
19e197e2a1af
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, |
19e197e2a1af
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. |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
18 * |
19e197e2a1af
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 |
19e197e2a1af
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 |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
21 * questions. |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
22 */ |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
23 |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
24 /* |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
25 * @test FieldMonitor.java |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
26 * @bug 7158988 |
7978
a7f9a1195d86
8000363: runtime/7158988/FieldMonitor.java fails with exception
ctornqvi
parents:
5995
diff
changeset
|
27 * @key regression |
5995
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
28 * @summary verify jvm does not crash while debugging |
7978
a7f9a1195d86
8000363: runtime/7158988/FieldMonitor.java fails with exception
ctornqvi
parents:
5995
diff
changeset
|
29 * @run compile TestPostFieldModification.java |
a7f9a1195d86
8000363: runtime/7158988/FieldMonitor.java fails with exception
ctornqvi
parents:
5995
diff
changeset
|
30 * @run main/othervm FieldMonitor |
5995
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
31 * @author axel.siebenborn@sap.com |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
32 */ |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
33 import java.io.BufferedReader; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
34 import java.io.IOException; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
35 import java.io.InputStream; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
36 import java.io.InputStreamReader; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
37 import java.util.Iterator; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
38 import java.util.List; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
39 import java.util.Map; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
40 |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
41 import com.sun.jdi.Bootstrap; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
42 import com.sun.jdi.Field; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
43 import com.sun.jdi.ReferenceType; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
44 import com.sun.jdi.VirtualMachine; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
45 import com.sun.jdi.connect.Connector; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
46 import com.sun.jdi.connect.IllegalConnectorArgumentsException; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
47 import com.sun.jdi.connect.LaunchingConnector; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
48 import com.sun.jdi.connect.VMStartException; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
49 import com.sun.jdi.event.ClassPrepareEvent; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
50 import com.sun.jdi.event.Event; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
51 import com.sun.jdi.event.EventQueue; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
52 import com.sun.jdi.event.EventSet; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
53 import com.sun.jdi.event.ModificationWatchpointEvent; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
54 import com.sun.jdi.event.VMDeathEvent; |
18041
52b4284cb496
Merge with jdk8u20-b26
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14909
diff
changeset
|
55 import com.sun.jdi.event.VMStartEvent; |
5995
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
56 import com.sun.jdi.event.VMDisconnectEvent; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
57 import com.sun.jdi.request.ClassPrepareRequest; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
58 import com.sun.jdi.request.EventRequest; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
59 import com.sun.jdi.request.EventRequestManager; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
60 import com.sun.jdi.request.ModificationWatchpointRequest; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
61 |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
62 public class FieldMonitor { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
63 |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
64 public static final String CLASS_NAME = "TestPostFieldModification"; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
65 public static final String FIELD_NAME = "value"; |
19e197e2a1af
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"; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
67 |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
68 public static void main(String[] args) |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
69 throws IOException, InterruptedException { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
70 |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
71 //VirtualMachine vm = launchTarget(sb.toString()); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
72 VirtualMachine vm = launchTarget(CLASS_NAME); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
73 |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
74 System.out.println("Vm launched"); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
75 |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
76 // process events |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
77 EventQueue eventQueue = vm.eventQueue(); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
78 // resume the vm |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
79 |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
80 Process process = vm.process(); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
81 |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
82 |
19e197e2a1af
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. |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
84 Thread outThread = new StreamRedirectThread("out reader", process.getInputStream()); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
85 Thread errThread = new StreamRedirectThread("error reader", process.getErrorStream()); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
86 |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
87 errThread.start(); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
88 outThread.start(); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
89 |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
90 boolean connected = true; |
18041
52b4284cb496
Merge with jdk8u20-b26
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14909
diff
changeset
|
91 int watched = 0; |
5995
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
92 while (connected) { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
93 EventSet eventSet = eventQueue.remove(); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
94 for (Event event : eventSet) { |
18041
52b4284cb496
Merge with jdk8u20-b26
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14909
diff
changeset
|
95 System.out.println("FieldMonitor-main receives: "+event); |
52b4284cb496
Merge with jdk8u20-b26
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14909
diff
changeset
|
96 if (event instanceof VMStartEvent) { |
52b4284cb496
Merge with jdk8u20-b26
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14909
diff
changeset
|
97 addClassWatch(vm); |
52b4284cb496
Merge with jdk8u20-b26
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14909
diff
changeset
|
98 } else if (event instanceof VMDeathEvent |
5995
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
99 || event instanceof VMDisconnectEvent) { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
100 // exit |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
101 connected = false; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
102 } else if (event instanceof ClassPrepareEvent) { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
103 // watch field on loaded class |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
104 System.out.println("ClassPrepareEvent"); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
105 ClassPrepareEvent classPrepEvent = (ClassPrepareEvent) event; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
106 ReferenceType refType = classPrepEvent |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
107 .referenceType(); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
108 addFieldWatch(vm, refType); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
109 } else if (event instanceof ModificationWatchpointEvent) { |
18041
52b4284cb496
Merge with jdk8u20-b26
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14909
diff
changeset
|
110 watched++; |
5995
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
111 System.out.println("sleep for 500 ms"); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
112 Thread.sleep(500); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
113 |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
114 ModificationWatchpointEvent modEvent = (ModificationWatchpointEvent) event; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
115 System.out.println("old=" |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
116 + modEvent.valueCurrent()); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
117 System.out.println("new=" + modEvent.valueToBe()); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
118 } |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
119 } |
18041
52b4284cb496
Merge with jdk8u20-b26
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14909
diff
changeset
|
120 System.out.println("resume..."); |
5995
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
121 eventSet.resume(); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
122 } |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
123 // Shutdown begins when event thread terminates |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
124 try { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
125 errThread.join(); // Make sure output is forwarded |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
126 outThread.join(); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
127 } catch (InterruptedException exc) { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
128 // we don't interrupt |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
129 } |
18041
52b4284cb496
Merge with jdk8u20-b26
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14909
diff
changeset
|
130 |
52b4284cb496
Merge with jdk8u20-b26
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14909
diff
changeset
|
131 if (watched != 11) { // init + 10 modifications in TestPostFieldModification class |
52b4284cb496
Merge with jdk8u20-b26
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14909
diff
changeset
|
132 throw new Error("Expected to receive 11 times ModificationWatchpointEvent, but got "+watched); |
52b4284cb496
Merge with jdk8u20-b26
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14909
diff
changeset
|
133 } |
5995
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
134 } |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
135 |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
136 /** |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
137 * Find a com.sun.jdi.CommandLineLaunch connector |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
138 */ |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
139 static LaunchingConnector findLaunchingConnector() { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
140 List <Connector> connectors = Bootstrap.virtualMachineManager().allConnectors(); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
141 Iterator <Connector> iter = connectors.iterator(); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
142 while (iter.hasNext()) { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
143 Connector connector = iter.next(); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
144 if (connector.name().equals("com.sun.jdi.CommandLineLaunch")) { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
145 return (LaunchingConnector)connector; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
146 } |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
147 } |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
148 throw new Error("No launching connector"); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
149 } |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
150 /** |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
151 * Return the launching connector's arguments. |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
152 */ |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
153 static Map <String,Connector.Argument> connectorArguments(LaunchingConnector connector, String mainArgs) { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
154 Map<String,Connector.Argument> arguments = connector.defaultArguments(); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
155 for (String key : arguments.keySet()) { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
156 System.out.println(key); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
157 } |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
158 |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
159 Connector.Argument mainArg = (Connector.Argument)arguments.get("main"); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
160 if (mainArg == null) { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
161 throw new Error("Bad launching connector"); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
162 } |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
163 mainArg.setValue(mainArgs); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
164 |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
165 Connector.Argument optionsArg = (Connector.Argument)arguments.get("options"); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
166 if (optionsArg == null) { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
167 throw new Error("Bad launching connector"); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
168 } |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
169 optionsArg.setValue(ARGUMENTS); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
170 return arguments; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
171 } |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
172 |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
173 static VirtualMachine launchTarget(String mainArgs) { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
174 LaunchingConnector connector = findLaunchingConnector(); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
175 Map arguments = connectorArguments(connector, mainArgs); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
176 try { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
177 return (VirtualMachine) connector.launch(arguments); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
178 } catch (IOException exc) { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
179 throw new Error("Unable to launch target VM: " + exc); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
180 } catch (IllegalConnectorArgumentsException exc) { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
181 throw new Error("Internal error: " + exc); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
182 } catch (VMStartException exc) { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
183 throw new Error("Target VM failed to initialize: " + |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
184 exc.getMessage()); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
185 } |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
186 } |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
187 |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
188 |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
189 private static void addClassWatch(VirtualMachine vm) { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
190 EventRequestManager erm = vm.eventRequestManager(); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
191 ClassPrepareRequest classPrepareRequest = erm |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
192 .createClassPrepareRequest(); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
193 classPrepareRequest.addClassFilter(CLASS_NAME); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
194 classPrepareRequest.setEnabled(true); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
195 } |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
196 |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
197 |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
198 private static void addFieldWatch(VirtualMachine vm, |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
199 ReferenceType refType) { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
200 EventRequestManager erm = vm.eventRequestManager(); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
201 Field field = refType.fieldByName(FIELD_NAME); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
202 ModificationWatchpointRequest modificationWatchpointRequest = erm |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
203 .createModificationWatchpointRequest(field); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
204 modificationWatchpointRequest.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
205 modificationWatchpointRequest.setEnabled(true); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
206 } |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
207 } |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
208 |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
209 class StreamRedirectThread extends Thread { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
210 |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
211 private final BufferedReader in; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
212 |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
213 private static final int BUFFER_SIZE = 2048; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
214 |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
215 /** |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
216 * Set up for copy. |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
217 * @param name Name of the thread |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
218 * @param in Stream to copy from |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
219 * @param out Stream to copy to |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
220 */ |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
221 StreamRedirectThread(String name, InputStream in) { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
222 super(name); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
223 this.in = new BufferedReader(new InputStreamReader(in)); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
224 } |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
225 |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
226 /** |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
227 * Copy. |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
228 */ |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
229 public void run() { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
230 try { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
231 String line; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
232 while ((line = in.readLine ()) != null) { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
233 System.out.println ("testvm: " + line); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
234 } |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
235 System.out.flush(); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
236 } catch(IOException exc) { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
237 System.err.println("Child I/O Transfer - " + exc); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
238 } |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
239 } |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
240 } |