annotate agent/src/share/classes/sun/jvm/hotspot/debugger/remote/RemoteDebuggerClient.java @ 0:a61af66fc99e jdk7-b24

Initial load
author duke
date Sat, 01 Dec 2007 00:00:00 +0000
parents
children ba764ed4b6f2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2 * Copyright 2002-2004 Sun Microsystems, Inc. All Rights Reserved.
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 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
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.debugger.remote;
a61af66fc99e Initial load
duke
parents:
diff changeset
26
a61af66fc99e Initial load
duke
parents:
diff changeset
27 import java.rmi.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
28 import java.util.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
29
a61af66fc99e Initial load
duke
parents:
diff changeset
30 import sun.jvm.hotspot.debugger.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 import sun.jvm.hotspot.debugger.cdbg.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
32 import sun.jvm.hotspot.debugger.remote.sparc.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
33 import sun.jvm.hotspot.debugger.remote.x86.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
34 import sun.jvm.hotspot.debugger.remote.amd64.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
35
a61af66fc99e Initial load
duke
parents:
diff changeset
36 /** An implementation of Debugger which wraps a
a61af66fc99e Initial load
duke
parents:
diff changeset
37 RemoteDebugger, providing remote debugging via RMI.
a61af66fc99e Initial load
duke
parents:
diff changeset
38 This implementation provides caching of the remote process's
a61af66fc99e Initial load
duke
parents:
diff changeset
39 address space on the local machine where the user interface is
a61af66fc99e Initial load
duke
parents:
diff changeset
40 running. */
a61af66fc99e Initial load
duke
parents:
diff changeset
41
a61af66fc99e Initial load
duke
parents:
diff changeset
42 public class RemoteDebuggerClient extends DebuggerBase implements JVMDebugger {
a61af66fc99e Initial load
duke
parents:
diff changeset
43 private RemoteDebugger remoteDebugger;
a61af66fc99e Initial load
duke
parents:
diff changeset
44 private RemoteThreadFactory threadFactory;
a61af66fc99e Initial load
duke
parents:
diff changeset
45 private boolean unalignedAccessesOkay = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
46 private static final int cacheSize = 16 * 1024 * 1024; // 16 MB
a61af66fc99e Initial load
duke
parents:
diff changeset
47
a61af66fc99e Initial load
duke
parents:
diff changeset
48 public RemoteDebuggerClient(RemoteDebugger remoteDebugger) throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
49 super();
a61af66fc99e Initial load
duke
parents:
diff changeset
50 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
51 this.remoteDebugger = remoteDebugger;
a61af66fc99e Initial load
duke
parents:
diff changeset
52 machDesc = remoteDebugger.getMachineDescription();
a61af66fc99e Initial load
duke
parents:
diff changeset
53 utils = new DebuggerUtilities(machDesc.getAddressSize(), machDesc.isBigEndian());
a61af66fc99e Initial load
duke
parents:
diff changeset
54 int cacheNumPages;
a61af66fc99e Initial load
duke
parents:
diff changeset
55 int cachePageSize;
a61af66fc99e Initial load
duke
parents:
diff changeset
56 String cpu = remoteDebugger.getCPU();
a61af66fc99e Initial load
duke
parents:
diff changeset
57 // page size. (FIXME: should pick this up from the remoteDebugger.)
a61af66fc99e Initial load
duke
parents:
diff changeset
58 if (cpu.equals("sparc")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
59 threadFactory = new RemoteSPARCThreadFactory(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
60 cachePageSize = 8192;
a61af66fc99e Initial load
duke
parents:
diff changeset
61 cacheNumPages = parseCacheNumPagesProperty(cacheSize / cachePageSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
62 } else if (cpu.equals("x86")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
63 threadFactory = new RemoteX86ThreadFactory(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
64 cachePageSize = 4096;
a61af66fc99e Initial load
duke
parents:
diff changeset
65 cacheNumPages = parseCacheNumPagesProperty(cacheSize / cachePageSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
66 unalignedAccessesOkay = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
67 } else if (cpu.equals("amd64")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
68 threadFactory = new RemoteAMD64ThreadFactory(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
69 cachePageSize = 4096;
a61af66fc99e Initial load
duke
parents:
diff changeset
70 cacheNumPages = parseCacheNumPagesProperty(cacheSize / cachePageSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
71 unalignedAccessesOkay = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
72 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
73 throw new DebuggerException("Thread access for CPU architecture " + cpu + " not yet supported");
a61af66fc99e Initial load
duke
parents:
diff changeset
74 }
a61af66fc99e Initial load
duke
parents:
diff changeset
75
a61af66fc99e Initial load
duke
parents:
diff changeset
76 // Cache portion of the remote process's address space.
a61af66fc99e Initial load
duke
parents:
diff changeset
77 initCache(cachePageSize, cacheNumPages);
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79 jbooleanSize = remoteDebugger.getJBooleanSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
80 jbyteSize = remoteDebugger.getJByteSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
81 jcharSize = remoteDebugger.getJCharSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
82 jdoubleSize = remoteDebugger.getJDoubleSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
83 jfloatSize = remoteDebugger.getJFloatSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
84 jintSize = remoteDebugger.getJIntSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
85 jlongSize = remoteDebugger.getJLongSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
86 jshortSize = remoteDebugger.getJShortSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
87 javaPrimitiveTypesConfigured = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
88 }
a61af66fc99e Initial load
duke
parents:
diff changeset
89 catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
90 throw new DebuggerException(e);
a61af66fc99e Initial load
duke
parents:
diff changeset
91 }
a61af66fc99e Initial load
duke
parents:
diff changeset
92 }
a61af66fc99e Initial load
duke
parents:
diff changeset
93
a61af66fc99e Initial load
duke
parents:
diff changeset
94 public long[] getThreadIntegerRegisterSet(Address addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
95 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
96 return remoteDebugger.getThreadIntegerRegisterSet(getAddressValue(addr), true);
a61af66fc99e Initial load
duke
parents:
diff changeset
97 }
a61af66fc99e Initial load
duke
parents:
diff changeset
98 catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
99 throw new DebuggerException(e);
a61af66fc99e Initial load
duke
parents:
diff changeset
100 }
a61af66fc99e Initial load
duke
parents:
diff changeset
101 }
a61af66fc99e Initial load
duke
parents:
diff changeset
102
a61af66fc99e Initial load
duke
parents:
diff changeset
103 public long[] getThreadIntegerRegisterSet(long id) {
a61af66fc99e Initial load
duke
parents:
diff changeset
104 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
105 return remoteDebugger.getThreadIntegerRegisterSet(id, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
106 }
a61af66fc99e Initial load
duke
parents:
diff changeset
107 catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
108 throw new DebuggerException(e);
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 /** Unimplemented in this class (remote remoteDebugger should already be attached) */
a61af66fc99e Initial load
duke
parents:
diff changeset
113 public boolean hasProcessList() throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
114 throw new DebuggerException("Should not be called on RemoteDebuggerClient");
a61af66fc99e Initial load
duke
parents:
diff changeset
115 }
a61af66fc99e Initial load
duke
parents:
diff changeset
116
a61af66fc99e Initial load
duke
parents:
diff changeset
117 /** Unimplemented in this class (remote remoteDebugger should already be attached) */
a61af66fc99e Initial load
duke
parents:
diff changeset
118 public List getProcessList() throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
119 throw new DebuggerException("Should not be called on RemoteDebuggerClient");
a61af66fc99e Initial load
duke
parents:
diff changeset
120 }
a61af66fc99e Initial load
duke
parents:
diff changeset
121
a61af66fc99e Initial load
duke
parents:
diff changeset
122 /** Unimplemented in this class (remote remoteDebugger should already be attached) */
a61af66fc99e Initial load
duke
parents:
diff changeset
123 public void attach(int processID) throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
124 throw new DebuggerException("Should not be called on RemoteDebuggerClient");
a61af66fc99e Initial load
duke
parents:
diff changeset
125 }
a61af66fc99e Initial load
duke
parents:
diff changeset
126
a61af66fc99e Initial load
duke
parents:
diff changeset
127 /** Unimplemented in this class (remote remoteDebugger should already be attached) */
a61af66fc99e Initial load
duke
parents:
diff changeset
128 public void attach(String executableName, String coreFileName) throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
129 throw new DebuggerException("Should not be called on RemoteDebuggerClient");
a61af66fc99e Initial load
duke
parents:
diff changeset
130 }
a61af66fc99e Initial load
duke
parents:
diff changeset
131
a61af66fc99e Initial load
duke
parents:
diff changeset
132 /** Unimplemented in this class (remote remoteDebugger can not be detached) */
a61af66fc99e Initial load
duke
parents:
diff changeset
133 public boolean detach() {
a61af66fc99e Initial load
duke
parents:
diff changeset
134 throw new DebuggerException("Should not be called on RemoteDebuggerClient");
a61af66fc99e Initial load
duke
parents:
diff changeset
135 }
a61af66fc99e Initial load
duke
parents:
diff changeset
136
a61af66fc99e Initial load
duke
parents:
diff changeset
137 public Address parseAddress(String addressString) throws NumberFormatException {
a61af66fc99e Initial load
duke
parents:
diff changeset
138 long addr = utils.scanAddress(addressString);
a61af66fc99e Initial load
duke
parents:
diff changeset
139 if (addr == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
140 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
141 }
a61af66fc99e Initial load
duke
parents:
diff changeset
142 return new RemoteAddress(this, addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
143 }
a61af66fc99e Initial load
duke
parents:
diff changeset
144
a61af66fc99e Initial load
duke
parents:
diff changeset
145 public String getOS() throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
146 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
147 return remoteDebugger.getOS();
a61af66fc99e Initial load
duke
parents:
diff changeset
148 }
a61af66fc99e Initial load
duke
parents:
diff changeset
149 catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
150 throw new DebuggerException(e);
a61af66fc99e Initial load
duke
parents:
diff changeset
151 }
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 String getCPU() {
a61af66fc99e Initial load
duke
parents:
diff changeset
155 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
156 return remoteDebugger.getCPU();
a61af66fc99e Initial load
duke
parents:
diff changeset
157 }
a61af66fc99e Initial load
duke
parents:
diff changeset
158 catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
159 throw new DebuggerException(e);
a61af66fc99e Initial load
duke
parents:
diff changeset
160 }
a61af66fc99e Initial load
duke
parents:
diff changeset
161 }
a61af66fc99e Initial load
duke
parents:
diff changeset
162
a61af66fc99e Initial load
duke
parents:
diff changeset
163 public boolean hasConsole() throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
164 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
165 return remoteDebugger.hasConsole();
a61af66fc99e Initial load
duke
parents:
diff changeset
166 } catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
167 throw new DebuggerException(e);
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 public String consoleExecuteCommand(String cmd) throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
172 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
173 return remoteDebugger.consoleExecuteCommand(cmd);
a61af66fc99e Initial load
duke
parents:
diff changeset
174 }
a61af66fc99e Initial load
duke
parents:
diff changeset
175 catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
176 throw new DebuggerException(e);
a61af66fc99e Initial load
duke
parents:
diff changeset
177 }
a61af66fc99e Initial load
duke
parents:
diff changeset
178 }
a61af66fc99e Initial load
duke
parents:
diff changeset
179
a61af66fc99e Initial load
duke
parents:
diff changeset
180 public String getConsolePrompt() throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
181 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
182 return remoteDebugger.getConsolePrompt();
a61af66fc99e Initial load
duke
parents:
diff changeset
183 } catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
184 throw new DebuggerException(e);
a61af66fc99e Initial load
duke
parents:
diff changeset
185 }
a61af66fc99e Initial load
duke
parents:
diff changeset
186 }
a61af66fc99e Initial load
duke
parents:
diff changeset
187
a61af66fc99e Initial load
duke
parents:
diff changeset
188 public CDebugger getCDebugger() throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
189 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
190 }
a61af66fc99e Initial load
duke
parents:
diff changeset
191
a61af66fc99e Initial load
duke
parents:
diff changeset
192 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
193 // Implementation of SymbolLookup interface
a61af66fc99e Initial load
duke
parents:
diff changeset
194
a61af66fc99e Initial load
duke
parents:
diff changeset
195 public Address lookup(String objectName, String symbol) {
a61af66fc99e Initial load
duke
parents:
diff changeset
196 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
197 long addr = remoteDebugger.lookupInProcess(objectName, symbol);
a61af66fc99e Initial load
duke
parents:
diff changeset
198 if (addr == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
199 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
200 }
a61af66fc99e Initial load
duke
parents:
diff changeset
201 return new RemoteAddress(this, addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
202 }
a61af66fc99e Initial load
duke
parents:
diff changeset
203 catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
204 throw new DebuggerException(e);
a61af66fc99e Initial load
duke
parents:
diff changeset
205 }
a61af66fc99e Initial load
duke
parents:
diff changeset
206 }
a61af66fc99e Initial load
duke
parents:
diff changeset
207
a61af66fc99e Initial load
duke
parents:
diff changeset
208 public OopHandle lookupOop(String objectName, String symbol) {
a61af66fc99e Initial load
duke
parents:
diff changeset
209 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
210 long addr = remoteDebugger.lookupInProcess(objectName, symbol);
a61af66fc99e Initial load
duke
parents:
diff changeset
211 if (addr == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
212 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
213 }
a61af66fc99e Initial load
duke
parents:
diff changeset
214 return new RemoteOopHandle(this, addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
215 }
a61af66fc99e Initial load
duke
parents:
diff changeset
216 catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
217 throw new DebuggerException(e);
a61af66fc99e Initial load
duke
parents:
diff changeset
218 }
a61af66fc99e Initial load
duke
parents:
diff changeset
219 }
a61af66fc99e Initial load
duke
parents:
diff changeset
220
a61af66fc99e Initial load
duke
parents:
diff changeset
221 /** Need to override this to relax alignment checks on x86. */
a61af66fc99e Initial load
duke
parents:
diff changeset
222 public long readCInteger(long address, long numBytes, boolean isUnsigned)
a61af66fc99e Initial load
duke
parents:
diff changeset
223 throws UnmappedAddressException, UnalignedAddressException {
a61af66fc99e Initial load
duke
parents:
diff changeset
224 if (!unalignedAccessesOkay) {
a61af66fc99e Initial load
duke
parents:
diff changeset
225 utils.checkAlignment(address, numBytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
226 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
227 // Only slightly relaxed semantics -- this is a hack, but is
a61af66fc99e Initial load
duke
parents:
diff changeset
228 // necessary on x86 where it seems the compiler is
a61af66fc99e Initial load
duke
parents:
diff changeset
229 // putting some global 64-bit data on 32-bit boundaries
a61af66fc99e Initial load
duke
parents:
diff changeset
230 if (numBytes == 8) {
a61af66fc99e Initial load
duke
parents:
diff changeset
231 utils.checkAlignment(address, 4);
a61af66fc99e Initial load
duke
parents:
diff changeset
232 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
233 utils.checkAlignment(address, numBytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
234 }
a61af66fc99e Initial load
duke
parents:
diff changeset
235 }
a61af66fc99e Initial load
duke
parents:
diff changeset
236 byte[] data = readBytes(address, numBytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
237 return utils.dataToCInteger(data, isUnsigned);
a61af66fc99e Initial load
duke
parents:
diff changeset
238 }
a61af66fc99e Initial load
duke
parents:
diff changeset
239
a61af66fc99e Initial load
duke
parents:
diff changeset
240 // Overridden from DebuggerBase because we need to relax alignment
a61af66fc99e Initial load
duke
parents:
diff changeset
241 // constraints on x86
a61af66fc99e Initial load
duke
parents:
diff changeset
242 public long readJLong(long address)
a61af66fc99e Initial load
duke
parents:
diff changeset
243 throws UnmappedAddressException, UnalignedAddressException {
a61af66fc99e Initial load
duke
parents:
diff changeset
244 // FIXME: allow this to be configurable. Undesirable to add a
a61af66fc99e Initial load
duke
parents:
diff changeset
245 // dependency on the runtime package here, though, since this
a61af66fc99e Initial load
duke
parents:
diff changeset
246 // package should be strictly underneath it.
a61af66fc99e Initial load
duke
parents:
diff changeset
247 if (unalignedAccessesOkay) {
a61af66fc99e Initial load
duke
parents:
diff changeset
248 utils.checkAlignment(address, jintSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
249 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
250 utils.checkAlignment(address, jlongSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
251 }
a61af66fc99e Initial load
duke
parents:
diff changeset
252 byte[] data = readBytes(address, jlongSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
253 return utils.dataToJLong(data, jlongSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
254 }
a61af66fc99e Initial load
duke
parents:
diff changeset
255
a61af66fc99e Initial load
duke
parents:
diff changeset
256
a61af66fc99e Initial load
duke
parents:
diff changeset
257 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
258 // Implementation of JVMDebugger interface
a61af66fc99e Initial load
duke
parents:
diff changeset
259 //
a61af66fc99e Initial load
duke
parents:
diff changeset
260
a61af66fc99e Initial load
duke
parents:
diff changeset
261 /** Unimplemented in this class (remote remoteDebugger should already be configured) */
a61af66fc99e Initial load
duke
parents:
diff changeset
262 public void configureJavaPrimitiveTypeSizes(long jbooleanSize,
a61af66fc99e Initial load
duke
parents:
diff changeset
263 long jbyteSize,
a61af66fc99e Initial load
duke
parents:
diff changeset
264 long jcharSize,
a61af66fc99e Initial load
duke
parents:
diff changeset
265 long jdoubleSize,
a61af66fc99e Initial load
duke
parents:
diff changeset
266 long jfloatSize,
a61af66fc99e Initial load
duke
parents:
diff changeset
267 long jintSize,
a61af66fc99e Initial load
duke
parents:
diff changeset
268 long jlongSize,
a61af66fc99e Initial load
duke
parents:
diff changeset
269 long jshortSize) {
a61af66fc99e Initial load
duke
parents:
diff changeset
270 throw new DebuggerException("Should not be called on RemoteDebuggerClient");
a61af66fc99e Initial load
duke
parents:
diff changeset
271 }
a61af66fc99e Initial load
duke
parents:
diff changeset
272
a61af66fc99e Initial load
duke
parents:
diff changeset
273 public void setMachineDescription(MachineDescription machDesc) {
a61af66fc99e Initial load
duke
parents:
diff changeset
274 throw new DebuggerException("Should not be called on RemoteDebuggerClient");
a61af66fc99e Initial load
duke
parents:
diff changeset
275 }
a61af66fc99e Initial load
duke
parents:
diff changeset
276
a61af66fc99e Initial load
duke
parents:
diff changeset
277 public int getRemoteProcessAddressSize() {
a61af66fc99e Initial load
duke
parents:
diff changeset
278 throw new DebuggerException("Should not be called on RemoteDebuggerClient");
a61af66fc99e Initial load
duke
parents:
diff changeset
279 }
a61af66fc99e Initial load
duke
parents:
diff changeset
280
a61af66fc99e Initial load
duke
parents:
diff changeset
281 public String addressValueToString(long addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
282 return utils.addressValueToString(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
283 }
a61af66fc99e Initial load
duke
parents:
diff changeset
284
a61af66fc99e Initial load
duke
parents:
diff changeset
285 public long getAddressValue(Address addr) throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
286 if (addr == null) return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
287 return ((RemoteAddress) addr).getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
288 }
a61af66fc99e Initial load
duke
parents:
diff changeset
289
a61af66fc99e Initial load
duke
parents:
diff changeset
290 public Address newAddress(long value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
291 if (value == 0) return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
292 return new RemoteAddress(this, value);
a61af66fc99e Initial load
duke
parents:
diff changeset
293 }
a61af66fc99e Initial load
duke
parents:
diff changeset
294
a61af66fc99e Initial load
duke
parents:
diff changeset
295 RemoteAddress readAddress(long address)
a61af66fc99e Initial load
duke
parents:
diff changeset
296 throws UnmappedAddressException, UnalignedAddressException {
a61af66fc99e Initial load
duke
parents:
diff changeset
297 long value = readAddressValue(address);
a61af66fc99e Initial load
duke
parents:
diff changeset
298 return (value == 0 ? null : new RemoteAddress(this, value));
a61af66fc99e Initial load
duke
parents:
diff changeset
299 }
a61af66fc99e Initial load
duke
parents:
diff changeset
300
a61af66fc99e Initial load
duke
parents:
diff changeset
301 RemoteOopHandle readOopHandle(long address)
a61af66fc99e Initial load
duke
parents:
diff changeset
302 throws UnmappedAddressException, UnalignedAddressException, NotInHeapException {
a61af66fc99e Initial load
duke
parents:
diff changeset
303 long value = readAddressValue(address);
a61af66fc99e Initial load
duke
parents:
diff changeset
304 return (value == 0 ? null : new RemoteOopHandle(this, value));
a61af66fc99e Initial load
duke
parents:
diff changeset
305 }
a61af66fc99e Initial load
duke
parents:
diff changeset
306
a61af66fc99e Initial load
duke
parents:
diff changeset
307 boolean areThreadsEqual(Address addr1, Address addr2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
308 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
309 return remoteDebugger.areThreadsEqual(getAddressValue(addr1), true,
a61af66fc99e Initial load
duke
parents:
diff changeset
310 getAddressValue(addr2), true);
a61af66fc99e Initial load
duke
parents:
diff changeset
311 } catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
312 }
a61af66fc99e Initial load
duke
parents:
diff changeset
313 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
314 }
a61af66fc99e Initial load
duke
parents:
diff changeset
315
a61af66fc99e Initial load
duke
parents:
diff changeset
316 boolean areThreadsEqual(long id1, long id2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
317 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
318 return remoteDebugger.areThreadsEqual(id1, false, id2, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
319 } catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
320 }
a61af66fc99e Initial load
duke
parents:
diff changeset
321 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
322 }
a61af66fc99e Initial load
duke
parents:
diff changeset
323
a61af66fc99e Initial load
duke
parents:
diff changeset
324 boolean areThreadsEqual(Address addr1, long id2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
325 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
326 return remoteDebugger.areThreadsEqual(getAddressValue(addr1), true, id2, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
327 } catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
328 }
a61af66fc99e Initial load
duke
parents:
diff changeset
329 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
330 }
a61af66fc99e Initial load
duke
parents:
diff changeset
331
a61af66fc99e Initial load
duke
parents:
diff changeset
332 boolean areThreadsEqual(long id1, Address addr2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
333 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
334 return remoteDebugger.areThreadsEqual(id1, false, getAddressValue(addr2), true);
a61af66fc99e Initial load
duke
parents:
diff changeset
335 } catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
336 }
a61af66fc99e Initial load
duke
parents:
diff changeset
337 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
338 }
a61af66fc99e Initial load
duke
parents:
diff changeset
339
a61af66fc99e Initial load
duke
parents:
diff changeset
340 int getThreadHashCode(Address a) {
a61af66fc99e Initial load
duke
parents:
diff changeset
341 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
342 return remoteDebugger.getThreadHashCode(getAddressValue(a), true);
a61af66fc99e Initial load
duke
parents:
diff changeset
343 } catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
344 }
a61af66fc99e Initial load
duke
parents:
diff changeset
345 return a.hashCode();
a61af66fc99e Initial load
duke
parents:
diff changeset
346 }
a61af66fc99e Initial load
duke
parents:
diff changeset
347
a61af66fc99e Initial load
duke
parents:
diff changeset
348 int getThreadHashCode(long id) {
a61af66fc99e Initial load
duke
parents:
diff changeset
349 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
350 return remoteDebugger.getThreadHashCode(id, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
351 } catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
352 }
a61af66fc99e Initial load
duke
parents:
diff changeset
353 return (int) id;
a61af66fc99e Initial load
duke
parents:
diff changeset
354 }
a61af66fc99e Initial load
duke
parents:
diff changeset
355
a61af66fc99e Initial load
duke
parents:
diff changeset
356 public ThreadProxy getThreadForIdentifierAddress(Address addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
357 return threadFactory.createThreadWrapper(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
358 }
a61af66fc99e Initial load
duke
parents:
diff changeset
359
a61af66fc99e Initial load
duke
parents:
diff changeset
360 public ThreadProxy getThreadForThreadId(long id) {
a61af66fc99e Initial load
duke
parents:
diff changeset
361 return threadFactory.createThreadWrapper(id);
a61af66fc99e Initial load
duke
parents:
diff changeset
362 }
a61af66fc99e Initial load
duke
parents:
diff changeset
363
a61af66fc99e Initial load
duke
parents:
diff changeset
364 public MachineDescription getMachineDescription() throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
365 return machDesc;
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 reads bytes from the remote process. */
a61af66fc99e Initial load
duke
parents:
diff changeset
369 public ReadResult readBytesFromProcess(long address, long numBytes) {
a61af66fc99e Initial load
duke
parents:
diff changeset
370 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
371 return remoteDebugger.readBytesFromProcess(address, numBytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
372 }
a61af66fc99e Initial load
duke
parents:
diff changeset
373 catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
374 throw new DebuggerException(e);
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 public void writeBytesToProcess(long a, long b, byte[] c) {
a61af66fc99e Initial load
duke
parents:
diff changeset
379 throw new DebuggerException("Unimplemented!");
a61af66fc99e Initial load
duke
parents:
diff changeset
380 }
a61af66fc99e Initial load
duke
parents:
diff changeset
381 }