annotate agent/src/share/classes/sun/jvm/hotspot/debugger/remote/RemoteDebuggerClient.java @ 113:ba764ed4b6f2

6420645: Create a vm that uses compressed oops for up to 32gb heapsizes Summary: Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
author coleenp
date Sun, 13 Apr 2008 17:43:42 -0400
parents a61af66fc99e
children d1605aabd0a1
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;
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
88 heapBase = remoteDebugger.getHeapBase();
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
89 heapOopSize = remoteDebugger.getHeapOopSize();
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
90 logMinObjAlignmentInBytes = remoteDebugger.getLogMinObjAlignmentInBytes();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
91 }
a61af66fc99e Initial load
duke
parents:
diff changeset
92 catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
93 throw new DebuggerException(e);
a61af66fc99e Initial load
duke
parents:
diff changeset
94 }
a61af66fc99e Initial load
duke
parents:
diff changeset
95 }
a61af66fc99e Initial load
duke
parents:
diff changeset
96
a61af66fc99e Initial load
duke
parents:
diff changeset
97 public long[] getThreadIntegerRegisterSet(Address addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
98 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
99 return remoteDebugger.getThreadIntegerRegisterSet(getAddressValue(addr), true);
a61af66fc99e Initial load
duke
parents:
diff changeset
100 }
a61af66fc99e Initial load
duke
parents:
diff changeset
101 catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
102 throw new DebuggerException(e);
a61af66fc99e Initial load
duke
parents:
diff changeset
103 }
a61af66fc99e Initial load
duke
parents:
diff changeset
104 }
a61af66fc99e Initial load
duke
parents:
diff changeset
105
a61af66fc99e Initial load
duke
parents:
diff changeset
106 public long[] getThreadIntegerRegisterSet(long id) {
a61af66fc99e Initial load
duke
parents:
diff changeset
107 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
108 return remoteDebugger.getThreadIntegerRegisterSet(id, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
109 }
a61af66fc99e Initial load
duke
parents:
diff changeset
110 catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
111 throw new DebuggerException(e);
a61af66fc99e Initial load
duke
parents:
diff changeset
112 }
a61af66fc99e Initial load
duke
parents:
diff changeset
113 }
a61af66fc99e Initial load
duke
parents:
diff changeset
114
a61af66fc99e Initial load
duke
parents:
diff changeset
115 /** Unimplemented in this class (remote remoteDebugger should already be attached) */
a61af66fc99e Initial load
duke
parents:
diff changeset
116 public boolean hasProcessList() throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
117 throw new DebuggerException("Should not be called on RemoteDebuggerClient");
a61af66fc99e Initial load
duke
parents:
diff changeset
118 }
a61af66fc99e Initial load
duke
parents:
diff changeset
119
a61af66fc99e Initial load
duke
parents:
diff changeset
120 /** Unimplemented in this class (remote remoteDebugger should already be attached) */
a61af66fc99e Initial load
duke
parents:
diff changeset
121 public List getProcessList() throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
122 throw new DebuggerException("Should not be called on RemoteDebuggerClient");
a61af66fc99e Initial load
duke
parents:
diff changeset
123 }
a61af66fc99e Initial load
duke
parents:
diff changeset
124
a61af66fc99e Initial load
duke
parents:
diff changeset
125 /** Unimplemented in this class (remote remoteDebugger should already be attached) */
a61af66fc99e Initial load
duke
parents:
diff changeset
126 public void attach(int processID) throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
127 throw new DebuggerException("Should not be called on RemoteDebuggerClient");
a61af66fc99e Initial load
duke
parents:
diff changeset
128 }
a61af66fc99e Initial load
duke
parents:
diff changeset
129
a61af66fc99e Initial load
duke
parents:
diff changeset
130 /** Unimplemented in this class (remote remoteDebugger should already be attached) */
a61af66fc99e Initial load
duke
parents:
diff changeset
131 public void attach(String executableName, String coreFileName) throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
132 throw new DebuggerException("Should not be called on RemoteDebuggerClient");
a61af66fc99e Initial load
duke
parents:
diff changeset
133 }
a61af66fc99e Initial load
duke
parents:
diff changeset
134
a61af66fc99e Initial load
duke
parents:
diff changeset
135 /** Unimplemented in this class (remote remoteDebugger can not be detached) */
a61af66fc99e Initial load
duke
parents:
diff changeset
136 public boolean detach() {
a61af66fc99e Initial load
duke
parents:
diff changeset
137 throw new DebuggerException("Should not be called on RemoteDebuggerClient");
a61af66fc99e Initial load
duke
parents:
diff changeset
138 }
a61af66fc99e Initial load
duke
parents:
diff changeset
139
a61af66fc99e Initial load
duke
parents:
diff changeset
140 public Address parseAddress(String addressString) throws NumberFormatException {
a61af66fc99e Initial load
duke
parents:
diff changeset
141 long addr = utils.scanAddress(addressString);
a61af66fc99e Initial load
duke
parents:
diff changeset
142 if (addr == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
143 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
144 }
a61af66fc99e Initial load
duke
parents:
diff changeset
145 return new RemoteAddress(this, addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
146 }
a61af66fc99e Initial load
duke
parents:
diff changeset
147
a61af66fc99e Initial load
duke
parents:
diff changeset
148 public String getOS() throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
149 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
150 return remoteDebugger.getOS();
a61af66fc99e Initial load
duke
parents:
diff changeset
151 }
a61af66fc99e Initial load
duke
parents:
diff changeset
152 catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
153 throw new DebuggerException(e);
a61af66fc99e Initial load
duke
parents:
diff changeset
154 }
a61af66fc99e Initial load
duke
parents:
diff changeset
155 }
a61af66fc99e Initial load
duke
parents:
diff changeset
156
a61af66fc99e Initial load
duke
parents:
diff changeset
157 public String getCPU() {
a61af66fc99e Initial load
duke
parents:
diff changeset
158 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
159 return remoteDebugger.getCPU();
a61af66fc99e Initial load
duke
parents:
diff changeset
160 }
a61af66fc99e Initial load
duke
parents:
diff changeset
161 catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
162 throw new DebuggerException(e);
a61af66fc99e Initial load
duke
parents:
diff changeset
163 }
a61af66fc99e Initial load
duke
parents:
diff changeset
164 }
a61af66fc99e Initial load
duke
parents:
diff changeset
165
a61af66fc99e Initial load
duke
parents:
diff changeset
166 public boolean hasConsole() throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
167 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
168 return remoteDebugger.hasConsole();
a61af66fc99e Initial load
duke
parents:
diff changeset
169 } catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
170 throw new DebuggerException(e);
a61af66fc99e Initial load
duke
parents:
diff changeset
171 }
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 String consoleExecuteCommand(String cmd) throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
175 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
176 return remoteDebugger.consoleExecuteCommand(cmd);
a61af66fc99e Initial load
duke
parents:
diff changeset
177 }
a61af66fc99e Initial load
duke
parents:
diff changeset
178 catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
179 throw new DebuggerException(e);
a61af66fc99e Initial load
duke
parents:
diff changeset
180 }
a61af66fc99e Initial load
duke
parents:
diff changeset
181 }
a61af66fc99e Initial load
duke
parents:
diff changeset
182
a61af66fc99e Initial load
duke
parents:
diff changeset
183 public String getConsolePrompt() throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
184 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
185 return remoteDebugger.getConsolePrompt();
a61af66fc99e Initial load
duke
parents:
diff changeset
186 } catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
187 throw new DebuggerException(e);
a61af66fc99e Initial load
duke
parents:
diff changeset
188 }
a61af66fc99e Initial load
duke
parents:
diff changeset
189 }
a61af66fc99e Initial load
duke
parents:
diff changeset
190
a61af66fc99e Initial load
duke
parents:
diff changeset
191 public CDebugger getCDebugger() throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
192 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
193 }
a61af66fc99e Initial load
duke
parents:
diff changeset
194
a61af66fc99e Initial load
duke
parents:
diff changeset
195 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
196 // Implementation of SymbolLookup interface
a61af66fc99e Initial load
duke
parents:
diff changeset
197
a61af66fc99e Initial load
duke
parents:
diff changeset
198 public Address lookup(String objectName, String symbol) {
a61af66fc99e Initial load
duke
parents:
diff changeset
199 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
200 long addr = remoteDebugger.lookupInProcess(objectName, symbol);
a61af66fc99e Initial load
duke
parents:
diff changeset
201 if (addr == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
202 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
203 }
a61af66fc99e Initial load
duke
parents:
diff changeset
204 return new RemoteAddress(this, addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
205 }
a61af66fc99e Initial load
duke
parents:
diff changeset
206 catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
207 throw new DebuggerException(e);
a61af66fc99e Initial load
duke
parents:
diff changeset
208 }
a61af66fc99e Initial load
duke
parents:
diff changeset
209 }
a61af66fc99e Initial load
duke
parents:
diff changeset
210
a61af66fc99e Initial load
duke
parents:
diff changeset
211 public OopHandle lookupOop(String objectName, String symbol) {
a61af66fc99e Initial load
duke
parents:
diff changeset
212 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
213 long addr = remoteDebugger.lookupInProcess(objectName, symbol);
a61af66fc99e Initial load
duke
parents:
diff changeset
214 if (addr == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
215 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
216 }
a61af66fc99e Initial load
duke
parents:
diff changeset
217 return new RemoteOopHandle(this, addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
218 }
a61af66fc99e Initial load
duke
parents:
diff changeset
219 catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
220 throw new DebuggerException(e);
a61af66fc99e Initial load
duke
parents:
diff changeset
221 }
a61af66fc99e Initial load
duke
parents:
diff changeset
222 }
a61af66fc99e Initial load
duke
parents:
diff changeset
223
a61af66fc99e Initial load
duke
parents:
diff changeset
224 /** Need to override this to relax alignment checks on x86. */
a61af66fc99e Initial load
duke
parents:
diff changeset
225 public long readCInteger(long address, long numBytes, boolean isUnsigned)
a61af66fc99e Initial load
duke
parents:
diff changeset
226 throws UnmappedAddressException, UnalignedAddressException {
a61af66fc99e Initial load
duke
parents:
diff changeset
227 if (!unalignedAccessesOkay) {
a61af66fc99e Initial load
duke
parents:
diff changeset
228 utils.checkAlignment(address, numBytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
229 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
230 // Only slightly relaxed semantics -- this is a hack, but is
a61af66fc99e Initial load
duke
parents:
diff changeset
231 // necessary on x86 where it seems the compiler is
a61af66fc99e Initial load
duke
parents:
diff changeset
232 // putting some global 64-bit data on 32-bit boundaries
a61af66fc99e Initial load
duke
parents:
diff changeset
233 if (numBytes == 8) {
a61af66fc99e Initial load
duke
parents:
diff changeset
234 utils.checkAlignment(address, 4);
a61af66fc99e Initial load
duke
parents:
diff changeset
235 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
236 utils.checkAlignment(address, numBytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
237 }
a61af66fc99e Initial load
duke
parents:
diff changeset
238 }
a61af66fc99e Initial load
duke
parents:
diff changeset
239 byte[] data = readBytes(address, numBytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
240 return utils.dataToCInteger(data, isUnsigned);
a61af66fc99e Initial load
duke
parents:
diff changeset
241 }
a61af66fc99e Initial load
duke
parents:
diff changeset
242
a61af66fc99e Initial load
duke
parents:
diff changeset
243 // Overridden from DebuggerBase because we need to relax alignment
a61af66fc99e Initial load
duke
parents:
diff changeset
244 // constraints on x86
a61af66fc99e Initial load
duke
parents:
diff changeset
245 public long readJLong(long address)
a61af66fc99e Initial load
duke
parents:
diff changeset
246 throws UnmappedAddressException, UnalignedAddressException {
a61af66fc99e Initial load
duke
parents:
diff changeset
247 // FIXME: allow this to be configurable. Undesirable to add a
a61af66fc99e Initial load
duke
parents:
diff changeset
248 // dependency on the runtime package here, though, since this
a61af66fc99e Initial load
duke
parents:
diff changeset
249 // package should be strictly underneath it.
a61af66fc99e Initial load
duke
parents:
diff changeset
250 if (unalignedAccessesOkay) {
a61af66fc99e Initial load
duke
parents:
diff changeset
251 utils.checkAlignment(address, jintSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
252 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
253 utils.checkAlignment(address, jlongSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
254 }
a61af66fc99e Initial load
duke
parents:
diff changeset
255 byte[] data = readBytes(address, jlongSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
256 return utils.dataToJLong(data, jlongSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
257 }
a61af66fc99e Initial load
duke
parents:
diff changeset
258
a61af66fc99e Initial load
duke
parents:
diff changeset
259
a61af66fc99e Initial load
duke
parents:
diff changeset
260 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
261 // Implementation of JVMDebugger interface
a61af66fc99e Initial load
duke
parents:
diff changeset
262 //
a61af66fc99e Initial load
duke
parents:
diff changeset
263
a61af66fc99e Initial load
duke
parents:
diff changeset
264 /** Unimplemented in this class (remote remoteDebugger should already be configured) */
a61af66fc99e Initial load
duke
parents:
diff changeset
265 public void configureJavaPrimitiveTypeSizes(long jbooleanSize,
a61af66fc99e Initial load
duke
parents:
diff changeset
266 long jbyteSize,
a61af66fc99e Initial load
duke
parents:
diff changeset
267 long jcharSize,
a61af66fc99e Initial load
duke
parents:
diff changeset
268 long jdoubleSize,
a61af66fc99e Initial load
duke
parents:
diff changeset
269 long jfloatSize,
a61af66fc99e Initial load
duke
parents:
diff changeset
270 long jintSize,
a61af66fc99e Initial load
duke
parents:
diff changeset
271 long jlongSize,
a61af66fc99e Initial load
duke
parents:
diff changeset
272 long jshortSize) {
a61af66fc99e Initial load
duke
parents:
diff changeset
273 throw new DebuggerException("Should not be called on RemoteDebuggerClient");
a61af66fc99e Initial load
duke
parents:
diff changeset
274 }
a61af66fc99e Initial load
duke
parents:
diff changeset
275
a61af66fc99e Initial load
duke
parents:
diff changeset
276 public void setMachineDescription(MachineDescription machDesc) {
a61af66fc99e Initial load
duke
parents:
diff changeset
277 throw new DebuggerException("Should not be called on RemoteDebuggerClient");
a61af66fc99e Initial load
duke
parents:
diff changeset
278 }
a61af66fc99e Initial load
duke
parents:
diff changeset
279
a61af66fc99e Initial load
duke
parents:
diff changeset
280 public int getRemoteProcessAddressSize() {
a61af66fc99e Initial load
duke
parents:
diff changeset
281 throw new DebuggerException("Should not be called on RemoteDebuggerClient");
a61af66fc99e Initial load
duke
parents:
diff changeset
282 }
a61af66fc99e Initial load
duke
parents:
diff changeset
283
a61af66fc99e Initial load
duke
parents:
diff changeset
284 public String addressValueToString(long addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
285 return utils.addressValueToString(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
286 }
a61af66fc99e Initial load
duke
parents:
diff changeset
287
a61af66fc99e Initial load
duke
parents:
diff changeset
288 public long getAddressValue(Address addr) throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
289 if (addr == null) return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
290 return ((RemoteAddress) addr).getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
291 }
a61af66fc99e Initial load
duke
parents:
diff changeset
292
a61af66fc99e Initial load
duke
parents:
diff changeset
293 public Address newAddress(long value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
294 if (value == 0) return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
295 return new RemoteAddress(this, value);
a61af66fc99e Initial load
duke
parents:
diff changeset
296 }
a61af66fc99e Initial load
duke
parents:
diff changeset
297
a61af66fc99e Initial load
duke
parents:
diff changeset
298 RemoteAddress readAddress(long address)
a61af66fc99e Initial load
duke
parents:
diff changeset
299 throws UnmappedAddressException, UnalignedAddressException {
a61af66fc99e Initial load
duke
parents:
diff changeset
300 long value = readAddressValue(address);
a61af66fc99e Initial load
duke
parents:
diff changeset
301 return (value == 0 ? null : new RemoteAddress(this, value));
a61af66fc99e Initial load
duke
parents:
diff changeset
302 }
a61af66fc99e Initial load
duke
parents:
diff changeset
303
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
304 RemoteAddress readCompOopAddress(long address)
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
305 throws UnmappedAddressException, UnalignedAddressException {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
306 long value = readCompOopAddressValue(address);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
307 return (value == 0 ? null : new RemoteAddress(this, value));
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
308 }
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
309
0
a61af66fc99e Initial load
duke
parents:
diff changeset
310 RemoteOopHandle readOopHandle(long address)
a61af66fc99e Initial load
duke
parents:
diff changeset
311 throws UnmappedAddressException, UnalignedAddressException, NotInHeapException {
a61af66fc99e Initial load
duke
parents:
diff changeset
312 long value = readAddressValue(address);
a61af66fc99e Initial load
duke
parents:
diff changeset
313 return (value == 0 ? null : new RemoteOopHandle(this, value));
a61af66fc99e Initial load
duke
parents:
diff changeset
314 }
a61af66fc99e Initial load
duke
parents:
diff changeset
315
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
316 RemoteOopHandle readCompOopHandle(long address)
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
317 throws UnmappedAddressException, UnalignedAddressException, NotInHeapException {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
318 long value = readCompOopAddressValue(address);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
319 return (value == 0 ? null : new RemoteOopHandle(this, value));
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
320 }
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
321
0
a61af66fc99e Initial load
duke
parents:
diff changeset
322 boolean areThreadsEqual(Address addr1, Address addr2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
323 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
324 return remoteDebugger.areThreadsEqual(getAddressValue(addr1), true,
a61af66fc99e Initial load
duke
parents:
diff changeset
325 getAddressValue(addr2), true);
a61af66fc99e Initial load
duke
parents:
diff changeset
326 } catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
327 }
a61af66fc99e Initial load
duke
parents:
diff changeset
328 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
329 }
a61af66fc99e Initial load
duke
parents:
diff changeset
330
a61af66fc99e Initial load
duke
parents:
diff changeset
331 boolean areThreadsEqual(long id1, long id2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
332 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
333 return remoteDebugger.areThreadsEqual(id1, false, id2, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
334 } catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
335 }
a61af66fc99e Initial load
duke
parents:
diff changeset
336 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
337 }
a61af66fc99e Initial load
duke
parents:
diff changeset
338
a61af66fc99e Initial load
duke
parents:
diff changeset
339 boolean areThreadsEqual(Address addr1, long id2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
340 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
341 return remoteDebugger.areThreadsEqual(getAddressValue(addr1), true, id2, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
342 } catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
343 }
a61af66fc99e Initial load
duke
parents:
diff changeset
344 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
345 }
a61af66fc99e Initial load
duke
parents:
diff changeset
346
a61af66fc99e Initial load
duke
parents:
diff changeset
347 boolean areThreadsEqual(long id1, Address addr2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
348 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
349 return remoteDebugger.areThreadsEqual(id1, false, getAddressValue(addr2), true);
a61af66fc99e Initial load
duke
parents:
diff changeset
350 } catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
351 }
a61af66fc99e Initial load
duke
parents:
diff changeset
352 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
353 }
a61af66fc99e Initial load
duke
parents:
diff changeset
354
a61af66fc99e Initial load
duke
parents:
diff changeset
355 int getThreadHashCode(Address a) {
a61af66fc99e Initial load
duke
parents:
diff changeset
356 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
357 return remoteDebugger.getThreadHashCode(getAddressValue(a), true);
a61af66fc99e Initial load
duke
parents:
diff changeset
358 } catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
359 }
a61af66fc99e Initial load
duke
parents:
diff changeset
360 return a.hashCode();
a61af66fc99e Initial load
duke
parents:
diff changeset
361 }
a61af66fc99e Initial load
duke
parents:
diff changeset
362
a61af66fc99e Initial load
duke
parents:
diff changeset
363 int getThreadHashCode(long id) {
a61af66fc99e Initial load
duke
parents:
diff changeset
364 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
365 return remoteDebugger.getThreadHashCode(id, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
366 } catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
367 }
a61af66fc99e Initial load
duke
parents:
diff changeset
368 return (int) id;
a61af66fc99e Initial load
duke
parents:
diff changeset
369 }
a61af66fc99e Initial load
duke
parents:
diff changeset
370
a61af66fc99e Initial load
duke
parents:
diff changeset
371 public ThreadProxy getThreadForIdentifierAddress(Address addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
372 return threadFactory.createThreadWrapper(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
373 }
a61af66fc99e Initial load
duke
parents:
diff changeset
374
a61af66fc99e Initial load
duke
parents:
diff changeset
375 public ThreadProxy getThreadForThreadId(long id) {
a61af66fc99e Initial load
duke
parents:
diff changeset
376 return threadFactory.createThreadWrapper(id);
a61af66fc99e Initial load
duke
parents:
diff changeset
377 }
a61af66fc99e Initial load
duke
parents:
diff changeset
378
a61af66fc99e Initial load
duke
parents:
diff changeset
379 public MachineDescription getMachineDescription() throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
380 return machDesc;
a61af66fc99e Initial load
duke
parents:
diff changeset
381 }
a61af66fc99e Initial load
duke
parents:
diff changeset
382
a61af66fc99e Initial load
duke
parents:
diff changeset
383 /** This reads bytes from the remote process. */
a61af66fc99e Initial load
duke
parents:
diff changeset
384 public ReadResult readBytesFromProcess(long address, long numBytes) {
a61af66fc99e Initial load
duke
parents:
diff changeset
385 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
386 return remoteDebugger.readBytesFromProcess(address, numBytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
387 }
a61af66fc99e Initial load
duke
parents:
diff changeset
388 catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
389 throw new DebuggerException(e);
a61af66fc99e Initial load
duke
parents:
diff changeset
390 }
a61af66fc99e Initial load
duke
parents:
diff changeset
391 }
a61af66fc99e Initial load
duke
parents:
diff changeset
392
a61af66fc99e Initial load
duke
parents:
diff changeset
393 public void writeBytesToProcess(long a, long b, byte[] c) {
a61af66fc99e Initial load
duke
parents:
diff changeset
394 throw new DebuggerException("Unimplemented!");
a61af66fc99e Initial load
duke
parents:
diff changeset
395 }
a61af66fc99e Initial load
duke
parents:
diff changeset
396 }