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

7197424: update copyright year to match last edit in jdk8 hotspot repository Summary: Update copyright year to 2012 for relevant files Reviewed-by: dholmes, coleenp
author mikael
date Tue, 09 Oct 2012 10:09:34 -0700
parents a9fed06c01d2
children 8e47bac5643a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
6641
a9fed06c01d2 7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents: 6073
diff changeset
2 * Copyright (c) 2002, 2012, 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: 844
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 844
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: 844
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.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.*;
6641
a9fed06c01d2 7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents: 6073
diff changeset
29 import java.lang.reflect.*;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
30
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.cdbg.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
33 import sun.jvm.hotspot.debugger.remote.sparc.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
34 import sun.jvm.hotspot.debugger.remote.x86.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
35 import sun.jvm.hotspot.debugger.remote.amd64.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
36
a61af66fc99e Initial load
duke
parents:
diff changeset
37 /** An implementation of Debugger which wraps a
a61af66fc99e Initial load
duke
parents:
diff changeset
38 RemoteDebugger, providing remote debugging via RMI.
a61af66fc99e Initial load
duke
parents:
diff changeset
39 This implementation provides caching of the remote process's
a61af66fc99e Initial load
duke
parents:
diff changeset
40 address space on the local machine where the user interface is
a61af66fc99e Initial load
duke
parents:
diff changeset
41 running. */
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43 public class RemoteDebuggerClient extends DebuggerBase implements JVMDebugger {
a61af66fc99e Initial load
duke
parents:
diff changeset
44 private RemoteDebugger remoteDebugger;
a61af66fc99e Initial load
duke
parents:
diff changeset
45 private RemoteThreadFactory threadFactory;
a61af66fc99e Initial load
duke
parents:
diff changeset
46 private boolean unalignedAccessesOkay = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
47 private static final int cacheSize = 16 * 1024 * 1024; // 16 MB
a61af66fc99e Initial load
duke
parents:
diff changeset
48
a61af66fc99e Initial load
duke
parents:
diff changeset
49 public RemoteDebuggerClient(RemoteDebugger remoteDebugger) throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
50 super();
a61af66fc99e Initial load
duke
parents:
diff changeset
51 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
52 this.remoteDebugger = remoteDebugger;
a61af66fc99e Initial load
duke
parents:
diff changeset
53 machDesc = remoteDebugger.getMachineDescription();
a61af66fc99e Initial load
duke
parents:
diff changeset
54 utils = new DebuggerUtilities(machDesc.getAddressSize(), machDesc.isBigEndian());
a61af66fc99e Initial load
duke
parents:
diff changeset
55 int cacheNumPages;
a61af66fc99e Initial load
duke
parents:
diff changeset
56 int cachePageSize;
a61af66fc99e Initial load
duke
parents:
diff changeset
57 String cpu = remoteDebugger.getCPU();
a61af66fc99e Initial load
duke
parents:
diff changeset
58 // page size. (FIXME: should pick this up from the remoteDebugger.)
a61af66fc99e Initial load
duke
parents:
diff changeset
59 if (cpu.equals("sparc")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
60 threadFactory = new RemoteSPARCThreadFactory(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
61 cachePageSize = 8192;
a61af66fc99e Initial load
duke
parents:
diff changeset
62 cacheNumPages = parseCacheNumPagesProperty(cacheSize / cachePageSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
63 } else if (cpu.equals("x86")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
64 threadFactory = new RemoteX86ThreadFactory(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
65 cachePageSize = 4096;
a61af66fc99e Initial load
duke
parents:
diff changeset
66 cacheNumPages = parseCacheNumPagesProperty(cacheSize / cachePageSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
67 unalignedAccessesOkay = true;
6073
78d2ae5ab35b 7163117: Agent can't connect to process on Mac OSX
nloodin
parents: 1552
diff changeset
68 } else if (cpu.equals("amd64") || cpu.equals("x86_64")) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
69 threadFactory = new RemoteAMD64ThreadFactory(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
70 cachePageSize = 4096;
a61af66fc99e Initial load
duke
parents:
diff changeset
71 cacheNumPages = parseCacheNumPagesProperty(cacheSize / cachePageSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
72 unalignedAccessesOkay = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
73 } else {
6641
a9fed06c01d2 7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents: 6073
diff changeset
74 try {
a9fed06c01d2 7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents: 6073
diff changeset
75 Class tf = Class.forName("sun.jvm.hotspot.debugger.remote." +
a9fed06c01d2 7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents: 6073
diff changeset
76 cpu.toLowerCase() + ".Remote" + cpu.toUpperCase() +
a9fed06c01d2 7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents: 6073
diff changeset
77 "ThreadFactory");
a9fed06c01d2 7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents: 6073
diff changeset
78 Constructor[] ctf = tf.getConstructors();
a9fed06c01d2 7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents: 6073
diff changeset
79 threadFactory = (RemoteThreadFactory)ctf[0].newInstance(this);
a9fed06c01d2 7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents: 6073
diff changeset
80 } catch (Exception e) {
a9fed06c01d2 7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents: 6073
diff changeset
81 throw new DebuggerException("Thread access for CPU architecture " + cpu + " not yet supported");
a9fed06c01d2 7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents: 6073
diff changeset
82 }
a9fed06c01d2 7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents: 6073
diff changeset
83 cachePageSize = 4096;
a9fed06c01d2 7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents: 6073
diff changeset
84 cacheNumPages = parseCacheNumPagesProperty(cacheSize / cachePageSize);
a9fed06c01d2 7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents: 6073
diff changeset
85 unalignedAccessesOkay = false;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
86 }
a61af66fc99e Initial load
duke
parents:
diff changeset
87
a61af66fc99e Initial load
duke
parents:
diff changeset
88 // Cache portion of the remote process's address space.
a61af66fc99e Initial load
duke
parents:
diff changeset
89 initCache(cachePageSize, cacheNumPages);
a61af66fc99e Initial load
duke
parents:
diff changeset
90
a61af66fc99e Initial load
duke
parents:
diff changeset
91 jbooleanSize = remoteDebugger.getJBooleanSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
92 jbyteSize = remoteDebugger.getJByteSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
93 jcharSize = remoteDebugger.getJCharSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
94 jdoubleSize = remoteDebugger.getJDoubleSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
95 jfloatSize = remoteDebugger.getJFloatSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
96 jintSize = remoteDebugger.getJIntSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
97 jlongSize = remoteDebugger.getJLongSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
98 jshortSize = remoteDebugger.getJShortSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
99 javaPrimitiveTypesConfigured = true;
642
660978a2a31a 6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents: 196
diff changeset
100 narrowOopBase = remoteDebugger.getNarrowOopBase();
660978a2a31a 6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents: 196
diff changeset
101 narrowOopShift = remoteDebugger.getNarrowOopShift();
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
102 heapOopSize = remoteDebugger.getHeapOopSize();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
103 }
a61af66fc99e Initial load
duke
parents:
diff changeset
104 catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
105 throw new DebuggerException(e);
a61af66fc99e Initial load
duke
parents:
diff changeset
106 }
a61af66fc99e Initial load
duke
parents:
diff changeset
107 }
a61af66fc99e Initial load
duke
parents:
diff changeset
108
a61af66fc99e Initial load
duke
parents:
diff changeset
109 public long[] getThreadIntegerRegisterSet(Address addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
110 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
111 return remoteDebugger.getThreadIntegerRegisterSet(getAddressValue(addr), true);
a61af66fc99e Initial load
duke
parents:
diff changeset
112 }
a61af66fc99e Initial load
duke
parents:
diff changeset
113 catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
114 throw new DebuggerException(e);
a61af66fc99e Initial load
duke
parents:
diff changeset
115 }
a61af66fc99e Initial load
duke
parents:
diff changeset
116 }
a61af66fc99e Initial load
duke
parents:
diff changeset
117
a61af66fc99e Initial load
duke
parents:
diff changeset
118 public long[] getThreadIntegerRegisterSet(long id) {
a61af66fc99e Initial load
duke
parents:
diff changeset
119 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
120 return remoteDebugger.getThreadIntegerRegisterSet(id, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
121 }
a61af66fc99e Initial load
duke
parents:
diff changeset
122 catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
123 throw new DebuggerException(e);
a61af66fc99e Initial load
duke
parents:
diff changeset
124 }
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 boolean hasProcessList() 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 should already be attached) */
a61af66fc99e Initial load
duke
parents:
diff changeset
133 public List getProcessList() throws DebuggerException {
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 /** Unimplemented in this class (remote remoteDebugger should already be attached) */
a61af66fc99e Initial load
duke
parents:
diff changeset
138 public void attach(int processID) throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
139 throw new DebuggerException("Should not be called on RemoteDebuggerClient");
a61af66fc99e Initial load
duke
parents:
diff changeset
140 }
a61af66fc99e Initial load
duke
parents:
diff changeset
141
a61af66fc99e Initial load
duke
parents:
diff changeset
142 /** Unimplemented in this class (remote remoteDebugger should already be attached) */
a61af66fc99e Initial load
duke
parents:
diff changeset
143 public void attach(String executableName, String coreFileName) throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
144 throw new DebuggerException("Should not be called on RemoteDebuggerClient");
a61af66fc99e Initial load
duke
parents:
diff changeset
145 }
a61af66fc99e Initial load
duke
parents:
diff changeset
146
a61af66fc99e Initial load
duke
parents:
diff changeset
147 /** Unimplemented in this class (remote remoteDebugger can not be detached) */
a61af66fc99e Initial load
duke
parents:
diff changeset
148 public boolean detach() {
a61af66fc99e Initial load
duke
parents:
diff changeset
149 throw new DebuggerException("Should not be called on RemoteDebuggerClient");
a61af66fc99e Initial load
duke
parents:
diff changeset
150 }
a61af66fc99e Initial load
duke
parents:
diff changeset
151
a61af66fc99e Initial load
duke
parents:
diff changeset
152 public Address parseAddress(String addressString) throws NumberFormatException {
a61af66fc99e Initial load
duke
parents:
diff changeset
153 long addr = utils.scanAddress(addressString);
a61af66fc99e Initial load
duke
parents:
diff changeset
154 if (addr == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
155 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
156 }
a61af66fc99e Initial load
duke
parents:
diff changeset
157 return new RemoteAddress(this, addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
158 }
a61af66fc99e Initial load
duke
parents:
diff changeset
159
a61af66fc99e Initial load
duke
parents:
diff changeset
160 public String getOS() throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
161 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
162 return remoteDebugger.getOS();
a61af66fc99e Initial load
duke
parents:
diff changeset
163 }
a61af66fc99e Initial load
duke
parents:
diff changeset
164 catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
165 throw new DebuggerException(e);
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 public String getCPU() {
a61af66fc99e Initial load
duke
parents:
diff changeset
170 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
171 return remoteDebugger.getCPU();
a61af66fc99e Initial load
duke
parents:
diff changeset
172 }
a61af66fc99e Initial load
duke
parents:
diff changeset
173 catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
174 throw new DebuggerException(e);
a61af66fc99e Initial load
duke
parents:
diff changeset
175 }
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 boolean hasConsole() throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
179 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
180 return remoteDebugger.hasConsole();
a61af66fc99e Initial load
duke
parents:
diff changeset
181 } catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
182 throw new DebuggerException(e);
a61af66fc99e Initial load
duke
parents:
diff changeset
183 }
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 String consoleExecuteCommand(String cmd) throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
187 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
188 return remoteDebugger.consoleExecuteCommand(cmd);
a61af66fc99e Initial load
duke
parents:
diff changeset
189 }
a61af66fc99e Initial load
duke
parents:
diff changeset
190 catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
191 throw new DebuggerException(e);
a61af66fc99e Initial load
duke
parents:
diff changeset
192 }
a61af66fc99e Initial load
duke
parents:
diff changeset
193 }
a61af66fc99e Initial load
duke
parents:
diff changeset
194
a61af66fc99e Initial load
duke
parents:
diff changeset
195 public String getConsolePrompt() throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
196 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
197 return remoteDebugger.getConsolePrompt();
a61af66fc99e Initial load
duke
parents:
diff changeset
198 } catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
199 throw new DebuggerException(e);
a61af66fc99e Initial load
duke
parents:
diff changeset
200 }
a61af66fc99e Initial load
duke
parents:
diff changeset
201 }
a61af66fc99e Initial load
duke
parents:
diff changeset
202
a61af66fc99e Initial load
duke
parents:
diff changeset
203 public CDebugger getCDebugger() throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
204 return null;
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 // Implementation of SymbolLookup interface
a61af66fc99e Initial load
duke
parents:
diff changeset
209
a61af66fc99e Initial load
duke
parents:
diff changeset
210 public Address lookup(String objectName, String symbol) {
a61af66fc99e Initial load
duke
parents:
diff changeset
211 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
212 long addr = remoteDebugger.lookupInProcess(objectName, symbol);
a61af66fc99e Initial load
duke
parents:
diff changeset
213 if (addr == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
214 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
215 }
a61af66fc99e Initial load
duke
parents:
diff changeset
216 return new RemoteAddress(this, addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
217 }
a61af66fc99e Initial load
duke
parents:
diff changeset
218 catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
219 throw new DebuggerException(e);
a61af66fc99e Initial load
duke
parents:
diff changeset
220 }
a61af66fc99e Initial load
duke
parents:
diff changeset
221 }
a61af66fc99e Initial load
duke
parents:
diff changeset
222
a61af66fc99e Initial load
duke
parents:
diff changeset
223 public OopHandle lookupOop(String objectName, String symbol) {
a61af66fc99e Initial load
duke
parents:
diff changeset
224 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
225 long addr = remoteDebugger.lookupInProcess(objectName, symbol);
a61af66fc99e Initial load
duke
parents:
diff changeset
226 if (addr == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
227 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
228 }
a61af66fc99e Initial load
duke
parents:
diff changeset
229 return new RemoteOopHandle(this, addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
230 }
a61af66fc99e Initial load
duke
parents:
diff changeset
231 catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
232 throw new DebuggerException(e);
a61af66fc99e Initial load
duke
parents:
diff changeset
233 }
a61af66fc99e Initial load
duke
parents:
diff changeset
234 }
a61af66fc99e Initial load
duke
parents:
diff changeset
235
a61af66fc99e Initial load
duke
parents:
diff changeset
236 /** Need to override this to relax alignment checks on x86. */
a61af66fc99e Initial load
duke
parents:
diff changeset
237 public long readCInteger(long address, long numBytes, boolean isUnsigned)
a61af66fc99e Initial load
duke
parents:
diff changeset
238 throws UnmappedAddressException, UnalignedAddressException {
a61af66fc99e Initial load
duke
parents:
diff changeset
239 if (!unalignedAccessesOkay) {
a61af66fc99e Initial load
duke
parents:
diff changeset
240 utils.checkAlignment(address, numBytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
241 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
242 // Only slightly relaxed semantics -- this is a hack, but is
a61af66fc99e Initial load
duke
parents:
diff changeset
243 // necessary on x86 where it seems the compiler is
a61af66fc99e Initial load
duke
parents:
diff changeset
244 // putting some global 64-bit data on 32-bit boundaries
a61af66fc99e Initial load
duke
parents:
diff changeset
245 if (numBytes == 8) {
a61af66fc99e Initial load
duke
parents:
diff changeset
246 utils.checkAlignment(address, 4);
a61af66fc99e Initial load
duke
parents:
diff changeset
247 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
248 utils.checkAlignment(address, numBytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
249 }
a61af66fc99e Initial load
duke
parents:
diff changeset
250 }
a61af66fc99e Initial load
duke
parents:
diff changeset
251 byte[] data = readBytes(address, numBytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
252 return utils.dataToCInteger(data, isUnsigned);
a61af66fc99e Initial load
duke
parents:
diff changeset
253 }
a61af66fc99e Initial load
duke
parents:
diff changeset
254
a61af66fc99e Initial load
duke
parents:
diff changeset
255 // Overridden from DebuggerBase because we need to relax alignment
a61af66fc99e Initial load
duke
parents:
diff changeset
256 // constraints on x86
a61af66fc99e Initial load
duke
parents:
diff changeset
257 public long readJLong(long address)
a61af66fc99e Initial load
duke
parents:
diff changeset
258 throws UnmappedAddressException, UnalignedAddressException {
a61af66fc99e Initial load
duke
parents:
diff changeset
259 // FIXME: allow this to be configurable. Undesirable to add a
a61af66fc99e Initial load
duke
parents:
diff changeset
260 // dependency on the runtime package here, though, since this
a61af66fc99e Initial load
duke
parents:
diff changeset
261 // package should be strictly underneath it.
a61af66fc99e Initial load
duke
parents:
diff changeset
262 if (unalignedAccessesOkay) {
a61af66fc99e Initial load
duke
parents:
diff changeset
263 utils.checkAlignment(address, jintSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
264 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
265 utils.checkAlignment(address, jlongSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
266 }
a61af66fc99e Initial load
duke
parents:
diff changeset
267 byte[] data = readBytes(address, jlongSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
268 return utils.dataToJLong(data, jlongSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
269 }
a61af66fc99e Initial load
duke
parents:
diff changeset
270
a61af66fc99e Initial load
duke
parents:
diff changeset
271
a61af66fc99e Initial load
duke
parents:
diff changeset
272 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
273 // Implementation of JVMDebugger interface
a61af66fc99e Initial load
duke
parents:
diff changeset
274 //
a61af66fc99e Initial load
duke
parents:
diff changeset
275
a61af66fc99e Initial load
duke
parents:
diff changeset
276 /** Unimplemented in this class (remote remoteDebugger should already be configured) */
a61af66fc99e Initial load
duke
parents:
diff changeset
277 public void configureJavaPrimitiveTypeSizes(long jbooleanSize,
a61af66fc99e Initial load
duke
parents:
diff changeset
278 long jbyteSize,
a61af66fc99e Initial load
duke
parents:
diff changeset
279 long jcharSize,
a61af66fc99e Initial load
duke
parents:
diff changeset
280 long jdoubleSize,
a61af66fc99e Initial load
duke
parents:
diff changeset
281 long jfloatSize,
a61af66fc99e Initial load
duke
parents:
diff changeset
282 long jintSize,
a61af66fc99e Initial load
duke
parents:
diff changeset
283 long jlongSize,
a61af66fc99e Initial load
duke
parents:
diff changeset
284 long jshortSize) {
a61af66fc99e Initial load
duke
parents:
diff changeset
285 throw new DebuggerException("Should not be called on RemoteDebuggerClient");
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 void setMachineDescription(MachineDescription machDesc) {
a61af66fc99e Initial load
duke
parents:
diff changeset
289 throw new DebuggerException("Should not be called on RemoteDebuggerClient");
a61af66fc99e Initial load
duke
parents:
diff changeset
290 }
a61af66fc99e Initial load
duke
parents:
diff changeset
291
a61af66fc99e Initial load
duke
parents:
diff changeset
292 public int getRemoteProcessAddressSize() {
a61af66fc99e Initial load
duke
parents:
diff changeset
293 throw new DebuggerException("Should not be called on RemoteDebuggerClient");
a61af66fc99e Initial load
duke
parents:
diff changeset
294 }
a61af66fc99e Initial load
duke
parents:
diff changeset
295
a61af66fc99e Initial load
duke
parents:
diff changeset
296 public String addressValueToString(long addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
297 return utils.addressValueToString(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
298 }
a61af66fc99e Initial load
duke
parents:
diff changeset
299
a61af66fc99e Initial load
duke
parents:
diff changeset
300 public long getAddressValue(Address addr) throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
301 if (addr == null) return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
302 return ((RemoteAddress) addr).getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
303 }
a61af66fc99e Initial load
duke
parents:
diff changeset
304
a61af66fc99e Initial load
duke
parents:
diff changeset
305 public Address newAddress(long value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
306 if (value == 0) return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
307 return new RemoteAddress(this, value);
a61af66fc99e Initial load
duke
parents:
diff changeset
308 }
a61af66fc99e Initial load
duke
parents:
diff changeset
309
a61af66fc99e Initial load
duke
parents:
diff changeset
310 RemoteAddress readAddress(long address)
a61af66fc99e Initial load
duke
parents:
diff changeset
311 throws UnmappedAddressException, UnalignedAddressException {
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 RemoteAddress(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 RemoteAddress readCompOopAddress(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 {
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 RemoteAddress(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 RemoteOopHandle readOopHandle(long address)
a61af66fc99e Initial load
duke
parents:
diff changeset
323 throws UnmappedAddressException, UnalignedAddressException, NotInHeapException {
a61af66fc99e Initial load
duke
parents:
diff changeset
324 long value = readAddressValue(address);
a61af66fc99e Initial load
duke
parents:
diff changeset
325 return (value == 0 ? null : new RemoteOopHandle(this, value));
a61af66fc99e Initial load
duke
parents:
diff changeset
326 }
a61af66fc99e Initial load
duke
parents:
diff changeset
327
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
328 RemoteOopHandle readCompOopHandle(long address)
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
329 throws UnmappedAddressException, UnalignedAddressException, NotInHeapException {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
330 long value = readCompOopAddressValue(address);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
331 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
332 }
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
333
0
a61af66fc99e Initial load
duke
parents:
diff changeset
334 boolean areThreadsEqual(Address addr1, Address addr2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
335 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
336 return remoteDebugger.areThreadsEqual(getAddressValue(addr1), true,
a61af66fc99e Initial load
duke
parents:
diff changeset
337 getAddressValue(addr2), true);
a61af66fc99e Initial load
duke
parents:
diff changeset
338 } catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
339 }
a61af66fc99e Initial load
duke
parents:
diff changeset
340 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
341 }
a61af66fc99e Initial load
duke
parents:
diff changeset
342
a61af66fc99e Initial load
duke
parents:
diff changeset
343 boolean areThreadsEqual(long id1, long id2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
344 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
345 return remoteDebugger.areThreadsEqual(id1, false, id2, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
346 } catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
347 }
a61af66fc99e Initial load
duke
parents:
diff changeset
348 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
349 }
a61af66fc99e Initial load
duke
parents:
diff changeset
350
a61af66fc99e Initial load
duke
parents:
diff changeset
351 boolean areThreadsEqual(Address addr1, long id2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
352 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
353 return remoteDebugger.areThreadsEqual(getAddressValue(addr1), true, id2, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
354 } catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
355 }
a61af66fc99e Initial load
duke
parents:
diff changeset
356 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
357 }
a61af66fc99e Initial load
duke
parents:
diff changeset
358
a61af66fc99e Initial load
duke
parents:
diff changeset
359 boolean areThreadsEqual(long id1, Address addr2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
360 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
361 return remoteDebugger.areThreadsEqual(id1, false, getAddressValue(addr2), true);
a61af66fc99e Initial load
duke
parents:
diff changeset
362 } catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
363 }
a61af66fc99e Initial load
duke
parents:
diff changeset
364 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
365 }
a61af66fc99e Initial load
duke
parents:
diff changeset
366
a61af66fc99e Initial load
duke
parents:
diff changeset
367 int getThreadHashCode(Address a) {
a61af66fc99e Initial load
duke
parents:
diff changeset
368 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
369 return remoteDebugger.getThreadHashCode(getAddressValue(a), true);
a61af66fc99e Initial load
duke
parents:
diff changeset
370 } catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
371 }
a61af66fc99e Initial load
duke
parents:
diff changeset
372 return a.hashCode();
a61af66fc99e Initial load
duke
parents:
diff changeset
373 }
a61af66fc99e Initial load
duke
parents:
diff changeset
374
a61af66fc99e Initial load
duke
parents:
diff changeset
375 int getThreadHashCode(long id) {
a61af66fc99e Initial load
duke
parents:
diff changeset
376 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
377 return remoteDebugger.getThreadHashCode(id, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
378 } catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
379 }
a61af66fc99e Initial load
duke
parents:
diff changeset
380 return (int) id;
a61af66fc99e Initial load
duke
parents:
diff changeset
381 }
a61af66fc99e Initial load
duke
parents:
diff changeset
382
a61af66fc99e Initial load
duke
parents:
diff changeset
383 public ThreadProxy getThreadForIdentifierAddress(Address addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
384 return threadFactory.createThreadWrapper(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
385 }
a61af66fc99e Initial load
duke
parents:
diff changeset
386
a61af66fc99e Initial load
duke
parents:
diff changeset
387 public ThreadProxy getThreadForThreadId(long id) {
a61af66fc99e Initial load
duke
parents:
diff changeset
388 return threadFactory.createThreadWrapper(id);
a61af66fc99e Initial load
duke
parents:
diff changeset
389 }
a61af66fc99e Initial load
duke
parents:
diff changeset
390
a61af66fc99e Initial load
duke
parents:
diff changeset
391 public MachineDescription getMachineDescription() throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
392 return machDesc;
a61af66fc99e Initial load
duke
parents:
diff changeset
393 }
a61af66fc99e Initial load
duke
parents:
diff changeset
394
a61af66fc99e Initial load
duke
parents:
diff changeset
395 /** This reads bytes from the remote process. */
a61af66fc99e Initial load
duke
parents:
diff changeset
396 public ReadResult readBytesFromProcess(long address, long numBytes) {
a61af66fc99e Initial load
duke
parents:
diff changeset
397 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
398 return remoteDebugger.readBytesFromProcess(address, numBytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
399 }
a61af66fc99e Initial load
duke
parents:
diff changeset
400 catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
401 throw new DebuggerException(e);
a61af66fc99e Initial load
duke
parents:
diff changeset
402 }
a61af66fc99e Initial load
duke
parents:
diff changeset
403 }
a61af66fc99e Initial load
duke
parents:
diff changeset
404
a61af66fc99e Initial load
duke
parents:
diff changeset
405 public void writeBytesToProcess(long a, long b, byte[] c) {
a61af66fc99e Initial load
duke
parents:
diff changeset
406 throw new DebuggerException("Unimplemented!");
a61af66fc99e Initial load
duke
parents:
diff changeset
407 }
a61af66fc99e Initial load
duke
parents:
diff changeset
408 }