Mercurial > hg > graal-compiler
annotate test/runtime/7158988/FieldMonitor.java @ 10236:a258a8351528
Merge
author | vladidan |
---|---|
date | Tue, 07 May 2013 10:36:20 -0400 |
parents | a7f9a1195d86 |
children | cbdbdd6577f6 |
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.io.OutputStream; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
38 import java.io.OutputStreamWriter; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
39 import java.io.Reader; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
40 import java.io.Writer; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
41 import java.util.Iterator; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
42 import java.util.List; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
43 import java.util.Map; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
44 |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
45 import com.sun.jdi.Bootstrap; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
46 import com.sun.jdi.Field; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
47 import com.sun.jdi.ReferenceType; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
48 import com.sun.jdi.VirtualMachine; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
49 import com.sun.jdi.connect.Connector; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
50 import com.sun.jdi.connect.IllegalConnectorArgumentsException; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
51 import com.sun.jdi.connect.LaunchingConnector; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
52 import com.sun.jdi.connect.VMStartException; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
53 import com.sun.jdi.event.ClassPrepareEvent; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
54 import com.sun.jdi.event.Event; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
55 import com.sun.jdi.event.EventQueue; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
56 import com.sun.jdi.event.EventSet; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
57 import com.sun.jdi.event.ModificationWatchpointEvent; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
58 import com.sun.jdi.event.VMDeathEvent; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
59 import com.sun.jdi.event.VMDisconnectEvent; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
60 import com.sun.jdi.request.ClassPrepareRequest; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
61 import com.sun.jdi.request.EventRequest; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
62 import com.sun.jdi.request.EventRequestManager; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
63 import com.sun.jdi.request.ModificationWatchpointRequest; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
64 |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
65 public class FieldMonitor { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
66 |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
67 public static final String CLASS_NAME = "TestPostFieldModification"; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
68 public static final String FIELD_NAME = "value"; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
69 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
|
70 |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
71 public static void main(String[] args) |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
72 throws IOException, InterruptedException { |
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 StringBuffer sb = new StringBuffer(); |
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 for (int i=0; i < args.length; i++) { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
77 sb.append(' '); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
78 sb.append(args[i]); |
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 //VirtualMachine vm = launchTarget(sb.toString()); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
81 VirtualMachine vm = launchTarget(CLASS_NAME); |
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 System.out.println("Vm launched"); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
84 // set watch field on already loaded classes |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
85 List<ReferenceType> referenceTypes = vm |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
86 .classesByName(CLASS_NAME); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
87 for (ReferenceType refType : referenceTypes) { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
88 addFieldWatch(vm, refType); |
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 // watch for loaded classes |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
91 addClassWatch(vm); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
92 |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
93 // process events |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
94 EventQueue eventQueue = vm.eventQueue(); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
95 // resume the vm |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
96 |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
97 Process process = vm.process(); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
98 |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
99 |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
100 // 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
|
101 Thread outThread = new StreamRedirectThread("out reader", process.getInputStream()); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
102 Thread errThread = new StreamRedirectThread("error reader", process.getErrorStream()); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
103 |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
104 errThread.start(); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
105 outThread.start(); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
106 |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
107 |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
108 vm.resume(); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
109 boolean connected = true; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
110 while (connected) { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
111 EventSet eventSet = eventQueue.remove(); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
112 for (Event event : eventSet) { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
113 if (event instanceof VMDeathEvent |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
114 || event instanceof VMDisconnectEvent) { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
115 // exit |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
116 connected = false; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
117 } else if (event instanceof ClassPrepareEvent) { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
118 // watch field on loaded class |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
119 System.out.println("ClassPrepareEvent"); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
120 ClassPrepareEvent classPrepEvent = (ClassPrepareEvent) event; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
121 ReferenceType refType = classPrepEvent |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
122 .referenceType(); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
123 addFieldWatch(vm, refType); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
124 } else if (event instanceof ModificationWatchpointEvent) { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
125 System.out.println("sleep for 500 ms"); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
126 Thread.sleep(500); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
127 System.out.println("resume..."); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
128 |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
129 ModificationWatchpointEvent modEvent = (ModificationWatchpointEvent) event; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
130 System.out.println("old=" |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
131 + modEvent.valueCurrent()); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
132 System.out.println("new=" + modEvent.valueToBe()); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
133 System.out.println(); |
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 eventSet.resume(); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
137 } |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
138 // Shutdown begins when event thread terminates |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
139 try { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
140 errThread.join(); // Make sure output is forwarded |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
141 outThread.join(); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
142 } catch (InterruptedException exc) { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
143 // we don't interrupt |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
144 } |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
145 } |
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 * Find a com.sun.jdi.CommandLineLaunch 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 static LaunchingConnector findLaunchingConnector() { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
151 List <Connector> connectors = Bootstrap.virtualMachineManager().allConnectors(); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
152 Iterator <Connector> iter = connectors.iterator(); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
153 while (iter.hasNext()) { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
154 Connector connector = iter.next(); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
155 if (connector.name().equals("com.sun.jdi.CommandLineLaunch")) { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
156 return (LaunchingConnector)connector; |
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 throw new Error("No launching connector"); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
160 } |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
161 /** |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
162 * Return the launching connector's arguments. |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
163 */ |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
164 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
|
165 Map<String,Connector.Argument> arguments = connector.defaultArguments(); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
166 for (String key : arguments.keySet()) { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
167 System.out.println(key); |
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 |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
170 Connector.Argument mainArg = (Connector.Argument)arguments.get("main"); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
171 if (mainArg == null) { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
172 throw new Error("Bad launching connector"); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
173 } |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
174 mainArg.setValue(mainArgs); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
175 |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
176 Connector.Argument optionsArg = (Connector.Argument)arguments.get("options"); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
177 if (optionsArg == null) { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
178 throw new Error("Bad launching connector"); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
179 } |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
180 optionsArg.setValue(ARGUMENTS); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
181 return arguments; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
182 } |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
183 |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
184 static VirtualMachine launchTarget(String mainArgs) { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
185 LaunchingConnector connector = findLaunchingConnector(); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
186 Map arguments = connectorArguments(connector, mainArgs); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
187 try { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
188 return (VirtualMachine) connector.launch(arguments); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
189 } catch (IOException exc) { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
190 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
|
191 } catch (IllegalConnectorArgumentsException exc) { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
192 throw new Error("Internal error: " + exc); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
193 } catch (VMStartException exc) { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
194 throw new Error("Target VM failed to initialize: " + |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
195 exc.getMessage()); |
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 |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
199 |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
200 private static void addClassWatch(VirtualMachine vm) { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
201 EventRequestManager erm = vm.eventRequestManager(); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
202 ClassPrepareRequest classPrepareRequest = erm |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
203 .createClassPrepareRequest(); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
204 classPrepareRequest.addClassFilter(CLASS_NAME); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
205 classPrepareRequest.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 private static void addFieldWatch(VirtualMachine vm, |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
210 ReferenceType refType) { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
211 EventRequestManager erm = vm.eventRequestManager(); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
212 Field field = refType.fieldByName(FIELD_NAME); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
213 ModificationWatchpointRequest modificationWatchpointRequest = erm |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
214 .createModificationWatchpointRequest(field); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
215 modificationWatchpointRequest.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
216 modificationWatchpointRequest.setEnabled(true); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
217 } |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
218 } |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
219 |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
220 class StreamRedirectThread extends Thread { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
221 |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
222 private final BufferedReader in; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
223 |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
224 private static final int BUFFER_SIZE = 2048; |
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 * Set up for copy. |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
228 * @param name Name of the thread |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
229 * @param in Stream to copy from |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
230 * @param out Stream to copy to |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
231 */ |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
232 StreamRedirectThread(String name, InputStream in) { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
233 super(name); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
234 this.in = new BufferedReader(new InputStreamReader(in)); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
235 } |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
236 |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
237 /** |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
238 * Copy. |
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 public void run() { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
241 try { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
242 String line; |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
243 while ((line = in.readLine ()) != null) { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
244 System.out.println ("testvm: " + line); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
245 } |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
246 System.out.flush(); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
247 } catch(IOException exc) { |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
248 System.err.println("Child I/O Transfer - " + exc); |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
249 } |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
250 } |
19e197e2a1af
7158988: jvm crashes while debugging on x86_32 and x86_64
coleenp
parents:
diff
changeset
|
251 } |