annotate agent/src/share/classes/sun/jvm/hotspot/HotSpotAgent.java @ 17716:cdb71841f4bc

6498581: ThreadInterruptTest3 produces wrong output on Windows Summary: There is race condition between os::interrupt and os::is_interrupted on Windows. In JVM_Sleep(Thread.sleep), check if thread gets interrupted, it may see interrupted but not really interrupted so cause spurious waking up (early return from sleep). Fix by checking if interrupt event really gets set thus prevent false return. For intrinsic of _isInterrupted, on Windows, go fastpath only on bit not set. Reviewed-by: acorn, kvn Contributed-by: david.holmes@oracle.com, yumin.qi@oracle.com
author minqi
date Wed, 26 Feb 2014 15:20:41 -0800
parents 38ea2efa32a7
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
8750
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 6782
diff changeset
2 * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 package sun.jvm.hotspot;
a61af66fc99e Initial load
duke
parents:
diff changeset
26
10229
f6a055fcf47d 8005038: remove crufty '_g' support from SA
sla
parents: 8750
diff changeset
27 import java.rmi.RemoteException;
11054
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
28 import java.lang.reflect.Constructor;
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
29 import java.lang.reflect.InvocationTargetException;
10229
f6a055fcf47d 8005038: remove crufty '_g' support from SA
sla
parents: 8750
diff changeset
30
f6a055fcf47d 8005038: remove crufty '_g' support from SA
sla
parents: 8750
diff changeset
31 import sun.jvm.hotspot.debugger.Debugger;
f6a055fcf47d 8005038: remove crufty '_g' support from SA
sla
parents: 8750
diff changeset
32 import sun.jvm.hotspot.debugger.DebuggerException;
f6a055fcf47d 8005038: remove crufty '_g' support from SA
sla
parents: 8750
diff changeset
33 import sun.jvm.hotspot.debugger.JVMDebugger;
f6a055fcf47d 8005038: remove crufty '_g' support from SA
sla
parents: 8750
diff changeset
34 import sun.jvm.hotspot.debugger.MachineDescription;
f6a055fcf47d 8005038: remove crufty '_g' support from SA
sla
parents: 8750
diff changeset
35 import sun.jvm.hotspot.debugger.MachineDescriptionAMD64;
f6a055fcf47d 8005038: remove crufty '_g' support from SA
sla
parents: 8750
diff changeset
36 import sun.jvm.hotspot.debugger.MachineDescriptionIA64;
f6a055fcf47d 8005038: remove crufty '_g' support from SA
sla
parents: 8750
diff changeset
37 import sun.jvm.hotspot.debugger.MachineDescriptionIntelX86;
f6a055fcf47d 8005038: remove crufty '_g' support from SA
sla
parents: 8750
diff changeset
38 import sun.jvm.hotspot.debugger.MachineDescriptionSPARC32Bit;
f6a055fcf47d 8005038: remove crufty '_g' support from SA
sla
parents: 8750
diff changeset
39 import sun.jvm.hotspot.debugger.MachineDescriptionSPARC64Bit;
f6a055fcf47d 8005038: remove crufty '_g' support from SA
sla
parents: 8750
diff changeset
40 import sun.jvm.hotspot.debugger.NoSuchSymbolException;
f6a055fcf47d 8005038: remove crufty '_g' support from SA
sla
parents: 8750
diff changeset
41 import sun.jvm.hotspot.debugger.bsd.BsdDebuggerLocal;
f6a055fcf47d 8005038: remove crufty '_g' support from SA
sla
parents: 8750
diff changeset
42 import sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal;
f6a055fcf47d 8005038: remove crufty '_g' support from SA
sla
parents: 8750
diff changeset
43 import sun.jvm.hotspot.debugger.proc.ProcDebuggerLocal;
f6a055fcf47d 8005038: remove crufty '_g' support from SA
sla
parents: 8750
diff changeset
44 import sun.jvm.hotspot.debugger.remote.RemoteDebugger;
f6a055fcf47d 8005038: remove crufty '_g' support from SA
sla
parents: 8750
diff changeset
45 import sun.jvm.hotspot.debugger.remote.RemoteDebuggerClient;
f6a055fcf47d 8005038: remove crufty '_g' support from SA
sla
parents: 8750
diff changeset
46 import sun.jvm.hotspot.debugger.remote.RemoteDebuggerServer;
f6a055fcf47d 8005038: remove crufty '_g' support from SA
sla
parents: 8750
diff changeset
47 import sun.jvm.hotspot.debugger.windbg.WindbgDebuggerLocal;
f6a055fcf47d 8005038: remove crufty '_g' support from SA
sla
parents: 8750
diff changeset
48 import sun.jvm.hotspot.runtime.VM;
f6a055fcf47d 8005038: remove crufty '_g' support from SA
sla
parents: 8750
diff changeset
49 import sun.jvm.hotspot.types.TypeDataBase;
f6a055fcf47d 8005038: remove crufty '_g' support from SA
sla
parents: 8750
diff changeset
50 import sun.jvm.hotspot.utilities.PlatformInfo;
f6a055fcf47d 8005038: remove crufty '_g' support from SA
sla
parents: 8750
diff changeset
51 import sun.jvm.hotspot.utilities.UnsupportedPlatformException;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
52
a61af66fc99e Initial load
duke
parents:
diff changeset
53 /** <P> This class wraps much of the basic functionality and is the
a61af66fc99e Initial load
duke
parents:
diff changeset
54 * highest-level factory for VM data structures. It makes it simple
a61af66fc99e Initial load
duke
parents:
diff changeset
55 * to start up the debugging system. </P>
a61af66fc99e Initial load
duke
parents:
diff changeset
56 *
a61af66fc99e Initial load
duke
parents:
diff changeset
57 * <P> FIXME: especially with the addition of remote debugging, this
a61af66fc99e Initial load
duke
parents:
diff changeset
58 * has turned into a mess; needs rethinking. </P>
a61af66fc99e Initial load
duke
parents:
diff changeset
59 */
a61af66fc99e Initial load
duke
parents:
diff changeset
60
a61af66fc99e Initial load
duke
parents:
diff changeset
61 public class HotSpotAgent {
a61af66fc99e Initial load
duke
parents:
diff changeset
62 private JVMDebugger debugger;
a61af66fc99e Initial load
duke
parents:
diff changeset
63 private MachineDescription machDesc;
a61af66fc99e Initial load
duke
parents:
diff changeset
64 private TypeDataBase db;
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66 private String os;
a61af66fc99e Initial load
duke
parents:
diff changeset
67 private String cpu;
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 // The system can work in several ways:
a61af66fc99e Initial load
duke
parents:
diff changeset
70 // - Attaching to local process
a61af66fc99e Initial load
duke
parents:
diff changeset
71 // - Attaching to local core file
a61af66fc99e Initial load
duke
parents:
diff changeset
72 // - Connecting to remote debug server
a61af66fc99e Initial load
duke
parents:
diff changeset
73 // - Starting debug server for process
a61af66fc99e Initial load
duke
parents:
diff changeset
74 // - Starting debug server for core file
a61af66fc99e Initial load
duke
parents:
diff changeset
75
a61af66fc99e Initial load
duke
parents:
diff changeset
76 // These are options for the "client" side of things
a61af66fc99e Initial load
duke
parents:
diff changeset
77 private static final int PROCESS_MODE = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
78 private static final int CORE_FILE_MODE = 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
79 private static final int REMOTE_MODE = 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
80 private int startupMode;
a61af66fc99e Initial load
duke
parents:
diff changeset
81
a61af66fc99e Initial load
duke
parents:
diff changeset
82 // This indicates whether we are really starting a server or not
a61af66fc99e Initial load
duke
parents:
diff changeset
83 private boolean isServer;
a61af66fc99e Initial load
duke
parents:
diff changeset
84
a61af66fc99e Initial load
duke
parents:
diff changeset
85 // All possible required information for connecting
a61af66fc99e Initial load
duke
parents:
diff changeset
86 private int pid;
a61af66fc99e Initial load
duke
parents:
diff changeset
87 private String javaExecutableName;
a61af66fc99e Initial load
duke
parents:
diff changeset
88 private String coreFileName;
a61af66fc99e Initial load
duke
parents:
diff changeset
89 private String debugServerID;
a61af66fc99e Initial load
duke
parents:
diff changeset
90
a61af66fc99e Initial load
duke
parents:
diff changeset
91 // All needed information for server side
a61af66fc99e Initial load
duke
parents:
diff changeset
92 private String serverID;
a61af66fc99e Initial load
duke
parents:
diff changeset
93
a61af66fc99e Initial load
duke
parents:
diff changeset
94 private String[] jvmLibNames;
a61af66fc99e Initial load
duke
parents:
diff changeset
95
a61af66fc99e Initial load
duke
parents:
diff changeset
96 static void showUsage() {
a61af66fc99e Initial load
duke
parents:
diff changeset
97 }
a61af66fc99e Initial load
duke
parents:
diff changeset
98
a61af66fc99e Initial load
duke
parents:
diff changeset
99 public HotSpotAgent() {
a61af66fc99e Initial load
duke
parents:
diff changeset
100 // for non-server add shutdown hook to clean-up debugger in case
a61af66fc99e Initial load
duke
parents:
diff changeset
101 // of forced exit. For remote server, shutdown hook is added by
a61af66fc99e Initial load
duke
parents:
diff changeset
102 // DebugServer.
a61af66fc99e Initial load
duke
parents:
diff changeset
103 Runtime.getRuntime().addShutdownHook(new java.lang.Thread(
a61af66fc99e Initial load
duke
parents:
diff changeset
104 new Runnable() {
a61af66fc99e Initial load
duke
parents:
diff changeset
105 public void run() {
a61af66fc99e Initial load
duke
parents:
diff changeset
106 synchronized (HotSpotAgent.this) {
a61af66fc99e Initial load
duke
parents:
diff changeset
107 if (!isServer) {
a61af66fc99e Initial load
duke
parents:
diff changeset
108 detach();
a61af66fc99e Initial load
duke
parents:
diff changeset
109 }
a61af66fc99e Initial load
duke
parents:
diff changeset
110 }
a61af66fc99e Initial load
duke
parents:
diff changeset
111 }
a61af66fc99e Initial load
duke
parents:
diff changeset
112 }));
a61af66fc99e Initial load
duke
parents:
diff changeset
113 }
a61af66fc99e Initial load
duke
parents:
diff changeset
114
a61af66fc99e Initial load
duke
parents:
diff changeset
115 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
116 // Accessors (once the system is set up)
a61af66fc99e Initial load
duke
parents:
diff changeset
117 //
a61af66fc99e Initial load
duke
parents:
diff changeset
118
a61af66fc99e Initial load
duke
parents:
diff changeset
119 public synchronized Debugger getDebugger() {
a61af66fc99e Initial load
duke
parents:
diff changeset
120 return debugger;
a61af66fc99e Initial load
duke
parents:
diff changeset
121 }
a61af66fc99e Initial load
duke
parents:
diff changeset
122
a61af66fc99e Initial load
duke
parents:
diff changeset
123 public synchronized TypeDataBase getTypeDataBase() {
a61af66fc99e Initial load
duke
parents:
diff changeset
124 return db;
a61af66fc99e Initial load
duke
parents:
diff changeset
125 }
a61af66fc99e Initial load
duke
parents:
diff changeset
126
a61af66fc99e Initial load
duke
parents:
diff changeset
127 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
128 // Client-side operations
a61af66fc99e Initial load
duke
parents:
diff changeset
129 //
a61af66fc99e Initial load
duke
parents:
diff changeset
130
a61af66fc99e Initial load
duke
parents:
diff changeset
131 /** This attaches to a process running on the local machine. */
a61af66fc99e Initial load
duke
parents:
diff changeset
132 public synchronized void attach(int processID)
a61af66fc99e Initial load
duke
parents:
diff changeset
133 throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
134 if (debugger != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
135 throw new DebuggerException("Already attached");
a61af66fc99e Initial load
duke
parents:
diff changeset
136 }
a61af66fc99e Initial load
duke
parents:
diff changeset
137 pid = processID;
a61af66fc99e Initial load
duke
parents:
diff changeset
138 startupMode = PROCESS_MODE;
a61af66fc99e Initial load
duke
parents:
diff changeset
139 isServer = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
140 go();
a61af66fc99e Initial load
duke
parents:
diff changeset
141 }
a61af66fc99e Initial load
duke
parents:
diff changeset
142
a61af66fc99e Initial load
duke
parents:
diff changeset
143 /** This opens a core file on the local machine */
a61af66fc99e Initial load
duke
parents:
diff changeset
144 public synchronized void attach(String javaExecutableName, String coreFileName)
a61af66fc99e Initial load
duke
parents:
diff changeset
145 throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
146 if (debugger != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
147 throw new DebuggerException("Already attached");
a61af66fc99e Initial load
duke
parents:
diff changeset
148 }
a61af66fc99e Initial load
duke
parents:
diff changeset
149 if ((javaExecutableName == null) || (coreFileName == null)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
150 throw new DebuggerException("Both the core file name and Java executable name must be specified");
a61af66fc99e Initial load
duke
parents:
diff changeset
151 }
a61af66fc99e Initial load
duke
parents:
diff changeset
152 this.javaExecutableName = javaExecutableName;
a61af66fc99e Initial load
duke
parents:
diff changeset
153 this.coreFileName = coreFileName;
a61af66fc99e Initial load
duke
parents:
diff changeset
154 startupMode = CORE_FILE_MODE;
a61af66fc99e Initial load
duke
parents:
diff changeset
155 isServer = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
156 go();
a61af66fc99e Initial load
duke
parents:
diff changeset
157 }
a61af66fc99e Initial load
duke
parents:
diff changeset
158
11054
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
159 /** This uses a JVMDebugger that is already attached to the core or process */
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
160 public synchronized void attach(JVMDebugger d)
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
161 throws DebuggerException {
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
162 debugger = d;
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
163 isServer = false;
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
164 go();
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
165 }
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
166
0
a61af66fc99e Initial load
duke
parents:
diff changeset
167 /** This attaches to a "debug server" on a remote machine; this
a61af66fc99e Initial load
duke
parents:
diff changeset
168 remote server has already attached to a process or opened a
a61af66fc99e Initial load
duke
parents:
diff changeset
169 core file and is waiting for RMI calls on the Debugger object to
a61af66fc99e Initial load
duke
parents:
diff changeset
170 come in. */
a61af66fc99e Initial load
duke
parents:
diff changeset
171 public synchronized void attach(String remoteServerID)
a61af66fc99e Initial load
duke
parents:
diff changeset
172 throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
173 if (debugger != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
174 throw new DebuggerException("Already attached to a process");
a61af66fc99e Initial load
duke
parents:
diff changeset
175 }
a61af66fc99e Initial load
duke
parents:
diff changeset
176 if (remoteServerID == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
177 throw new DebuggerException("Debug server id must be specified");
a61af66fc99e Initial load
duke
parents:
diff changeset
178 }
a61af66fc99e Initial load
duke
parents:
diff changeset
179
a61af66fc99e Initial load
duke
parents:
diff changeset
180 debugServerID = remoteServerID;
a61af66fc99e Initial load
duke
parents:
diff changeset
181 startupMode = REMOTE_MODE;
a61af66fc99e Initial load
duke
parents:
diff changeset
182 isServer = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
183 go();
a61af66fc99e Initial load
duke
parents:
diff changeset
184 }
a61af66fc99e Initial load
duke
parents:
diff changeset
185
a61af66fc99e Initial load
duke
parents:
diff changeset
186 /** This should only be called by the user on the client machine,
a61af66fc99e Initial load
duke
parents:
diff changeset
187 not the server machine */
a61af66fc99e Initial load
duke
parents:
diff changeset
188 public synchronized boolean detach() throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
189 if (isServer) {
a61af66fc99e Initial load
duke
parents:
diff changeset
190 throw new DebuggerException("Should not call detach() for server configuration");
a61af66fc99e Initial load
duke
parents:
diff changeset
191 }
a61af66fc99e Initial load
duke
parents:
diff changeset
192 return detachInternal();
a61af66fc99e Initial load
duke
parents:
diff changeset
193 }
a61af66fc99e Initial load
duke
parents:
diff changeset
194
a61af66fc99e Initial load
duke
parents:
diff changeset
195 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
196 // Server-side operations
a61af66fc99e Initial load
duke
parents:
diff changeset
197 //
a61af66fc99e Initial load
duke
parents:
diff changeset
198
a61af66fc99e Initial load
duke
parents:
diff changeset
199 /** This attaches to a process running on the local machine and
a61af66fc99e Initial load
duke
parents:
diff changeset
200 starts a debug server, allowing remote machines to connect and
a61af66fc99e Initial load
duke
parents:
diff changeset
201 examine this process. Uses specified name to uniquely identify a
a61af66fc99e Initial load
duke
parents:
diff changeset
202 specific debuggee on the server */
a61af66fc99e Initial load
duke
parents:
diff changeset
203 public synchronized void startServer(int processID, String uniqueID) {
a61af66fc99e Initial load
duke
parents:
diff changeset
204 if (debugger != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
205 throw new DebuggerException("Already attached");
a61af66fc99e Initial load
duke
parents:
diff changeset
206 }
a61af66fc99e Initial load
duke
parents:
diff changeset
207 pid = processID;
a61af66fc99e Initial load
duke
parents:
diff changeset
208 startupMode = PROCESS_MODE;
a61af66fc99e Initial load
duke
parents:
diff changeset
209 isServer = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
210 serverID = uniqueID;
a61af66fc99e Initial load
duke
parents:
diff changeset
211 go();
a61af66fc99e Initial load
duke
parents:
diff changeset
212 }
a61af66fc99e Initial load
duke
parents:
diff changeset
213
a61af66fc99e Initial load
duke
parents:
diff changeset
214 /** This attaches to a process running on the local machine and
a61af66fc99e Initial load
duke
parents:
diff changeset
215 starts a debug server, allowing remote machines to connect and
a61af66fc99e Initial load
duke
parents:
diff changeset
216 examine this process. */
a61af66fc99e Initial load
duke
parents:
diff changeset
217 public synchronized void startServer(int processID)
a61af66fc99e Initial load
duke
parents:
diff changeset
218 throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
219 startServer(processID, null);
a61af66fc99e Initial load
duke
parents:
diff changeset
220 }
a61af66fc99e Initial load
duke
parents:
diff changeset
221
a61af66fc99e Initial load
duke
parents:
diff changeset
222 /** This opens a core file on the local machine and starts a debug
a61af66fc99e Initial load
duke
parents:
diff changeset
223 server, allowing remote machines to connect and examine this
a61af66fc99e Initial load
duke
parents:
diff changeset
224 core file. Uses supplied uniqueID to uniquely identify a specific
a61af66fc99e Initial load
duke
parents:
diff changeset
225 debugee */
a61af66fc99e Initial load
duke
parents:
diff changeset
226 public synchronized void startServer(String javaExecutableName,
a61af66fc99e Initial load
duke
parents:
diff changeset
227 String coreFileName,
a61af66fc99e Initial load
duke
parents:
diff changeset
228 String uniqueID) {
a61af66fc99e Initial load
duke
parents:
diff changeset
229 if (debugger != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
230 throw new DebuggerException("Already attached");
a61af66fc99e Initial load
duke
parents:
diff changeset
231 }
a61af66fc99e Initial load
duke
parents:
diff changeset
232 if ((javaExecutableName == null) || (coreFileName == null)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
233 throw new DebuggerException("Both the core file name and Java executable name must be specified");
a61af66fc99e Initial load
duke
parents:
diff changeset
234 }
a61af66fc99e Initial load
duke
parents:
diff changeset
235 this.javaExecutableName = javaExecutableName;
a61af66fc99e Initial load
duke
parents:
diff changeset
236 this.coreFileName = coreFileName;
a61af66fc99e Initial load
duke
parents:
diff changeset
237 startupMode = CORE_FILE_MODE;
a61af66fc99e Initial load
duke
parents:
diff changeset
238 isServer = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
239 serverID = uniqueID;
a61af66fc99e Initial load
duke
parents:
diff changeset
240 go();
a61af66fc99e Initial load
duke
parents:
diff changeset
241 }
a61af66fc99e Initial load
duke
parents:
diff changeset
242
a61af66fc99e Initial load
duke
parents:
diff changeset
243 /** This opens a core file on the local machine and starts a debug
a61af66fc99e Initial load
duke
parents:
diff changeset
244 server, allowing remote machines to connect and examine this
a61af66fc99e Initial load
duke
parents:
diff changeset
245 core file. */
a61af66fc99e Initial load
duke
parents:
diff changeset
246 public synchronized void startServer(String javaExecutableName, String coreFileName)
a61af66fc99e Initial load
duke
parents:
diff changeset
247 throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
248 startServer(javaExecutableName, coreFileName, null);
a61af66fc99e Initial load
duke
parents:
diff changeset
249 }
a61af66fc99e Initial load
duke
parents:
diff changeset
250
a61af66fc99e Initial load
duke
parents:
diff changeset
251 /** This may only be called on the server side after startServer()
a61af66fc99e Initial load
duke
parents:
diff changeset
252 has been called */
a61af66fc99e Initial load
duke
parents:
diff changeset
253 public synchronized boolean shutdownServer() throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
254 if (!isServer) {
a61af66fc99e Initial load
duke
parents:
diff changeset
255 throw new DebuggerException("Should not call shutdownServer() for client configuration");
a61af66fc99e Initial load
duke
parents:
diff changeset
256 }
a61af66fc99e Initial load
duke
parents:
diff changeset
257 return detachInternal();
a61af66fc99e Initial load
duke
parents:
diff changeset
258 }
a61af66fc99e Initial load
duke
parents:
diff changeset
259
a61af66fc99e Initial load
duke
parents:
diff changeset
260
a61af66fc99e Initial load
duke
parents:
diff changeset
261 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
262 // Internals only below this point
a61af66fc99e Initial load
duke
parents:
diff changeset
263 //
a61af66fc99e Initial load
duke
parents:
diff changeset
264
a61af66fc99e Initial load
duke
parents:
diff changeset
265 private boolean detachInternal() {
a61af66fc99e Initial load
duke
parents:
diff changeset
266 if (debugger == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
267 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
268 }
a61af66fc99e Initial load
duke
parents:
diff changeset
269 boolean retval = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
270 if (!isServer) {
a61af66fc99e Initial load
duke
parents:
diff changeset
271 VM.shutdown();
a61af66fc99e Initial load
duke
parents:
diff changeset
272 }
a61af66fc99e Initial load
duke
parents:
diff changeset
273 // We must not call detach() if we are a client and are connected
a61af66fc99e Initial load
duke
parents:
diff changeset
274 // to a remote debugger
a61af66fc99e Initial load
duke
parents:
diff changeset
275 Debugger dbg = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
276 DebuggerException ex = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
277 if (isServer) {
a61af66fc99e Initial load
duke
parents:
diff changeset
278 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
279 RMIHelper.unbind(serverID);
a61af66fc99e Initial load
duke
parents:
diff changeset
280 }
a61af66fc99e Initial load
duke
parents:
diff changeset
281 catch (DebuggerException de) {
a61af66fc99e Initial load
duke
parents:
diff changeset
282 ex = de;
a61af66fc99e Initial load
duke
parents:
diff changeset
283 }
a61af66fc99e Initial load
duke
parents:
diff changeset
284 dbg = debugger;
a61af66fc99e Initial load
duke
parents:
diff changeset
285 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
286 if (startupMode != REMOTE_MODE) {
a61af66fc99e Initial load
duke
parents:
diff changeset
287 dbg = debugger;
a61af66fc99e Initial load
duke
parents:
diff changeset
288 }
a61af66fc99e Initial load
duke
parents:
diff changeset
289 }
a61af66fc99e Initial load
duke
parents:
diff changeset
290 if (dbg != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
291 retval = dbg.detach();
a61af66fc99e Initial load
duke
parents:
diff changeset
292 }
a61af66fc99e Initial load
duke
parents:
diff changeset
293
a61af66fc99e Initial load
duke
parents:
diff changeset
294 debugger = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
295 machDesc = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
296 db = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
297 if (ex != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
298 throw(ex);
a61af66fc99e Initial load
duke
parents:
diff changeset
299 }
a61af66fc99e Initial load
duke
parents:
diff changeset
300 return retval;
a61af66fc99e Initial load
duke
parents:
diff changeset
301 }
a61af66fc99e Initial load
duke
parents:
diff changeset
302
a61af66fc99e Initial load
duke
parents:
diff changeset
303 private void go() {
a61af66fc99e Initial load
duke
parents:
diff changeset
304 setupDebugger();
a61af66fc99e Initial load
duke
parents:
diff changeset
305 setupVM();
a61af66fc99e Initial load
duke
parents:
diff changeset
306 }
a61af66fc99e Initial load
duke
parents:
diff changeset
307
a61af66fc99e Initial load
duke
parents:
diff changeset
308 private void setupDebugger() {
a61af66fc99e Initial load
duke
parents:
diff changeset
309 if (startupMode != REMOTE_MODE) {
a61af66fc99e Initial load
duke
parents:
diff changeset
310 //
a61af66fc99e Initial load
duke
parents:
diff changeset
311 // Local mode (client attaching to local process or setting up
a61af66fc99e Initial load
duke
parents:
diff changeset
312 // server, but not client attaching to server)
a61af66fc99e Initial load
duke
parents:
diff changeset
313 //
a61af66fc99e Initial load
duke
parents:
diff changeset
314
11054
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
315 // Handle existing or alternate JVMDebugger:
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
316 // these will set os, cpu independently of our PlatformInfo implementation.
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
317 String alternateDebugger = System.getProperty("sa.altDebugger");
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
318 if (debugger != null) {
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
319 setupDebuggerExisting();
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
320
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
321 } else if (alternateDebugger != null) {
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
322 setupDebuggerAlternate(alternateDebugger);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
323
a61af66fc99e Initial load
duke
parents:
diff changeset
324 } else {
11054
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
325 // Otherwise, os, cpu are those of our current platform:
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
326 try {
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
327 os = PlatformInfo.getOS();
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
328 cpu = PlatformInfo.getCPU();
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
329 } catch (UnsupportedPlatformException e) {
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
330 throw new DebuggerException(e);
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
331 }
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
332 if (os.equals("solaris")) {
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
333 setupDebuggerSolaris();
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
334 } else if (os.equals("win32")) {
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
335 setupDebuggerWin32();
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
336 } else if (os.equals("linux")) {
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
337 setupDebuggerLinux();
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
338 } else if (os.equals("bsd")) {
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
339 setupDebuggerBsd();
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
340 } else if (os.equals("darwin")) {
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
341 setupDebuggerDarwin();
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
342 } else {
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
343 // Add support for more operating systems here
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
344 throw new DebuggerException("Operating system " + os + " not yet supported");
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
345 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
346 }
a61af66fc99e Initial load
duke
parents:
diff changeset
347
a61af66fc99e Initial load
duke
parents:
diff changeset
348 if (isServer) {
a61af66fc99e Initial load
duke
parents:
diff changeset
349 RemoteDebuggerServer remote = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
350 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
351 remote = new RemoteDebuggerServer(debugger);
a61af66fc99e Initial load
duke
parents:
diff changeset
352 }
a61af66fc99e Initial load
duke
parents:
diff changeset
353 catch (RemoteException rem) {
a61af66fc99e Initial load
duke
parents:
diff changeset
354 throw new DebuggerException(rem);
a61af66fc99e Initial load
duke
parents:
diff changeset
355 }
a61af66fc99e Initial load
duke
parents:
diff changeset
356 RMIHelper.rebind(serverID, remote);
a61af66fc99e Initial load
duke
parents:
diff changeset
357 }
a61af66fc99e Initial load
duke
parents:
diff changeset
358 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
359 //
a61af66fc99e Initial load
duke
parents:
diff changeset
360 // Remote mode (client attaching to server)
a61af66fc99e Initial load
duke
parents:
diff changeset
361 //
a61af66fc99e Initial load
duke
parents:
diff changeset
362
a61af66fc99e Initial load
duke
parents:
diff changeset
363 // Create and install a security manager
a61af66fc99e Initial load
duke
parents:
diff changeset
364
a61af66fc99e Initial load
duke
parents:
diff changeset
365 // FIXME: currently commented out because we were having
a61af66fc99e Initial load
duke
parents:
diff changeset
366 // security problems since we're "in the sun.* hierarchy" here.
a61af66fc99e Initial load
duke
parents:
diff changeset
367 // Perhaps a permissive policy file would work around this. In
a61af66fc99e Initial load
duke
parents:
diff changeset
368 // the long run, will probably have to move into com.sun.*.
a61af66fc99e Initial load
duke
parents:
diff changeset
369
a61af66fc99e Initial load
duke
parents:
diff changeset
370 // if (System.getSecurityManager() == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
371 // System.setSecurityManager(new RMISecurityManager());
a61af66fc99e Initial load
duke
parents:
diff changeset
372 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
373
a61af66fc99e Initial load
duke
parents:
diff changeset
374 connectRemoteDebugger();
a61af66fc99e Initial load
duke
parents:
diff changeset
375 }
a61af66fc99e Initial load
duke
parents:
diff changeset
376 }
a61af66fc99e Initial load
duke
parents:
diff changeset
377
a61af66fc99e Initial load
duke
parents:
diff changeset
378 private void setupVM() {
a61af66fc99e Initial load
duke
parents:
diff changeset
379 // We need to instantiate a HotSpotTypeDataBase on both the client
a61af66fc99e Initial load
duke
parents:
diff changeset
380 // and server machine. On the server it is only currently used to
a61af66fc99e Initial load
duke
parents:
diff changeset
381 // configure the Java primitive type sizes (which we should
a61af66fc99e Initial load
duke
parents:
diff changeset
382 // consider making constant). On the client it is used to
a61af66fc99e Initial load
duke
parents:
diff changeset
383 // configure the VM.
a61af66fc99e Initial load
duke
parents:
diff changeset
384
a61af66fc99e Initial load
duke
parents:
diff changeset
385 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
386 if (os.equals("solaris")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
387 db = new HotSpotTypeDataBase(machDesc,
a61af66fc99e Initial load
duke
parents:
diff changeset
388 new HotSpotSolarisVtblAccess(debugger, jvmLibNames),
a61af66fc99e Initial load
duke
parents:
diff changeset
389 debugger, jvmLibNames);
a61af66fc99e Initial load
duke
parents:
diff changeset
390 } else if (os.equals("win32")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
391 db = new HotSpotTypeDataBase(machDesc,
a61af66fc99e Initial load
duke
parents:
diff changeset
392 new Win32VtblAccess(debugger, jvmLibNames),
a61af66fc99e Initial load
duke
parents:
diff changeset
393 debugger, jvmLibNames);
a61af66fc99e Initial load
duke
parents:
diff changeset
394 } else if (os.equals("linux")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
395 db = new HotSpotTypeDataBase(machDesc,
a61af66fc99e Initial load
duke
parents:
diff changeset
396 new LinuxVtblAccess(debugger, jvmLibNames),
a61af66fc99e Initial load
duke
parents:
diff changeset
397 debugger, jvmLibNames);
3960
f08d439fab8c 7089790: integrate bsd-port changes
never
parents: 3939
diff changeset
398 } else if (os.equals("bsd")) {
f08d439fab8c 7089790: integrate bsd-port changes
never
parents: 3939
diff changeset
399 db = new HotSpotTypeDataBase(machDesc,
f08d439fab8c 7089790: integrate bsd-port changes
never
parents: 3939
diff changeset
400 new BsdVtblAccess(debugger, jvmLibNames),
f08d439fab8c 7089790: integrate bsd-port changes
never
parents: 3939
diff changeset
401 debugger, jvmLibNames);
8750
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 6782
diff changeset
402 } else if (os.equals("darwin")) {
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 6782
diff changeset
403 db = new HotSpotTypeDataBase(machDesc,
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 6782
diff changeset
404 new BsdVtblAccess(debugger, jvmLibNames),
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 6782
diff changeset
405 debugger, jvmLibNames);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
406 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
407 throw new DebuggerException("OS \"" + os + "\" not yet supported (no VtblAccess yet)");
a61af66fc99e Initial load
duke
parents:
diff changeset
408 }
a61af66fc99e Initial load
duke
parents:
diff changeset
409 }
a61af66fc99e Initial load
duke
parents:
diff changeset
410 catch (NoSuchSymbolException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
411 throw new DebuggerException("Doesn't appear to be a HotSpot VM (could not find symbol \"" +
a61af66fc99e Initial load
duke
parents:
diff changeset
412 e.getSymbol() + "\" in remote process)");
a61af66fc99e Initial load
duke
parents:
diff changeset
413 }
a61af66fc99e Initial load
duke
parents:
diff changeset
414
a61af66fc99e Initial load
duke
parents:
diff changeset
415 if (startupMode != REMOTE_MODE) {
a61af66fc99e Initial load
duke
parents:
diff changeset
416 // Configure the debugger with the primitive type sizes just obtained from the VM
a61af66fc99e Initial load
duke
parents:
diff changeset
417 debugger.configureJavaPrimitiveTypeSizes(db.getJBooleanType().getSize(),
a61af66fc99e Initial load
duke
parents:
diff changeset
418 db.getJByteType().getSize(),
a61af66fc99e Initial load
duke
parents:
diff changeset
419 db.getJCharType().getSize(),
a61af66fc99e Initial load
duke
parents:
diff changeset
420 db.getJDoubleType().getSize(),
a61af66fc99e Initial load
duke
parents:
diff changeset
421 db.getJFloatType().getSize(),
a61af66fc99e Initial load
duke
parents:
diff changeset
422 db.getJIntType().getSize(),
a61af66fc99e Initial load
duke
parents:
diff changeset
423 db.getJLongType().getSize(),
a61af66fc99e Initial load
duke
parents:
diff changeset
424 db.getJShortType().getSize());
a61af66fc99e Initial load
duke
parents:
diff changeset
425 }
a61af66fc99e Initial load
duke
parents:
diff changeset
426
a61af66fc99e Initial load
duke
parents:
diff changeset
427 if (!isServer) {
a61af66fc99e Initial load
duke
parents:
diff changeset
428 // Do not initialize the VM on the server (unnecessary, since it's
a61af66fc99e Initial load
duke
parents:
diff changeset
429 // instantiated on the client)
a61af66fc99e Initial load
duke
parents:
diff changeset
430 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
431 VM.initialize(db, debugger);
a61af66fc99e Initial load
duke
parents:
diff changeset
432 } catch (DebuggerException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
433 throw (e);
a61af66fc99e Initial load
duke
parents:
diff changeset
434 } catch (Exception e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
435 throw new DebuggerException(e);
a61af66fc99e Initial load
duke
parents:
diff changeset
436 }
a61af66fc99e Initial load
duke
parents:
diff changeset
437 }
a61af66fc99e Initial load
duke
parents:
diff changeset
438 }
a61af66fc99e Initial load
duke
parents:
diff changeset
439
a61af66fc99e Initial load
duke
parents:
diff changeset
440 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
441 // OS-specific debugger setup/connect routines
a61af66fc99e Initial load
duke
parents:
diff changeset
442 //
a61af66fc99e Initial load
duke
parents:
diff changeset
443
11054
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
444 // Use the existing JVMDebugger, as passed to our constructor.
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
445 // Retrieve os and cpu from that debugger, not the current platform.
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
446 private void setupDebuggerExisting() {
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
447
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
448 os = debugger.getOS();
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
449 cpu = debugger.getCPU();
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
450 setupJVMLibNames(os);
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
451 machDesc = debugger.getMachineDescription();
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
452 }
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
453
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
454 // Given a classname, load an alternate implementation of JVMDebugger.
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
455 private void setupDebuggerAlternate(String alternateName) {
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
456
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
457 try {
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
458 Class c = Class.forName(alternateName);
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
459 Constructor cons = c.getConstructor();
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
460 debugger = (JVMDebugger) cons.newInstance();
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
461 attachDebugger();
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
462 setupDebuggerExisting();
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
463
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
464 } catch (ClassNotFoundException cnfe) {
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
465 throw new DebuggerException("Cannot find alternate SA Debugger: '" + alternateName + "'");
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
466 } catch (NoSuchMethodException nsme) {
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
467 throw new DebuggerException("Alternate SA Debugger: '" + alternateName + "' has missing constructor.");
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
468 } catch (InstantiationException ie) {
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
469 throw new DebuggerException("Alternate SA Debugger: '" + alternateName + "' fails to initialise: ", ie);
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
470 } catch (IllegalAccessException iae) {
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
471 throw new DebuggerException("Alternate SA Debugger: '" + alternateName + "' fails to initialise: ", iae);
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
472 } catch (InvocationTargetException iae) {
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
473 throw new DebuggerException("Alternate SA Debugger: '" + alternateName + "' fails to initialise: ", iae);
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
474 }
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
475
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
476 System.err.println("Loaded alternate HotSpot SA Debugger: " + alternateName);
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
477 }
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
478
0
a61af66fc99e Initial load
duke
parents:
diff changeset
479 //
a61af66fc99e Initial load
duke
parents:
diff changeset
480 // Solaris
a61af66fc99e Initial load
duke
parents:
diff changeset
481 //
a61af66fc99e Initial load
duke
parents:
diff changeset
482
a61af66fc99e Initial load
duke
parents:
diff changeset
483 private void setupDebuggerSolaris() {
a61af66fc99e Initial load
duke
parents:
diff changeset
484 setupJVMLibNamesSolaris();
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
485 ProcDebuggerLocal dbg = new ProcDebuggerLocal(null, true);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
486 debugger = dbg;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
487 attachDebugger();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
488
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
489 // Set up CPU-dependent stuff
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
490 if (cpu.equals("x86")) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
491 machDesc = new MachineDescriptionIntelX86();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
492 } else if (cpu.equals("sparc")) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
493 int addressSize = dbg.getRemoteProcessAddressSize();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
494 if (addressSize == -1) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
495 throw new DebuggerException("Error occurred while trying to determine the remote process's " +
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
496 "address size");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
497 }
a61af66fc99e Initial load
duke
parents:
diff changeset
498
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
499 if (addressSize == 32) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
500 machDesc = new MachineDescriptionSPARC32Bit();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
501 } else if (addressSize == 64) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
502 machDesc = new MachineDescriptionSPARC64Bit();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
503 } else {
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
504 throw new DebuggerException("Address size " + addressSize + " is not supported on SPARC");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
505 }
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
506 } else if (cpu.equals("amd64")) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
507 machDesc = new MachineDescriptionAMD64();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
508 } else {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
509 throw new DebuggerException("Solaris only supported on sparc/sparcv9/x86/amd64");
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
510 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
511
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
512 dbg.setMachineDescription(machDesc);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
513 return;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
514 }
a61af66fc99e Initial load
duke
parents:
diff changeset
515
a61af66fc99e Initial load
duke
parents:
diff changeset
516 private void connectRemoteDebugger() throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
517 RemoteDebugger remote =
a61af66fc99e Initial load
duke
parents:
diff changeset
518 (RemoteDebugger) RMIHelper.lookup(debugServerID);
a61af66fc99e Initial load
duke
parents:
diff changeset
519 debugger = new RemoteDebuggerClient(remote);
a61af66fc99e Initial load
duke
parents:
diff changeset
520 machDesc = ((RemoteDebuggerClient) debugger).getMachineDescription();
a61af66fc99e Initial load
duke
parents:
diff changeset
521 os = debugger.getOS();
11054
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
522 setupJVMLibNames(os);
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
523 cpu = debugger.getCPU();
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
524 }
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
525
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 10229
diff changeset
526 private void setupJVMLibNames(String os) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
527 if (os.equals("solaris")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
528 setupJVMLibNamesSolaris();
a61af66fc99e Initial load
duke
parents:
diff changeset
529 } else if (os.equals("win32")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
530 setupJVMLibNamesWin32();
a61af66fc99e Initial load
duke
parents:
diff changeset
531 } else if (os.equals("linux")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
532 setupJVMLibNamesLinux();
3960
f08d439fab8c 7089790: integrate bsd-port changes
never
parents: 3939
diff changeset
533 } else if (os.equals("bsd")) {
f08d439fab8c 7089790: integrate bsd-port changes
never
parents: 3939
diff changeset
534 setupJVMLibNamesBsd();
8750
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 6782
diff changeset
535 } else if (os.equals("darwin")) {
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 6782
diff changeset
536 setupJVMLibNamesDarwin();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
537 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
538 throw new RuntimeException("Unknown OS type");
a61af66fc99e Initial load
duke
parents:
diff changeset
539 }
a61af66fc99e Initial load
duke
parents:
diff changeset
540 }
a61af66fc99e Initial load
duke
parents:
diff changeset
541
a61af66fc99e Initial load
duke
parents:
diff changeset
542 private void setupJVMLibNamesSolaris() {
10229
f6a055fcf47d 8005038: remove crufty '_g' support from SA
sla
parents: 8750
diff changeset
543 jvmLibNames = new String[] { "libjvm.so" };
0
a61af66fc99e Initial load
duke
parents:
diff changeset
544 }
a61af66fc99e Initial load
duke
parents:
diff changeset
545
a61af66fc99e Initial load
duke
parents:
diff changeset
546 //
a61af66fc99e Initial load
duke
parents:
diff changeset
547 // Win32
a61af66fc99e Initial load
duke
parents:
diff changeset
548 //
a61af66fc99e Initial load
duke
parents:
diff changeset
549
a61af66fc99e Initial load
duke
parents:
diff changeset
550 private void setupDebuggerWin32() {
a61af66fc99e Initial load
duke
parents:
diff changeset
551 setupJVMLibNamesWin32();
a61af66fc99e Initial load
duke
parents:
diff changeset
552
a61af66fc99e Initial load
duke
parents:
diff changeset
553 if (cpu.equals("x86")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
554 machDesc = new MachineDescriptionIntelX86();
a61af66fc99e Initial load
duke
parents:
diff changeset
555 } else if (cpu.equals("amd64")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
556 machDesc = new MachineDescriptionAMD64();
a61af66fc99e Initial load
duke
parents:
diff changeset
557 } else if (cpu.equals("ia64")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
558 machDesc = new MachineDescriptionIA64();
a61af66fc99e Initial load
duke
parents:
diff changeset
559 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
560 throw new DebuggerException("Win32 supported under x86, amd64 and ia64 only");
a61af66fc99e Initial load
duke
parents:
diff changeset
561 }
a61af66fc99e Initial load
duke
parents:
diff changeset
562
a61af66fc99e Initial load
duke
parents:
diff changeset
563 // Note we do not use a cache for the local debugger in server
a61af66fc99e Initial load
duke
parents:
diff changeset
564 // mode; it will be taken care of on the client side (once remote
a61af66fc99e Initial load
duke
parents:
diff changeset
565 // debugging is implemented).
a61af66fc99e Initial load
duke
parents:
diff changeset
566
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
567 debugger = new WindbgDebuggerLocal(machDesc, !isServer);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
568
a61af66fc99e Initial load
duke
parents:
diff changeset
569 attachDebugger();
a61af66fc99e Initial load
duke
parents:
diff changeset
570
a61af66fc99e Initial load
duke
parents:
diff changeset
571 // FIXME: add support for server mode
a61af66fc99e Initial load
duke
parents:
diff changeset
572 }
a61af66fc99e Initial load
duke
parents:
diff changeset
573
a61af66fc99e Initial load
duke
parents:
diff changeset
574 private void setupJVMLibNamesWin32() {
10229
f6a055fcf47d 8005038: remove crufty '_g' support from SA
sla
parents: 8750
diff changeset
575 jvmLibNames = new String[] { "jvm.dll" };
0
a61af66fc99e Initial load
duke
parents:
diff changeset
576 }
a61af66fc99e Initial load
duke
parents:
diff changeset
577
a61af66fc99e Initial load
duke
parents:
diff changeset
578 //
a61af66fc99e Initial load
duke
parents:
diff changeset
579 // Linux
a61af66fc99e Initial load
duke
parents:
diff changeset
580 //
a61af66fc99e Initial load
duke
parents:
diff changeset
581
a61af66fc99e Initial load
duke
parents:
diff changeset
582 private void setupDebuggerLinux() {
a61af66fc99e Initial load
duke
parents:
diff changeset
583 setupJVMLibNamesLinux();
a61af66fc99e Initial load
duke
parents:
diff changeset
584
a61af66fc99e Initial load
duke
parents:
diff changeset
585 if (cpu.equals("x86")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
586 machDesc = new MachineDescriptionIntelX86();
a61af66fc99e Initial load
duke
parents:
diff changeset
587 } else if (cpu.equals("ia64")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
588 machDesc = new MachineDescriptionIA64();
a61af66fc99e Initial load
duke
parents:
diff changeset
589 } else if (cpu.equals("amd64")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
590 machDesc = new MachineDescriptionAMD64();
a61af66fc99e Initial load
duke
parents:
diff changeset
591 } else if (cpu.equals("sparc")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
592 if (LinuxDebuggerLocal.getAddressSize()==8) {
a61af66fc99e Initial load
duke
parents:
diff changeset
593 machDesc = new MachineDescriptionSPARC64Bit();
a61af66fc99e Initial load
duke
parents:
diff changeset
594 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
595 machDesc = new MachineDescriptionSPARC32Bit();
a61af66fc99e Initial load
duke
parents:
diff changeset
596 }
a61af66fc99e Initial load
duke
parents:
diff changeset
597 } else {
6641
a9fed06c01d2 7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents: 6073
diff changeset
598 try {
a9fed06c01d2 7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents: 6073
diff changeset
599 machDesc = (MachineDescription)
a9fed06c01d2 7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents: 6073
diff changeset
600 Class.forName("sun.jvm.hotspot.debugger.MachineDescription" +
a9fed06c01d2 7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents: 6073
diff changeset
601 cpu.toUpperCase()).newInstance();
a9fed06c01d2 7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents: 6073
diff changeset
602 } catch (Exception e) {
a9fed06c01d2 7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents: 6073
diff changeset
603 throw new DebuggerException("Linux not supported on machine type " + cpu);
a9fed06c01d2 7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents: 6073
diff changeset
604 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
605 }
a61af66fc99e Initial load
duke
parents:
diff changeset
606
a61af66fc99e Initial load
duke
parents:
diff changeset
607 LinuxDebuggerLocal dbg =
a61af66fc99e Initial load
duke
parents:
diff changeset
608 new LinuxDebuggerLocal(machDesc, !isServer);
a61af66fc99e Initial load
duke
parents:
diff changeset
609 debugger = dbg;
a61af66fc99e Initial load
duke
parents:
diff changeset
610
a61af66fc99e Initial load
duke
parents:
diff changeset
611 attachDebugger();
a61af66fc99e Initial load
duke
parents:
diff changeset
612 }
a61af66fc99e Initial load
duke
parents:
diff changeset
613
a61af66fc99e Initial load
duke
parents:
diff changeset
614 private void setupJVMLibNamesLinux() {
10229
f6a055fcf47d 8005038: remove crufty '_g' support from SA
sla
parents: 8750
diff changeset
615 jvmLibNames = new String[] { "libjvm.so" };
0
a61af66fc99e Initial load
duke
parents:
diff changeset
616 }
a61af66fc99e Initial load
duke
parents:
diff changeset
617
3960
f08d439fab8c 7089790: integrate bsd-port changes
never
parents: 3939
diff changeset
618 //
f08d439fab8c 7089790: integrate bsd-port changes
never
parents: 3939
diff changeset
619 // BSD
f08d439fab8c 7089790: integrate bsd-port changes
never
parents: 3939
diff changeset
620 //
f08d439fab8c 7089790: integrate bsd-port changes
never
parents: 3939
diff changeset
621
f08d439fab8c 7089790: integrate bsd-port changes
never
parents: 3939
diff changeset
622 private void setupDebuggerBsd() {
f08d439fab8c 7089790: integrate bsd-port changes
never
parents: 3939
diff changeset
623 setupJVMLibNamesBsd();
f08d439fab8c 7089790: integrate bsd-port changes
never
parents: 3939
diff changeset
624
f08d439fab8c 7089790: integrate bsd-port changes
never
parents: 3939
diff changeset
625 if (cpu.equals("x86")) {
f08d439fab8c 7089790: integrate bsd-port changes
never
parents: 3939
diff changeset
626 machDesc = new MachineDescriptionIntelX86();
6073
78d2ae5ab35b 7163117: Agent can't connect to process on Mac OSX
nloodin
parents: 3960
diff changeset
627 } else if (cpu.equals("amd64") || cpu.equals("x86_64")) {
3960
f08d439fab8c 7089790: integrate bsd-port changes
never
parents: 3939
diff changeset
628 machDesc = new MachineDescriptionAMD64();
f08d439fab8c 7089790: integrate bsd-port changes
never
parents: 3939
diff changeset
629 } else {
6073
78d2ae5ab35b 7163117: Agent can't connect to process on Mac OSX
nloodin
parents: 3960
diff changeset
630 throw new DebuggerException("BSD only supported on x86/x86_64. Current arch: " + cpu);
3960
f08d439fab8c 7089790: integrate bsd-port changes
never
parents: 3939
diff changeset
631 }
f08d439fab8c 7089790: integrate bsd-port changes
never
parents: 3939
diff changeset
632
f08d439fab8c 7089790: integrate bsd-port changes
never
parents: 3939
diff changeset
633 BsdDebuggerLocal dbg = new BsdDebuggerLocal(machDesc, !isServer);
f08d439fab8c 7089790: integrate bsd-port changes
never
parents: 3939
diff changeset
634 debugger = dbg;
f08d439fab8c 7089790: integrate bsd-port changes
never
parents: 3939
diff changeset
635
f08d439fab8c 7089790: integrate bsd-port changes
never
parents: 3939
diff changeset
636 attachDebugger();
f08d439fab8c 7089790: integrate bsd-port changes
never
parents: 3939
diff changeset
637 }
f08d439fab8c 7089790: integrate bsd-port changes
never
parents: 3939
diff changeset
638
f08d439fab8c 7089790: integrate bsd-port changes
never
parents: 3939
diff changeset
639 private void setupJVMLibNamesBsd() {
10229
f6a055fcf47d 8005038: remove crufty '_g' support from SA
sla
parents: 8750
diff changeset
640 jvmLibNames = new String[] { "libjvm.so" };
3960
f08d439fab8c 7089790: integrate bsd-port changes
never
parents: 3939
diff changeset
641 }
f08d439fab8c 7089790: integrate bsd-port changes
never
parents: 3939
diff changeset
642
8750
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 6782
diff changeset
643 //
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 6782
diff changeset
644 // Darwin
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 6782
diff changeset
645 //
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 6782
diff changeset
646
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 6782
diff changeset
647 private void setupDebuggerDarwin() {
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 6782
diff changeset
648 setupJVMLibNamesDarwin();
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 6782
diff changeset
649
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 6782
diff changeset
650 if (cpu.equals("amd64") || cpu.equals("x86_64")) {
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 6782
diff changeset
651 machDesc = new MachineDescriptionAMD64();
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 6782
diff changeset
652 } else {
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 6782
diff changeset
653 throw new DebuggerException("Darwin only supported on x86_64. Current arch: " + cpu);
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 6782
diff changeset
654 }
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 6782
diff changeset
655
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 6782
diff changeset
656 BsdDebuggerLocal dbg = new BsdDebuggerLocal(machDesc, !isServer);
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 6782
diff changeset
657 debugger = dbg;
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 6782
diff changeset
658
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 6782
diff changeset
659 attachDebugger();
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 6782
diff changeset
660 }
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 6782
diff changeset
661
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 6782
diff changeset
662 private void setupJVMLibNamesDarwin() {
10229
f6a055fcf47d 8005038: remove crufty '_g' support from SA
sla
parents: 8750
diff changeset
663 jvmLibNames = new String[] { "libjvm.dylib" };
8750
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 6782
diff changeset
664 }
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 6782
diff changeset
665
0
a61af66fc99e Initial load
duke
parents:
diff changeset
666 /** Convenience routine which should be called by per-platform
a61af66fc99e Initial load
duke
parents:
diff changeset
667 debugger setup. Should not be called when startupMode is
a61af66fc99e Initial load
duke
parents:
diff changeset
668 REMOTE_MODE. */
a61af66fc99e Initial load
duke
parents:
diff changeset
669 private void attachDebugger() {
a61af66fc99e Initial load
duke
parents:
diff changeset
670 if (startupMode == PROCESS_MODE) {
a61af66fc99e Initial load
duke
parents:
diff changeset
671 debugger.attach(pid);
a61af66fc99e Initial load
duke
parents:
diff changeset
672 } else if (startupMode == CORE_FILE_MODE) {
a61af66fc99e Initial load
duke
parents:
diff changeset
673 debugger.attach(javaExecutableName, coreFileName);
a61af66fc99e Initial load
duke
parents:
diff changeset
674 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
675 throw new DebuggerException("Should not call attach() for startupMode == " + startupMode);
a61af66fc99e Initial load
duke
parents:
diff changeset
676 }
a61af66fc99e Initial load
duke
parents:
diff changeset
677 }
a61af66fc99e Initial load
duke
parents:
diff changeset
678 }