annotate agent/src/share/classes/sun/jvm/hotspot/bugspot/BugSpotAgent.java @ 3972:4f93f0d00802

7059019: G1: add G1 support to the SA Summary: Extend the SA to recognize the G1CollectedHeap and implement any code that's needed by our serviceability tools (jmap, jinfo, jstack, etc.) that depend on the SA. Reviewed-by: never, poonam, johnc
author tonyp
date Tue, 20 Sep 2011 09:59:59 -0400
parents f6f3bb0ee072
children f08d439fab8c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
2 * Copyright (c) 2002, 2011, 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.bugspot;
a61af66fc99e Initial load
duke
parents:
diff changeset
26
a61af66fc99e Initial load
duke
parents:
diff changeset
27 import java.io.PrintStream;
a61af66fc99e Initial load
duke
parents:
diff changeset
28 import java.net.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
29 import java.rmi.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
30 import sun.jvm.hotspot.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 import sun.jvm.hotspot.debugger.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
32 import sun.jvm.hotspot.debugger.proc.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
33 import sun.jvm.hotspot.debugger.cdbg.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
34 import sun.jvm.hotspot.debugger.windbg.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
35 import sun.jvm.hotspot.debugger.linux.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
36 import sun.jvm.hotspot.debugger.sparc.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
37 import sun.jvm.hotspot.debugger.remote.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
38 import sun.jvm.hotspot.livejvm.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
39 import sun.jvm.hotspot.memory.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
40 import sun.jvm.hotspot.oops.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
41 import sun.jvm.hotspot.runtime.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
42 import sun.jvm.hotspot.types.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
43 import sun.jvm.hotspot.utilities.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
44
a61af66fc99e Initial load
duke
parents:
diff changeset
45 /** <P> This class wraps the basic functionality for connecting to the
a61af66fc99e Initial load
duke
parents:
diff changeset
46 * target process or debug server. It makes it simple to start up the
a61af66fc99e Initial load
duke
parents:
diff changeset
47 * debugging system. </P>
a61af66fc99e Initial load
duke
parents:
diff changeset
48 *
a61af66fc99e Initial load
duke
parents:
diff changeset
49 * <P> This agent (as compared to the HotSpotAgent) can connect to
a61af66fc99e Initial load
duke
parents:
diff changeset
50 * and interact with arbitrary processes. If the target process
a61af66fc99e Initial load
duke
parents:
diff changeset
51 * happens to be a HotSpot JVM, the Java debugging features of the
a61af66fc99e Initial load
duke
parents:
diff changeset
52 * Serviceability Agent are enabled. Further, if the Serviceability
a61af66fc99e Initial load
duke
parents:
diff changeset
53 * Agent's JVMDI module is loaded into the target VM, interaction
a61af66fc99e Initial load
duke
parents:
diff changeset
54 * with the live Java program is possible, specifically the catching
a61af66fc99e Initial load
duke
parents:
diff changeset
55 * of exceptions and setting of breakpoints. </P>
a61af66fc99e Initial load
duke
parents:
diff changeset
56 *
a61af66fc99e Initial load
duke
parents:
diff changeset
57 * <P> The BugSpot debugger requires that the underlying Debugger
a61af66fc99e Initial load
duke
parents:
diff changeset
58 * support C/C++ debugging via the CDebugger interface. </P>
a61af66fc99e Initial load
duke
parents:
diff changeset
59 *
a61af66fc99e Initial load
duke
parents:
diff changeset
60 * <P> FIXME: need to add a way to configure the paths to dbx and the
a61af66fc99e Initial load
duke
parents:
diff changeset
61 * DSO from the outside. However, this should work for now for
a61af66fc99e Initial load
duke
parents:
diff changeset
62 * internal use. </P>
a61af66fc99e Initial load
duke
parents:
diff changeset
63 *
a61af66fc99e Initial load
duke
parents:
diff changeset
64 * <P> FIXME: especially with the addition of remote debugging, this
a61af66fc99e Initial load
duke
parents:
diff changeset
65 * has turned into a mess; needs rethinking. </P> */
a61af66fc99e Initial load
duke
parents:
diff changeset
66
a61af66fc99e Initial load
duke
parents:
diff changeset
67 public class BugSpotAgent {
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 private JVMDebugger debugger;
a61af66fc99e Initial load
duke
parents:
diff changeset
70 private MachineDescription machDesc;
a61af66fc99e Initial load
duke
parents:
diff changeset
71 private TypeDataBase db;
a61af66fc99e Initial load
duke
parents:
diff changeset
72
a61af66fc99e Initial load
duke
parents:
diff changeset
73 private String os;
a61af66fc99e Initial load
duke
parents:
diff changeset
74 private String cpu;
a61af66fc99e Initial load
duke
parents:
diff changeset
75 private String fileSep;
a61af66fc99e Initial load
duke
parents:
diff changeset
76
a61af66fc99e Initial load
duke
parents:
diff changeset
77 // The system can work in several ways:
a61af66fc99e Initial load
duke
parents:
diff changeset
78 // - Attaching to local process
a61af66fc99e Initial load
duke
parents:
diff changeset
79 // - Attaching to local core file
a61af66fc99e Initial load
duke
parents:
diff changeset
80 // - Connecting to remote debug server
a61af66fc99e Initial load
duke
parents:
diff changeset
81 // - Starting debug server for process
a61af66fc99e Initial load
duke
parents:
diff changeset
82 // - Starting debug server for core file
a61af66fc99e Initial load
duke
parents:
diff changeset
83
a61af66fc99e Initial load
duke
parents:
diff changeset
84 // These are options for the "client" side of things
a61af66fc99e Initial load
duke
parents:
diff changeset
85 private static final int PROCESS_MODE = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
86 private static final int CORE_FILE_MODE = 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
87 private static final int REMOTE_MODE = 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
88 private int startupMode;
a61af66fc99e Initial load
duke
parents:
diff changeset
89
a61af66fc99e Initial load
duke
parents:
diff changeset
90 // This indicates whether we are really starting a server or not
a61af66fc99e Initial load
duke
parents:
diff changeset
91 private boolean isServer;
a61af66fc99e Initial load
duke
parents:
diff changeset
92
a61af66fc99e Initial load
duke
parents:
diff changeset
93 // All possible required information for connecting
a61af66fc99e Initial load
duke
parents:
diff changeset
94 private int pid;
a61af66fc99e Initial load
duke
parents:
diff changeset
95 private String executableName;
a61af66fc99e Initial load
duke
parents:
diff changeset
96 private String coreFileName;
a61af66fc99e Initial load
duke
parents:
diff changeset
97 private String debugServerID;
a61af66fc99e Initial load
duke
parents:
diff changeset
98
a61af66fc99e Initial load
duke
parents:
diff changeset
99 // All needed information for server side
a61af66fc99e Initial load
duke
parents:
diff changeset
100 private String serverID;
a61af66fc99e Initial load
duke
parents:
diff changeset
101
a61af66fc99e Initial load
duke
parents:
diff changeset
102 // Indicates whether we are attached to a HotSpot JVM or not
a61af66fc99e Initial load
duke
parents:
diff changeset
103 private boolean javaMode;
a61af66fc99e Initial load
duke
parents:
diff changeset
104
a61af66fc99e Initial load
duke
parents:
diff changeset
105 // Indicates whether we have process control over a live HotSpot JVM
a61af66fc99e Initial load
duke
parents:
diff changeset
106 // or not; non-null if so.
a61af66fc99e Initial load
duke
parents:
diff changeset
107 private ServiceabilityAgentJVMDIModule jvmdi;
a61af66fc99e Initial load
duke
parents:
diff changeset
108 // While handling C breakpoints interactivity with the Java program
a61af66fc99e Initial load
duke
parents:
diff changeset
109 // is forbidden. Too many invariants are broken while the target is
a61af66fc99e Initial load
duke
parents:
diff changeset
110 // stopped at a C breakpoint to risk making JVMDI calls.
a61af66fc99e Initial load
duke
parents:
diff changeset
111 private boolean javaInteractionDisabled;
a61af66fc99e Initial load
duke
parents:
diff changeset
112
a61af66fc99e Initial load
duke
parents:
diff changeset
113 private String[] jvmLibNames;
a61af66fc99e Initial load
duke
parents:
diff changeset
114 private String[] saLibNames;
a61af66fc99e Initial load
duke
parents:
diff changeset
115
a61af66fc99e Initial load
duke
parents:
diff changeset
116 // FIXME: make these configurable, i.e., via a dotfile; also
a61af66fc99e Initial load
duke
parents:
diff changeset
117 // consider searching within the JDK from which this Java executable
a61af66fc99e Initial load
duke
parents:
diff changeset
118 // comes to find them
a61af66fc99e Initial load
duke
parents:
diff changeset
119 private static final String defaultDbxPathPrefix = "/net/jano.eng/export/disk05/hotspot/sa";
a61af66fc99e Initial load
duke
parents:
diff changeset
120 private static final String defaultDbxSvcAgentDSOPathPrefix = "/net/jano.eng/export/disk05/hotspot/sa";
a61af66fc99e Initial load
duke
parents:
diff changeset
121
a61af66fc99e Initial load
duke
parents:
diff changeset
122 private static final boolean DEBUG;
a61af66fc99e Initial load
duke
parents:
diff changeset
123 static {
a61af66fc99e Initial load
duke
parents:
diff changeset
124 DEBUG = System.getProperty("sun.jvm.hotspot.bugspot.BugSpotAgent.DEBUG")
a61af66fc99e Initial load
duke
parents:
diff changeset
125 != null;
a61af66fc99e Initial load
duke
parents:
diff changeset
126 }
a61af66fc99e Initial load
duke
parents:
diff changeset
127
a61af66fc99e Initial load
duke
parents:
diff changeset
128 static void debugPrintln(String str) {
a61af66fc99e Initial load
duke
parents:
diff changeset
129 if (DEBUG) {
a61af66fc99e Initial load
duke
parents:
diff changeset
130 System.err.println(str);
a61af66fc99e Initial load
duke
parents:
diff changeset
131 }
a61af66fc99e Initial load
duke
parents:
diff changeset
132 }
a61af66fc99e Initial load
duke
parents:
diff changeset
133
a61af66fc99e Initial load
duke
parents:
diff changeset
134 static void showUsage() {
a61af66fc99e Initial load
duke
parents:
diff changeset
135 System.out.println(" You can also pass these -D options to java to specify where to find dbx and the \n" +
a61af66fc99e Initial load
duke
parents:
diff changeset
136 " Serviceability Agent plugin for dbx:");
a61af66fc99e Initial load
duke
parents:
diff changeset
137 System.out.println(" -DdbxPathName=<path-to-dbx-executable>\n" +
a61af66fc99e Initial load
duke
parents:
diff changeset
138 " Default is derived from dbxPathPrefix");
a61af66fc99e Initial load
duke
parents:
diff changeset
139 System.out.println(" or");
a61af66fc99e Initial load
duke
parents:
diff changeset
140 System.out.println(" -DdbxPathPrefix=<xxx>\n" +
a61af66fc99e Initial load
duke
parents:
diff changeset
141 " where xxx is the path name of a dir structure that contains:\n" +
a61af66fc99e Initial load
duke
parents:
diff changeset
142 " <os>/<arch>/bin/dbx\n" +
a61af66fc99e Initial load
duke
parents:
diff changeset
143 " The default is " + defaultDbxPathPrefix);
a61af66fc99e Initial load
duke
parents:
diff changeset
144 System.out.println(" and");
a61af66fc99e Initial load
duke
parents:
diff changeset
145 System.out.println(" -DdbxSvcAgentDSOPathName=<path-to-dbx-serviceability-agent-module>\n" +
a61af66fc99e Initial load
duke
parents:
diff changeset
146 " Default is determined from dbxSvcAgentDSOPathPrefix");
a61af66fc99e Initial load
duke
parents:
diff changeset
147 System.out.println(" or");
a61af66fc99e Initial load
duke
parents:
diff changeset
148 System.out.println(" -DdbxSvcAgentDSOPathPrefix=<xxx>\n" +
a61af66fc99e Initial load
duke
parents:
diff changeset
149 " where xxx is the pathname of a dir structure that contains:\n" +
a61af66fc99e Initial load
duke
parents:
diff changeset
150 " <os>/<arch>/bin/lib/libsvc_agent_dbx.so\n" +
a61af66fc99e Initial load
duke
parents:
diff changeset
151 " The default is " + defaultDbxSvcAgentDSOPathPrefix);
a61af66fc99e Initial load
duke
parents:
diff changeset
152 }
a61af66fc99e Initial load
duke
parents:
diff changeset
153
a61af66fc99e Initial load
duke
parents:
diff changeset
154 public BugSpotAgent() {
a61af66fc99e Initial load
duke
parents:
diff changeset
155 // for non-server add shutdown hook to clean-up debugger in case
a61af66fc99e Initial load
duke
parents:
diff changeset
156 // of forced exit. For remote server, shutdown hook is added by
a61af66fc99e Initial load
duke
parents:
diff changeset
157 // DebugServer.
a61af66fc99e Initial load
duke
parents:
diff changeset
158 Runtime.getRuntime().addShutdownHook(new java.lang.Thread(
a61af66fc99e Initial load
duke
parents:
diff changeset
159 new Runnable() {
a61af66fc99e Initial load
duke
parents:
diff changeset
160 public void run() {
a61af66fc99e Initial load
duke
parents:
diff changeset
161 synchronized (BugSpotAgent.this) {
a61af66fc99e Initial load
duke
parents:
diff changeset
162 if (!isServer) {
a61af66fc99e Initial load
duke
parents:
diff changeset
163 detach();
a61af66fc99e Initial load
duke
parents:
diff changeset
164 }
a61af66fc99e Initial load
duke
parents:
diff changeset
165 }
a61af66fc99e Initial load
duke
parents:
diff changeset
166 }
a61af66fc99e Initial load
duke
parents:
diff changeset
167 }));
a61af66fc99e Initial load
duke
parents:
diff changeset
168 }
a61af66fc99e Initial load
duke
parents:
diff changeset
169
a61af66fc99e Initial load
duke
parents:
diff changeset
170 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
171 // Accessors (once the system is set up)
a61af66fc99e Initial load
duke
parents:
diff changeset
172 //
a61af66fc99e Initial load
duke
parents:
diff changeset
173
a61af66fc99e Initial load
duke
parents:
diff changeset
174 public synchronized Debugger getDebugger() {
a61af66fc99e Initial load
duke
parents:
diff changeset
175 return debugger;
a61af66fc99e Initial load
duke
parents:
diff changeset
176 }
a61af66fc99e Initial load
duke
parents:
diff changeset
177
a61af66fc99e Initial load
duke
parents:
diff changeset
178 public synchronized CDebugger getCDebugger() {
a61af66fc99e Initial load
duke
parents:
diff changeset
179 return getDebugger().getCDebugger();
a61af66fc99e Initial load
duke
parents:
diff changeset
180 }
a61af66fc99e Initial load
duke
parents:
diff changeset
181
a61af66fc99e Initial load
duke
parents:
diff changeset
182 public synchronized ProcessControl getProcessControl() {
a61af66fc99e Initial load
duke
parents:
diff changeset
183 return getCDebugger().getProcessControl();
a61af66fc99e Initial load
duke
parents:
diff changeset
184 }
a61af66fc99e Initial load
duke
parents:
diff changeset
185
a61af66fc99e Initial load
duke
parents:
diff changeset
186 public synchronized TypeDataBase getTypeDataBase() {
a61af66fc99e Initial load
duke
parents:
diff changeset
187 return db;
a61af66fc99e Initial load
duke
parents:
diff changeset
188 }
a61af66fc99e Initial load
duke
parents:
diff changeset
189
a61af66fc99e Initial load
duke
parents:
diff changeset
190 /** Indicates whether the target process is suspended
a61af66fc99e Initial load
duke
parents:
diff changeset
191 completely. Equivalent to getProcessControl().isSuspended(). */
a61af66fc99e Initial load
duke
parents:
diff changeset
192 public synchronized boolean isSuspended() throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
193 return getProcessControl().isSuspended();
a61af66fc99e Initial load
duke
parents:
diff changeset
194 }
a61af66fc99e Initial load
duke
parents:
diff changeset
195
a61af66fc99e Initial load
duke
parents:
diff changeset
196 /** Suspends the target process completely. Equivalent to
a61af66fc99e Initial load
duke
parents:
diff changeset
197 getProcessControl().suspend(). */
a61af66fc99e Initial load
duke
parents:
diff changeset
198 public synchronized void suspend() throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
199 getProcessControl().suspend();
a61af66fc99e Initial load
duke
parents:
diff changeset
200 }
a61af66fc99e Initial load
duke
parents:
diff changeset
201
a61af66fc99e Initial load
duke
parents:
diff changeset
202 /** Resumes the target process completely. Equivalent to
a61af66fc99e Initial load
duke
parents:
diff changeset
203 getProcessControl().suspend(). */
a61af66fc99e Initial load
duke
parents:
diff changeset
204 public synchronized void resume() throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
205 getProcessControl().resume();
a61af66fc99e Initial load
duke
parents:
diff changeset
206 }
a61af66fc99e Initial load
duke
parents:
diff changeset
207
a61af66fc99e Initial load
duke
parents:
diff changeset
208 /** Indicates whether we are attached to a Java HotSpot virtual
a61af66fc99e Initial load
duke
parents:
diff changeset
209 machine */
a61af66fc99e Initial load
duke
parents:
diff changeset
210 public synchronized boolean isJavaMode() {
a61af66fc99e Initial load
duke
parents:
diff changeset
211 return javaMode;
a61af66fc99e Initial load
duke
parents:
diff changeset
212 }
a61af66fc99e Initial load
duke
parents:
diff changeset
213
a61af66fc99e Initial load
duke
parents:
diff changeset
214 /** Temporarily disables interaction with the target process via
a61af66fc99e Initial load
duke
parents:
diff changeset
215 JVMDI. This is done while the target process is stopped at a C
a61af66fc99e Initial load
duke
parents:
diff changeset
216 breakpoint. Can be called even if the JVMDI agent has not been
a61af66fc99e Initial load
duke
parents:
diff changeset
217 initialized. */
a61af66fc99e Initial load
duke
parents:
diff changeset
218 public synchronized void disableJavaInteraction() {
a61af66fc99e Initial load
duke
parents:
diff changeset
219 javaInteractionDisabled = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
220 }
a61af66fc99e Initial load
duke
parents:
diff changeset
221
a61af66fc99e Initial load
duke
parents:
diff changeset
222 /** Re-enables interaction with the target process via JVMDI. This
a61af66fc99e Initial load
duke
parents:
diff changeset
223 is done while the target process is continued past a C
a61af66fc99e Initial load
duke
parents:
diff changeset
224 braekpoint. Can be called even if the JVMDI agent has not been
a61af66fc99e Initial load
duke
parents:
diff changeset
225 initialized. */
a61af66fc99e Initial load
duke
parents:
diff changeset
226 public synchronized void enableJavaInteraction() {
a61af66fc99e Initial load
duke
parents:
diff changeset
227 javaInteractionDisabled = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
228 }
a61af66fc99e Initial load
duke
parents:
diff changeset
229
a61af66fc99e Initial load
duke
parents:
diff changeset
230 /** Indicates whether Java interaction has been disabled */
a61af66fc99e Initial load
duke
parents:
diff changeset
231 public synchronized boolean isJavaInteractionDisabled() {
a61af66fc99e Initial load
duke
parents:
diff changeset
232 return javaInteractionDisabled;
a61af66fc99e Initial load
duke
parents:
diff changeset
233 }
a61af66fc99e Initial load
duke
parents:
diff changeset
234
a61af66fc99e Initial load
duke
parents:
diff changeset
235 /** Indicates whether we can talk to the Serviceability Agent's
a61af66fc99e Initial load
duke
parents:
diff changeset
236 JVMDI module to be able to set breakpoints */
a61af66fc99e Initial load
duke
parents:
diff changeset
237 public synchronized boolean canInteractWithJava() {
a61af66fc99e Initial load
duke
parents:
diff changeset
238 return (jvmdi != null) && !javaInteractionDisabled;
a61af66fc99e Initial load
duke
parents:
diff changeset
239 }
a61af66fc99e Initial load
duke
parents:
diff changeset
240
a61af66fc99e Initial load
duke
parents:
diff changeset
241 /** Suspends all Java threads in the target process. Can only be
a61af66fc99e Initial load
duke
parents:
diff changeset
242 called if we are attached to a HotSpot JVM and can connect to
a61af66fc99e Initial load
duke
parents:
diff changeset
243 the SA's JVMDI module. Must not be called when the target
a61af66fc99e Initial load
duke
parents:
diff changeset
244 process has been suspended with suspend(). */
a61af66fc99e Initial load
duke
parents:
diff changeset
245 public synchronized void suspendJava() throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
246 if (!canInteractWithJava()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
247 throw new DebuggerException("Could not connect to SA's JVMDI module");
a61af66fc99e Initial load
duke
parents:
diff changeset
248 }
a61af66fc99e Initial load
duke
parents:
diff changeset
249 if (jvmdi.isSuspended()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
250 throw new DebuggerException("Target process already suspended via JVMDI");
a61af66fc99e Initial load
duke
parents:
diff changeset
251 }
a61af66fc99e Initial load
duke
parents:
diff changeset
252 jvmdi.suspend();
a61af66fc99e Initial load
duke
parents:
diff changeset
253 }
a61af66fc99e Initial load
duke
parents:
diff changeset
254
a61af66fc99e Initial load
duke
parents:
diff changeset
255 /** Resumes all Java threads in the target process. Can only be
a61af66fc99e Initial load
duke
parents:
diff changeset
256 called if we are attached to a HotSpot JVM and can connect to
a61af66fc99e Initial load
duke
parents:
diff changeset
257 the SA's JVMDI module. Must not be called when the target
a61af66fc99e Initial load
duke
parents:
diff changeset
258 process has been suspended with suspend(). */
a61af66fc99e Initial load
duke
parents:
diff changeset
259 public synchronized void resumeJava() throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
260 if (!canInteractWithJava()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
261 throw new DebuggerException("Could not connect to SA's JVMDI module");
a61af66fc99e Initial load
duke
parents:
diff changeset
262 }
a61af66fc99e Initial load
duke
parents:
diff changeset
263 if (!jvmdi.isSuspended()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
264 throw new DebuggerException("Target process already resumed via JVMDI");
a61af66fc99e Initial load
duke
parents:
diff changeset
265 }
a61af66fc99e Initial load
duke
parents:
diff changeset
266 jvmdi.resume();
a61af66fc99e Initial load
duke
parents:
diff changeset
267 }
a61af66fc99e Initial load
duke
parents:
diff changeset
268
a61af66fc99e Initial load
duke
parents:
diff changeset
269 /** Indicates whether the target process has been suspended at the
a61af66fc99e Initial load
duke
parents:
diff changeset
270 Java language level via the SA's JVMDI module */
a61af66fc99e Initial load
duke
parents:
diff changeset
271 public synchronized boolean isJavaSuspended() throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
272 return jvmdi.isSuspended();
a61af66fc99e Initial load
duke
parents:
diff changeset
273 }
a61af66fc99e Initial load
duke
parents:
diff changeset
274
a61af66fc99e Initial load
duke
parents:
diff changeset
275 /** Toggle a Java breakpoint at the given location. */
a61af66fc99e Initial load
duke
parents:
diff changeset
276 public synchronized ServiceabilityAgentJVMDIModule.BreakpointToggleResult
a61af66fc99e Initial load
duke
parents:
diff changeset
277 toggleJavaBreakpoint(String srcFileName,
a61af66fc99e Initial load
duke
parents:
diff changeset
278 String pkgName,
a61af66fc99e Initial load
duke
parents:
diff changeset
279 int lineNo) {
a61af66fc99e Initial load
duke
parents:
diff changeset
280 if (!canInteractWithJava()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
281 throw new DebuggerException("Could not connect to SA's JVMDI module; can not toggle Java breakpoints");
a61af66fc99e Initial load
duke
parents:
diff changeset
282 }
a61af66fc99e Initial load
duke
parents:
diff changeset
283 return jvmdi.toggleBreakpoint(srcFileName, pkgName, lineNo);
a61af66fc99e Initial load
duke
parents:
diff changeset
284 }
a61af66fc99e Initial load
duke
parents:
diff changeset
285
a61af66fc99e Initial load
duke
parents:
diff changeset
286 /** Access to JVMDI module's eventPending */
a61af66fc99e Initial load
duke
parents:
diff changeset
287 public synchronized boolean javaEventPending() throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
288 if (!canInteractWithJava()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
289 throw new DebuggerException("Could not connect to SA's JVMDI module; can not poll for Java debug events");
a61af66fc99e Initial load
duke
parents:
diff changeset
290 }
a61af66fc99e Initial load
duke
parents:
diff changeset
291 return jvmdi.eventPending();
a61af66fc99e Initial load
duke
parents:
diff changeset
292 }
a61af66fc99e Initial load
duke
parents:
diff changeset
293
a61af66fc99e Initial load
duke
parents:
diff changeset
294 /** Access to JVMDI module's eventPoll */
a61af66fc99e Initial load
duke
parents:
diff changeset
295 public synchronized Event javaEventPoll() throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
296 if (!canInteractWithJava()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
297 throw new DebuggerException("Could not connect to SA's JVMDI module; can not poll for Java debug events");
a61af66fc99e Initial load
duke
parents:
diff changeset
298 }
a61af66fc99e Initial load
duke
parents:
diff changeset
299 return jvmdi.eventPoll();
a61af66fc99e Initial load
duke
parents:
diff changeset
300 }
a61af66fc99e Initial load
duke
parents:
diff changeset
301
a61af66fc99e Initial load
duke
parents:
diff changeset
302 /** Access to JVMDI module's eventContinue */
a61af66fc99e Initial load
duke
parents:
diff changeset
303 public synchronized void javaEventContinue() throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
304 if (!canInteractWithJava()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
305 throw new DebuggerException("Could not connect to SA's JVMDI module; can not continue past Java debug events");
a61af66fc99e Initial load
duke
parents:
diff changeset
306 }
a61af66fc99e Initial load
duke
parents:
diff changeset
307 jvmdi.eventContinue();
a61af66fc99e Initial load
duke
parents:
diff changeset
308 }
a61af66fc99e Initial load
duke
parents:
diff changeset
309
a61af66fc99e Initial load
duke
parents:
diff changeset
310
a61af66fc99e Initial load
duke
parents:
diff changeset
311 // FIXME: add other accessors. For example, suspension and
a61af66fc99e Initial load
duke
parents:
diff changeset
312 // resumption should be done through this interface, as well as
a61af66fc99e Initial load
duke
parents:
diff changeset
313 // interaction with the live Java process such as breakpoint setting.
a61af66fc99e Initial load
duke
parents:
diff changeset
314 // Probably should not expose the ServiceabilityAgentJVMDIModule
a61af66fc99e Initial load
duke
parents:
diff changeset
315 // from this interface.
a61af66fc99e Initial load
duke
parents:
diff changeset
316
a61af66fc99e Initial load
duke
parents:
diff changeset
317 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
318 // Client-side operations
a61af66fc99e Initial load
duke
parents:
diff changeset
319 //
a61af66fc99e Initial load
duke
parents:
diff changeset
320
a61af66fc99e Initial load
duke
parents:
diff changeset
321 /** This attaches to a process running on the local machine. */
a61af66fc99e Initial load
duke
parents:
diff changeset
322 public synchronized void attach(int processID)
a61af66fc99e Initial load
duke
parents:
diff changeset
323 throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
324 if (debugger != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
325 throw new DebuggerException("Already attached");
a61af66fc99e Initial load
duke
parents:
diff changeset
326 }
a61af66fc99e Initial load
duke
parents:
diff changeset
327 pid = processID;
a61af66fc99e Initial load
duke
parents:
diff changeset
328 startupMode = PROCESS_MODE;
a61af66fc99e Initial load
duke
parents:
diff changeset
329 isServer = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
330 go();
a61af66fc99e Initial load
duke
parents:
diff changeset
331 }
a61af66fc99e Initial load
duke
parents:
diff changeset
332
a61af66fc99e Initial load
duke
parents:
diff changeset
333 /** This opens a core file on the local machine */
a61af66fc99e Initial load
duke
parents:
diff changeset
334 public synchronized void attach(String executableName, String coreFileName)
a61af66fc99e Initial load
duke
parents:
diff changeset
335 throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
336 if (debugger != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
337 throw new DebuggerException("Already attached");
a61af66fc99e Initial load
duke
parents:
diff changeset
338 }
a61af66fc99e Initial load
duke
parents:
diff changeset
339 if ((executableName == null) || (coreFileName == null)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
340 throw new DebuggerException("Both the core file name and executable name must be specified");
a61af66fc99e Initial load
duke
parents:
diff changeset
341 }
a61af66fc99e Initial load
duke
parents:
diff changeset
342 this.executableName = executableName;
a61af66fc99e Initial load
duke
parents:
diff changeset
343 this.coreFileName = coreFileName;
a61af66fc99e Initial load
duke
parents:
diff changeset
344 startupMode = CORE_FILE_MODE;
a61af66fc99e Initial load
duke
parents:
diff changeset
345 isServer = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
346 go();
a61af66fc99e Initial load
duke
parents:
diff changeset
347 }
a61af66fc99e Initial load
duke
parents:
diff changeset
348
a61af66fc99e Initial load
duke
parents:
diff changeset
349 /** This attaches to a "debug server" on a remote machine; this
a61af66fc99e Initial load
duke
parents:
diff changeset
350 remote server has already attached to a process or opened a
a61af66fc99e Initial load
duke
parents:
diff changeset
351 core file and is waiting for RMI calls on the Debugger object to
a61af66fc99e Initial load
duke
parents:
diff changeset
352 come in. */
a61af66fc99e Initial load
duke
parents:
diff changeset
353 public synchronized void attach(String remoteServerID)
a61af66fc99e Initial load
duke
parents:
diff changeset
354 throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
355 if (debugger != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
356 throw new DebuggerException("Already attached to a process");
a61af66fc99e Initial load
duke
parents:
diff changeset
357 }
a61af66fc99e Initial load
duke
parents:
diff changeset
358 if (remoteServerID == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
359 throw new DebuggerException("Debug server id must be specified");
a61af66fc99e Initial load
duke
parents:
diff changeset
360 }
a61af66fc99e Initial load
duke
parents:
diff changeset
361
a61af66fc99e Initial load
duke
parents:
diff changeset
362 debugServerID = remoteServerID;
a61af66fc99e Initial load
duke
parents:
diff changeset
363 startupMode = REMOTE_MODE;
a61af66fc99e Initial load
duke
parents:
diff changeset
364 isServer = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
365 go();
a61af66fc99e Initial load
duke
parents:
diff changeset
366 }
a61af66fc99e Initial load
duke
parents:
diff changeset
367
a61af66fc99e Initial load
duke
parents:
diff changeset
368 /** This should only be called by the user on the client machine,
a61af66fc99e Initial load
duke
parents:
diff changeset
369 not the server machine */
a61af66fc99e Initial load
duke
parents:
diff changeset
370 public synchronized boolean detach() throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
371 if (isServer) {
a61af66fc99e Initial load
duke
parents:
diff changeset
372 throw new DebuggerException("Should not call detach() for server configuration");
a61af66fc99e Initial load
duke
parents:
diff changeset
373 }
a61af66fc99e Initial load
duke
parents:
diff changeset
374 return detachInternal();
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 // Server-side operations
a61af66fc99e Initial load
duke
parents:
diff changeset
379 //
a61af66fc99e Initial load
duke
parents:
diff changeset
380
a61af66fc99e Initial load
duke
parents:
diff changeset
381 /** This attaches to a process running on the local machine and
a61af66fc99e Initial load
duke
parents:
diff changeset
382 starts a debug server, allowing remote machines to connect and
a61af66fc99e Initial load
duke
parents:
diff changeset
383 examine this process. uniqueID is used to uniquely identify the
a61af66fc99e Initial load
duke
parents:
diff changeset
384 debuggee */
a61af66fc99e Initial load
duke
parents:
diff changeset
385 public synchronized void startServer(int processID, String uniqueID)
a61af66fc99e Initial load
duke
parents:
diff changeset
386 throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
387 if (debugger != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
388 throw new DebuggerException("Already attached");
a61af66fc99e Initial load
duke
parents:
diff changeset
389 }
a61af66fc99e Initial load
duke
parents:
diff changeset
390 pid = processID;
a61af66fc99e Initial load
duke
parents:
diff changeset
391 startupMode = PROCESS_MODE;
a61af66fc99e Initial load
duke
parents:
diff changeset
392 isServer = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
393 serverID = uniqueID;
a61af66fc99e Initial load
duke
parents:
diff changeset
394 go();
a61af66fc99e Initial load
duke
parents:
diff changeset
395 }
a61af66fc99e Initial load
duke
parents:
diff changeset
396
a61af66fc99e Initial load
duke
parents:
diff changeset
397 /** This attaches to a process running on the local machine and
a61af66fc99e Initial load
duke
parents:
diff changeset
398 starts a debug server, allowing remote machines to connect and
a61af66fc99e Initial load
duke
parents:
diff changeset
399 examine this process. */
a61af66fc99e Initial load
duke
parents:
diff changeset
400 public synchronized void startServer(int processID)
a61af66fc99e Initial load
duke
parents:
diff changeset
401 throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
402 startServer(processID, null);
a61af66fc99e Initial load
duke
parents:
diff changeset
403 }
a61af66fc99e Initial load
duke
parents:
diff changeset
404
a61af66fc99e Initial load
duke
parents:
diff changeset
405 /** This opens a core file on the local machine and starts a debug
a61af66fc99e Initial load
duke
parents:
diff changeset
406 server, allowing remote machines to connect and examine this
a61af66fc99e Initial load
duke
parents:
diff changeset
407 core file. uniqueID is used to uniquely identify the
a61af66fc99e Initial load
duke
parents:
diff changeset
408 debuggee */
a61af66fc99e Initial load
duke
parents:
diff changeset
409 public synchronized void startServer(String executableName, String coreFileName,
a61af66fc99e Initial load
duke
parents:
diff changeset
410 String uniqueID)
a61af66fc99e Initial load
duke
parents:
diff changeset
411 throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
412 if (debugger != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
413 throw new DebuggerException("Already attached");
a61af66fc99e Initial load
duke
parents:
diff changeset
414 }
a61af66fc99e Initial load
duke
parents:
diff changeset
415 if ((executableName == null) || (coreFileName == null)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
416 throw new DebuggerException("Both the core file name and Java executable name must be specified");
a61af66fc99e Initial load
duke
parents:
diff changeset
417 }
a61af66fc99e Initial load
duke
parents:
diff changeset
418 this.executableName = executableName;
a61af66fc99e Initial load
duke
parents:
diff changeset
419 this.coreFileName = coreFileName;
a61af66fc99e Initial load
duke
parents:
diff changeset
420 startupMode = CORE_FILE_MODE;
a61af66fc99e Initial load
duke
parents:
diff changeset
421 isServer = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
422 serverID = uniqueID;
a61af66fc99e Initial load
duke
parents:
diff changeset
423 go();
a61af66fc99e Initial load
duke
parents:
diff changeset
424 }
a61af66fc99e Initial load
duke
parents:
diff changeset
425
a61af66fc99e Initial load
duke
parents:
diff changeset
426 /** This opens a core file on the local machine and starts a debug
a61af66fc99e Initial load
duke
parents:
diff changeset
427 server, allowing remote machines to connect and examine this
a61af66fc99e Initial load
duke
parents:
diff changeset
428 core file.*/
a61af66fc99e Initial load
duke
parents:
diff changeset
429 public synchronized void startServer(String executableName, String coreFileName)
a61af66fc99e Initial load
duke
parents:
diff changeset
430 throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
431 startServer(executableName, coreFileName, null);
a61af66fc99e Initial load
duke
parents:
diff changeset
432 }
a61af66fc99e Initial load
duke
parents:
diff changeset
433
a61af66fc99e Initial load
duke
parents:
diff changeset
434 /** This may only be called on the server side after startServer()
a61af66fc99e Initial load
duke
parents:
diff changeset
435 has been called */
a61af66fc99e Initial load
duke
parents:
diff changeset
436 public synchronized boolean shutdownServer() throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
437 if (!isServer) {
a61af66fc99e Initial load
duke
parents:
diff changeset
438 throw new DebuggerException("Should not call shutdownServer() for client configuration");
a61af66fc99e Initial load
duke
parents:
diff changeset
439 }
a61af66fc99e Initial load
duke
parents:
diff changeset
440 return detachInternal();
a61af66fc99e Initial load
duke
parents:
diff changeset
441 }
a61af66fc99e Initial load
duke
parents:
diff changeset
442
a61af66fc99e Initial load
duke
parents:
diff changeset
443
a61af66fc99e Initial load
duke
parents:
diff changeset
444 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
445 // Internals only below this point
a61af66fc99e Initial load
duke
parents:
diff changeset
446 //
a61af66fc99e Initial load
duke
parents:
diff changeset
447
a61af66fc99e Initial load
duke
parents:
diff changeset
448 private boolean detachInternal() {
a61af66fc99e Initial load
duke
parents:
diff changeset
449 if (debugger == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
450 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
451 }
a61af66fc99e Initial load
duke
parents:
diff changeset
452 if (canInteractWithJava()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
453 jvmdi.detach();
a61af66fc99e Initial load
duke
parents:
diff changeset
454 jvmdi = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
455 }
a61af66fc99e Initial load
duke
parents:
diff changeset
456 boolean retval = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
457 if (!isServer) {
a61af66fc99e Initial load
duke
parents:
diff changeset
458 VM.shutdown();
a61af66fc99e Initial load
duke
parents:
diff changeset
459 }
a61af66fc99e Initial load
duke
parents:
diff changeset
460 // We must not call detach() if we are a client and are connected
a61af66fc99e Initial load
duke
parents:
diff changeset
461 // to a remote debugger
a61af66fc99e Initial load
duke
parents:
diff changeset
462 Debugger dbg = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
463 DebuggerException ex = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
464 if (isServer) {
a61af66fc99e Initial load
duke
parents:
diff changeset
465 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
466 RMIHelper.unbind(serverID);
a61af66fc99e Initial load
duke
parents:
diff changeset
467 }
a61af66fc99e Initial load
duke
parents:
diff changeset
468 catch (DebuggerException de) {
a61af66fc99e Initial load
duke
parents:
diff changeset
469 ex = de;
a61af66fc99e Initial load
duke
parents:
diff changeset
470 }
a61af66fc99e Initial load
duke
parents:
diff changeset
471 dbg = debugger;
a61af66fc99e Initial load
duke
parents:
diff changeset
472 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
473 if (startupMode != REMOTE_MODE) {
a61af66fc99e Initial load
duke
parents:
diff changeset
474 dbg = debugger;
a61af66fc99e Initial load
duke
parents:
diff changeset
475 }
a61af66fc99e Initial load
duke
parents:
diff changeset
476 }
a61af66fc99e Initial load
duke
parents:
diff changeset
477 if (dbg != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
478 retval = dbg.detach();
a61af66fc99e Initial load
duke
parents:
diff changeset
479 }
a61af66fc99e Initial load
duke
parents:
diff changeset
480
a61af66fc99e Initial load
duke
parents:
diff changeset
481 debugger = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
482 machDesc = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
483 db = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
484 if (ex != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
485 throw(ex);
a61af66fc99e Initial load
duke
parents:
diff changeset
486 }
a61af66fc99e Initial load
duke
parents:
diff changeset
487 return retval;
a61af66fc99e Initial load
duke
parents:
diff changeset
488 }
a61af66fc99e Initial load
duke
parents:
diff changeset
489
a61af66fc99e Initial load
duke
parents:
diff changeset
490 private void go() {
a61af66fc99e Initial load
duke
parents:
diff changeset
491 setupDebugger();
a61af66fc99e Initial load
duke
parents:
diff changeset
492 javaMode = setupVM();
a61af66fc99e Initial load
duke
parents:
diff changeset
493 }
a61af66fc99e Initial load
duke
parents:
diff changeset
494
a61af66fc99e Initial load
duke
parents:
diff changeset
495 private void setupDebugger() {
a61af66fc99e Initial load
duke
parents:
diff changeset
496 if (startupMode != REMOTE_MODE) {
a61af66fc99e Initial load
duke
parents:
diff changeset
497 //
a61af66fc99e Initial load
duke
parents:
diff changeset
498 // Local mode (client attaching to local process or setting up
a61af66fc99e Initial load
duke
parents:
diff changeset
499 // server, but not client attaching to server)
a61af66fc99e Initial load
duke
parents:
diff changeset
500 //
a61af66fc99e Initial load
duke
parents:
diff changeset
501
a61af66fc99e Initial load
duke
parents:
diff changeset
502 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
503 os = PlatformInfo.getOS();
a61af66fc99e Initial load
duke
parents:
diff changeset
504 cpu = PlatformInfo.getCPU();
a61af66fc99e Initial load
duke
parents:
diff changeset
505 }
a61af66fc99e Initial load
duke
parents:
diff changeset
506 catch (UnsupportedPlatformException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
507 throw new DebuggerException(e);
a61af66fc99e Initial load
duke
parents:
diff changeset
508 }
a61af66fc99e Initial load
duke
parents:
diff changeset
509 fileSep = System.getProperty("file.separator");
a61af66fc99e Initial load
duke
parents:
diff changeset
510
a61af66fc99e Initial load
duke
parents:
diff changeset
511 if (os.equals("solaris")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
512 setupDebuggerSolaris();
a61af66fc99e Initial load
duke
parents:
diff changeset
513 } else if (os.equals("win32")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
514 setupDebuggerWin32();
a61af66fc99e Initial load
duke
parents:
diff changeset
515 } else if (os.equals("linux")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
516 setupDebuggerLinux();
a61af66fc99e Initial load
duke
parents:
diff changeset
517 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
518 // Add support for more operating systems here
a61af66fc99e Initial load
duke
parents:
diff changeset
519 throw new DebuggerException("Operating system " + os + " not yet supported");
a61af66fc99e Initial load
duke
parents:
diff changeset
520 }
a61af66fc99e Initial load
duke
parents:
diff changeset
521 if (isServer) {
a61af66fc99e Initial load
duke
parents:
diff changeset
522 RemoteDebuggerServer remote = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
523 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
524 remote = new RemoteDebuggerServer(debugger);
a61af66fc99e Initial load
duke
parents:
diff changeset
525 }
a61af66fc99e Initial load
duke
parents:
diff changeset
526 catch (RemoteException rem) {
a61af66fc99e Initial load
duke
parents:
diff changeset
527 throw new DebuggerException(rem);
a61af66fc99e Initial load
duke
parents:
diff changeset
528 }
a61af66fc99e Initial load
duke
parents:
diff changeset
529 RMIHelper.rebind(serverID, remote);
a61af66fc99e Initial load
duke
parents:
diff changeset
530 }
a61af66fc99e Initial load
duke
parents:
diff changeset
531 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
532 //
a61af66fc99e Initial load
duke
parents:
diff changeset
533 // Remote mode (client attaching to server)
a61af66fc99e Initial load
duke
parents:
diff changeset
534 //
a61af66fc99e Initial load
duke
parents:
diff changeset
535
a61af66fc99e Initial load
duke
parents:
diff changeset
536 // Create and install a security manager
a61af66fc99e Initial load
duke
parents:
diff changeset
537
a61af66fc99e Initial load
duke
parents:
diff changeset
538 // FIXME: currently commented out because we were having
a61af66fc99e Initial load
duke
parents:
diff changeset
539 // security problems since we're "in the sun.* hierarchy" here.
a61af66fc99e Initial load
duke
parents:
diff changeset
540 // Perhaps a permissive policy file would work around this. In
a61af66fc99e Initial load
duke
parents:
diff changeset
541 // the long run, will probably have to move into com.sun.*.
a61af66fc99e Initial load
duke
parents:
diff changeset
542
a61af66fc99e Initial load
duke
parents:
diff changeset
543 // if (System.getSecurityManager() == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
544 // System.setSecurityManager(new RMISecurityManager());
a61af66fc99e Initial load
duke
parents:
diff changeset
545 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
546
a61af66fc99e Initial load
duke
parents:
diff changeset
547 connectRemoteDebugger();
a61af66fc99e Initial load
duke
parents:
diff changeset
548 }
a61af66fc99e Initial load
duke
parents:
diff changeset
549 }
a61af66fc99e Initial load
duke
parents:
diff changeset
550
a61af66fc99e Initial load
duke
parents:
diff changeset
551 private boolean setupVM() {
a61af66fc99e Initial load
duke
parents:
diff changeset
552 // We need to instantiate a HotSpotTypeDataBase on both the client
a61af66fc99e Initial load
duke
parents:
diff changeset
553 // and server machine. On the server it is only currently used to
a61af66fc99e Initial load
duke
parents:
diff changeset
554 // configure the Java primitive type sizes (which we should
a61af66fc99e Initial load
duke
parents:
diff changeset
555 // consider making constant). On the client it is used to
a61af66fc99e Initial load
duke
parents:
diff changeset
556 // configure the VM.
a61af66fc99e Initial load
duke
parents:
diff changeset
557
a61af66fc99e Initial load
duke
parents:
diff changeset
558 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
559 if (os.equals("solaris")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
560 db = new HotSpotTypeDataBase(machDesc, new HotSpotSolarisVtblAccess(debugger, jvmLibNames),
a61af66fc99e Initial load
duke
parents:
diff changeset
561 debugger, jvmLibNames);
a61af66fc99e Initial load
duke
parents:
diff changeset
562 } else if (os.equals("win32")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
563 db = new HotSpotTypeDataBase(machDesc, new Win32VtblAccess(debugger, jvmLibNames),
a61af66fc99e Initial load
duke
parents:
diff changeset
564 debugger, jvmLibNames);
a61af66fc99e Initial load
duke
parents:
diff changeset
565 } else if (os.equals("linux")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
566 db = new HotSpotTypeDataBase(machDesc, new LinuxVtblAccess(debugger, jvmLibNames),
a61af66fc99e Initial load
duke
parents:
diff changeset
567 debugger, jvmLibNames);
a61af66fc99e Initial load
duke
parents:
diff changeset
568 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
569 throw new DebuggerException("OS \"" + os + "\" not yet supported (no VtblAccess implemented yet)");
a61af66fc99e Initial load
duke
parents:
diff changeset
570 }
a61af66fc99e Initial load
duke
parents:
diff changeset
571 }
a61af66fc99e Initial load
duke
parents:
diff changeset
572 catch (NoSuchSymbolException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
573 e.printStackTrace();
a61af66fc99e Initial load
duke
parents:
diff changeset
574 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
575 }
a61af66fc99e Initial load
duke
parents:
diff changeset
576
a61af66fc99e Initial load
duke
parents:
diff changeset
577 if (startupMode != REMOTE_MODE) {
a61af66fc99e Initial load
duke
parents:
diff changeset
578 // Configure the debugger with the primitive type sizes just obtained from the VM
a61af66fc99e Initial load
duke
parents:
diff changeset
579 debugger.configureJavaPrimitiveTypeSizes(db.getJBooleanType().getSize(),
a61af66fc99e Initial load
duke
parents:
diff changeset
580 db.getJByteType().getSize(),
a61af66fc99e Initial load
duke
parents:
diff changeset
581 db.getJCharType().getSize(),
a61af66fc99e Initial load
duke
parents:
diff changeset
582 db.getJDoubleType().getSize(),
a61af66fc99e Initial load
duke
parents:
diff changeset
583 db.getJFloatType().getSize(),
a61af66fc99e Initial load
duke
parents:
diff changeset
584 db.getJIntType().getSize(),
a61af66fc99e Initial load
duke
parents:
diff changeset
585 db.getJLongType().getSize(),
a61af66fc99e Initial load
duke
parents:
diff changeset
586 db.getJShortType().getSize());
a61af66fc99e Initial load
duke
parents:
diff changeset
587 }
a61af66fc99e Initial load
duke
parents:
diff changeset
588
a61af66fc99e Initial load
duke
parents:
diff changeset
589 if (!isServer) {
a61af66fc99e Initial load
duke
parents:
diff changeset
590 // Do not initialize the VM on the server (unnecessary, since it's
a61af66fc99e Initial load
duke
parents:
diff changeset
591 // instantiated on the client)
a61af66fc99e Initial load
duke
parents:
diff changeset
592 VM.initialize(db, debugger);
a61af66fc99e Initial load
duke
parents:
diff changeset
593 }
a61af66fc99e Initial load
duke
parents:
diff changeset
594
a61af66fc99e Initial load
duke
parents:
diff changeset
595 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
596 jvmdi = new ServiceabilityAgentJVMDIModule(debugger, saLibNames);
a61af66fc99e Initial load
duke
parents:
diff changeset
597 if (jvmdi.canAttach()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
598 jvmdi.attach();
a61af66fc99e Initial load
duke
parents:
diff changeset
599 jvmdi.setCommandTimeout(6000);
a61af66fc99e Initial load
duke
parents:
diff changeset
600 debugPrintln("Attached to Serviceability Agent's JVMDI module.");
a61af66fc99e Initial load
duke
parents:
diff changeset
601 // Jog VM to suspended point with JVMDI module
a61af66fc99e Initial load
duke
parents:
diff changeset
602 resume();
a61af66fc99e Initial load
duke
parents:
diff changeset
603 suspendJava();
a61af66fc99e Initial load
duke
parents:
diff changeset
604 suspend();
a61af66fc99e Initial load
duke
parents:
diff changeset
605 debugPrintln("Suspended all Java threads.");
a61af66fc99e Initial load
duke
parents:
diff changeset
606 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
607 debugPrintln("Could not locate SA's JVMDI module; skipping attachment");
a61af66fc99e Initial load
duke
parents:
diff changeset
608 jvmdi = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
609 }
a61af66fc99e Initial load
duke
parents:
diff changeset
610 } catch (Exception e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
611 e.printStackTrace();
a61af66fc99e Initial load
duke
parents:
diff changeset
612 jvmdi = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
613 }
a61af66fc99e Initial load
duke
parents:
diff changeset
614
a61af66fc99e Initial load
duke
parents:
diff changeset
615 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
616 }
a61af66fc99e Initial load
duke
parents:
diff changeset
617
a61af66fc99e Initial load
duke
parents:
diff changeset
618 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
619 // OS-specific debugger setup/connect routines
a61af66fc99e Initial load
duke
parents:
diff changeset
620 //
a61af66fc99e Initial load
duke
parents:
diff changeset
621
a61af66fc99e Initial load
duke
parents:
diff changeset
622 //
a61af66fc99e Initial load
duke
parents:
diff changeset
623 // Solaris
a61af66fc99e Initial load
duke
parents:
diff changeset
624 //
a61af66fc99e Initial load
duke
parents:
diff changeset
625
a61af66fc99e Initial load
duke
parents:
diff changeset
626 private void setupDebuggerSolaris() {
a61af66fc99e Initial load
duke
parents:
diff changeset
627 setupJVMLibNamesSolaris();
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
628 ProcDebuggerLocal dbg = new ProcDebuggerLocal(null, true);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
629 debugger = dbg;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
630 attachDebugger();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
631
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
632 // Set up CPU-dependent stuff
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
633 if (cpu.equals("x86")) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
634 machDesc = new MachineDescriptionIntelX86();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
635 } else if (cpu.equals("sparc")) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
636 int addressSize = dbg.getRemoteProcessAddressSize();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
637 if (addressSize == -1) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
638 throw new DebuggerException("Error occurred while trying to determine the remote process's address size");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
639 }
a61af66fc99e Initial load
duke
parents:
diff changeset
640
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
641 if (addressSize == 32) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
642 machDesc = new MachineDescriptionSPARC32Bit();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
643 } else if (addressSize == 64) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
644 machDesc = new MachineDescriptionSPARC64Bit();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
645 } else {
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
646 throw new DebuggerException("Address size " + addressSize + " is not supported on SPARC");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
647 }
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
648 } else if (cpu.equals("amd64")) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
649 machDesc = new MachineDescriptionAMD64();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
650 } else {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
651 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
652 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
653
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
654 dbg.setMachineDescription(machDesc);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
655 }
a61af66fc99e Initial load
duke
parents:
diff changeset
656
a61af66fc99e Initial load
duke
parents:
diff changeset
657 private void connectRemoteDebugger() throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
658 RemoteDebugger remote =
a61af66fc99e Initial load
duke
parents:
diff changeset
659 (RemoteDebugger) RMIHelper.lookup(debugServerID);
a61af66fc99e Initial load
duke
parents:
diff changeset
660 debugger = new RemoteDebuggerClient(remote);
a61af66fc99e Initial load
duke
parents:
diff changeset
661 machDesc = ((RemoteDebuggerClient) debugger).getMachineDescription();
a61af66fc99e Initial load
duke
parents:
diff changeset
662 os = debugger.getOS();
a61af66fc99e Initial load
duke
parents:
diff changeset
663 if (os.equals("solaris")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
664 setupJVMLibNamesSolaris();
a61af66fc99e Initial load
duke
parents:
diff changeset
665 } else if (os.equals("win32")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
666 setupJVMLibNamesWin32();
a61af66fc99e Initial load
duke
parents:
diff changeset
667 } else if (os.equals("linux")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
668 setupJVMLibNamesLinux();
a61af66fc99e Initial load
duke
parents:
diff changeset
669 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
670 throw new RuntimeException("Unknown OS type");
a61af66fc99e Initial load
duke
parents:
diff changeset
671 }
a61af66fc99e Initial load
duke
parents:
diff changeset
672
a61af66fc99e Initial load
duke
parents:
diff changeset
673 cpu = debugger.getCPU();
a61af66fc99e Initial load
duke
parents:
diff changeset
674 }
a61af66fc99e Initial load
duke
parents:
diff changeset
675
a61af66fc99e Initial load
duke
parents:
diff changeset
676 private void setupJVMLibNamesSolaris() {
a61af66fc99e Initial load
duke
parents:
diff changeset
677 jvmLibNames = new String[] { "libjvm.so", "libjvm_g.so", "gamma_g" };
a61af66fc99e Initial load
duke
parents:
diff changeset
678 saLibNames = new String[] { "libsa.so", "libsa_g.so" };
a61af66fc99e Initial load
duke
parents:
diff changeset
679 }
a61af66fc99e Initial load
duke
parents:
diff changeset
680
a61af66fc99e Initial load
duke
parents:
diff changeset
681 //
a61af66fc99e Initial load
duke
parents:
diff changeset
682 // Win32
a61af66fc99e Initial load
duke
parents:
diff changeset
683 //
a61af66fc99e Initial load
duke
parents:
diff changeset
684
a61af66fc99e Initial load
duke
parents:
diff changeset
685 private void setupDebuggerWin32() {
a61af66fc99e Initial load
duke
parents:
diff changeset
686 setupJVMLibNamesWin32();
a61af66fc99e Initial load
duke
parents:
diff changeset
687
a61af66fc99e Initial load
duke
parents:
diff changeset
688 if (cpu.equals("x86")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
689 machDesc = new MachineDescriptionIntelX86();
a61af66fc99e Initial load
duke
parents:
diff changeset
690 } else if (cpu.equals("amd64")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
691 machDesc = new MachineDescriptionAMD64();
a61af66fc99e Initial load
duke
parents:
diff changeset
692 } else if (cpu.equals("ia64")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
693 machDesc = new MachineDescriptionIA64();
a61af66fc99e Initial load
duke
parents:
diff changeset
694 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
695 throw new DebuggerException("Win32 supported under x86, amd64 and ia64 only");
a61af66fc99e Initial load
duke
parents:
diff changeset
696 }
a61af66fc99e Initial load
duke
parents:
diff changeset
697
a61af66fc99e Initial load
duke
parents:
diff changeset
698 // Note we do not use a cache for the local debugger in server
a61af66fc99e Initial load
duke
parents:
diff changeset
699 // mode; it will be taken care of on the client side (once remote
a61af66fc99e Initial load
duke
parents:
diff changeset
700 // debugging is implemented).
a61af66fc99e Initial load
duke
parents:
diff changeset
701
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
702 debugger = new WindbgDebuggerLocal(machDesc, !isServer);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
703
a61af66fc99e Initial load
duke
parents:
diff changeset
704 attachDebugger();
a61af66fc99e Initial load
duke
parents:
diff changeset
705 }
a61af66fc99e Initial load
duke
parents:
diff changeset
706
a61af66fc99e Initial load
duke
parents:
diff changeset
707 private void setupJVMLibNamesWin32() {
a61af66fc99e Initial load
duke
parents:
diff changeset
708 jvmLibNames = new String[] { "jvm.dll", "jvm_g.dll" };
a61af66fc99e Initial load
duke
parents:
diff changeset
709 saLibNames = new String[] { "sa.dll", "sa_g.dll" };
a61af66fc99e Initial load
duke
parents:
diff changeset
710 }
a61af66fc99e Initial load
duke
parents:
diff changeset
711
a61af66fc99e Initial load
duke
parents:
diff changeset
712 //
a61af66fc99e Initial load
duke
parents:
diff changeset
713 // Linux
a61af66fc99e Initial load
duke
parents:
diff changeset
714 //
a61af66fc99e Initial load
duke
parents:
diff changeset
715
a61af66fc99e Initial load
duke
parents:
diff changeset
716 private void setupDebuggerLinux() {
a61af66fc99e Initial load
duke
parents:
diff changeset
717 setupJVMLibNamesLinux();
a61af66fc99e Initial load
duke
parents:
diff changeset
718
a61af66fc99e Initial load
duke
parents:
diff changeset
719 if (cpu.equals("x86")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
720 machDesc = new MachineDescriptionIntelX86();
a61af66fc99e Initial load
duke
parents:
diff changeset
721 } else if (cpu.equals("ia64")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
722 machDesc = new MachineDescriptionIA64();
a61af66fc99e Initial load
duke
parents:
diff changeset
723 } else if (cpu.equals("amd64")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
724 machDesc = new MachineDescriptionAMD64();
a61af66fc99e Initial load
duke
parents:
diff changeset
725 } else if (cpu.equals("sparc")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
726 if (LinuxDebuggerLocal.getAddressSize()==8) {
a61af66fc99e Initial load
duke
parents:
diff changeset
727 machDesc = new MachineDescriptionSPARC64Bit();
a61af66fc99e Initial load
duke
parents:
diff changeset
728 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
729 machDesc = new MachineDescriptionSPARC32Bit();
a61af66fc99e Initial load
duke
parents:
diff changeset
730 }
a61af66fc99e Initial load
duke
parents:
diff changeset
731 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
732 throw new DebuggerException("Linux only supported on x86/ia64/amd64/sparc/sparc64");
a61af66fc99e Initial load
duke
parents:
diff changeset
733 }
a61af66fc99e Initial load
duke
parents:
diff changeset
734
a61af66fc99e Initial load
duke
parents:
diff changeset
735 // Note we do not use a cache for the local debugger in server
a61af66fc99e Initial load
duke
parents:
diff changeset
736 // mode; it will be taken care of on the client side (once remote
a61af66fc99e Initial load
duke
parents:
diff changeset
737 // debugging is implemented).
a61af66fc99e Initial load
duke
parents:
diff changeset
738
a61af66fc99e Initial load
duke
parents:
diff changeset
739 debugger = new LinuxDebuggerLocal(machDesc, !isServer);
a61af66fc99e Initial load
duke
parents:
diff changeset
740 attachDebugger();
a61af66fc99e Initial load
duke
parents:
diff changeset
741 }
a61af66fc99e Initial load
duke
parents:
diff changeset
742
a61af66fc99e Initial load
duke
parents:
diff changeset
743 private void setupJVMLibNamesLinux() {
a61af66fc99e Initial load
duke
parents:
diff changeset
744 // same as solaris
a61af66fc99e Initial load
duke
parents:
diff changeset
745 setupJVMLibNamesSolaris();
a61af66fc99e Initial load
duke
parents:
diff changeset
746 }
a61af66fc99e Initial load
duke
parents:
diff changeset
747
a61af66fc99e Initial load
duke
parents:
diff changeset
748 /** Convenience routine which should be called by per-platform
a61af66fc99e Initial load
duke
parents:
diff changeset
749 debugger setup. Should not be called when startupMode is
a61af66fc99e Initial load
duke
parents:
diff changeset
750 REMOTE_MODE. */
a61af66fc99e Initial load
duke
parents:
diff changeset
751 private void attachDebugger() {
a61af66fc99e Initial load
duke
parents:
diff changeset
752 if (startupMode == PROCESS_MODE) {
a61af66fc99e Initial load
duke
parents:
diff changeset
753 debugger.attach(pid);
a61af66fc99e Initial load
duke
parents:
diff changeset
754 } else if (startupMode == CORE_FILE_MODE) {
a61af66fc99e Initial load
duke
parents:
diff changeset
755 debugger.attach(executableName, coreFileName);
a61af66fc99e Initial load
duke
parents:
diff changeset
756 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
757 throw new DebuggerException("Should not call attach() for startupMode == " + startupMode);
a61af66fc99e Initial load
duke
parents:
diff changeset
758 }
a61af66fc99e Initial load
duke
parents:
diff changeset
759 }
a61af66fc99e Initial load
duke
parents:
diff changeset
760 }