annotate agent/src/share/classes/sun/jvm/hotspot/debugger/remote/RemoteDebuggerClient.java @ 17524:89152779163c

Merge with jdk8-b132
author Gilles Duboscq <duboscq@ssw.jku.at>
date Wed, 15 Oct 2014 11:59:32 +0200
parents 8e47bac5643a
children
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();
6848
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6641
diff changeset
102 narrowKlassBase = remoteDebugger.getNarrowKlassBase();
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6641
diff changeset
103 narrowKlassShift = remoteDebugger.getNarrowKlassShift();
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
104 heapOopSize = remoteDebugger.getHeapOopSize();
6848
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6641
diff changeset
105 klassPtrSize = remoteDebugger.getKlassPtrSize();
0
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 public long[] getThreadIntegerRegisterSet(Address addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
113 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
114 return remoteDebugger.getThreadIntegerRegisterSet(getAddressValue(addr), true);
a61af66fc99e Initial load
duke
parents:
diff changeset
115 }
a61af66fc99e Initial load
duke
parents:
diff changeset
116 catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
117 throw new DebuggerException(e);
a61af66fc99e Initial load
duke
parents:
diff changeset
118 }
a61af66fc99e Initial load
duke
parents:
diff changeset
119 }
a61af66fc99e Initial load
duke
parents:
diff changeset
120
a61af66fc99e Initial load
duke
parents:
diff changeset
121 public long[] getThreadIntegerRegisterSet(long id) {
a61af66fc99e Initial load
duke
parents:
diff changeset
122 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
123 return remoteDebugger.getThreadIntegerRegisterSet(id, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
124 }
a61af66fc99e Initial load
duke
parents:
diff changeset
125 catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
126 throw new DebuggerException(e);
a61af66fc99e Initial load
duke
parents:
diff changeset
127 }
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 boolean hasProcessList() 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 should already be attached) */
a61af66fc99e Initial load
duke
parents:
diff changeset
136 public List getProcessList() throws DebuggerException {
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 /** Unimplemented in this class (remote remoteDebugger should already be attached) */
a61af66fc99e Initial load
duke
parents:
diff changeset
141 public void attach(int processID) throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
142 throw new DebuggerException("Should not be called on RemoteDebuggerClient");
a61af66fc99e Initial load
duke
parents:
diff changeset
143 }
a61af66fc99e Initial load
duke
parents:
diff changeset
144
a61af66fc99e Initial load
duke
parents:
diff changeset
145 /** Unimplemented in this class (remote remoteDebugger should already be attached) */
a61af66fc99e Initial load
duke
parents:
diff changeset
146 public void attach(String executableName, String coreFileName) throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
147 throw new DebuggerException("Should not be called on RemoteDebuggerClient");
a61af66fc99e Initial load
duke
parents:
diff changeset
148 }
a61af66fc99e Initial load
duke
parents:
diff changeset
149
a61af66fc99e Initial load
duke
parents:
diff changeset
150 /** Unimplemented in this class (remote remoteDebugger can not be detached) */
a61af66fc99e Initial load
duke
parents:
diff changeset
151 public boolean detach() {
a61af66fc99e Initial load
duke
parents:
diff changeset
152 throw new DebuggerException("Should not be called on RemoteDebuggerClient");
a61af66fc99e Initial load
duke
parents:
diff changeset
153 }
a61af66fc99e Initial load
duke
parents:
diff changeset
154
a61af66fc99e Initial load
duke
parents:
diff changeset
155 public Address parseAddress(String addressString) throws NumberFormatException {
a61af66fc99e Initial load
duke
parents:
diff changeset
156 long addr = utils.scanAddress(addressString);
a61af66fc99e Initial load
duke
parents:
diff changeset
157 if (addr == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
158 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
159 }
a61af66fc99e Initial load
duke
parents:
diff changeset
160 return new RemoteAddress(this, addr);
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 String getOS() throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
164 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
165 return remoteDebugger.getOS();
a61af66fc99e Initial load
duke
parents:
diff changeset
166 }
a61af66fc99e Initial load
duke
parents:
diff changeset
167 catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
168 throw new DebuggerException(e);
a61af66fc99e Initial load
duke
parents:
diff changeset
169 }
a61af66fc99e Initial load
duke
parents:
diff changeset
170 }
a61af66fc99e Initial load
duke
parents:
diff changeset
171
a61af66fc99e Initial load
duke
parents:
diff changeset
172 public String getCPU() {
a61af66fc99e Initial load
duke
parents:
diff changeset
173 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
174 return remoteDebugger.getCPU();
a61af66fc99e Initial load
duke
parents:
diff changeset
175 }
a61af66fc99e Initial load
duke
parents:
diff changeset
176 catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
177 throw new DebuggerException(e);
a61af66fc99e Initial load
duke
parents:
diff changeset
178 }
a61af66fc99e Initial load
duke
parents:
diff changeset
179 }
a61af66fc99e Initial load
duke
parents:
diff changeset
180
a61af66fc99e Initial load
duke
parents:
diff changeset
181 public boolean hasConsole() throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
182 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
183 return remoteDebugger.hasConsole();
a61af66fc99e Initial load
duke
parents:
diff changeset
184 } catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
185 throw new DebuggerException(e);
a61af66fc99e Initial load
duke
parents:
diff changeset
186 }
a61af66fc99e Initial load
duke
parents:
diff changeset
187 }
a61af66fc99e Initial load
duke
parents:
diff changeset
188
a61af66fc99e Initial load
duke
parents:
diff changeset
189 public String consoleExecuteCommand(String cmd) throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
190 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
191 return remoteDebugger.consoleExecuteCommand(cmd);
a61af66fc99e Initial load
duke
parents:
diff changeset
192 }
a61af66fc99e Initial load
duke
parents:
diff changeset
193 catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
194 throw new DebuggerException(e);
a61af66fc99e Initial load
duke
parents:
diff changeset
195 }
a61af66fc99e Initial load
duke
parents:
diff changeset
196 }
a61af66fc99e Initial load
duke
parents:
diff changeset
197
a61af66fc99e Initial load
duke
parents:
diff changeset
198 public String getConsolePrompt() throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
199 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
200 return remoteDebugger.getConsolePrompt();
a61af66fc99e Initial load
duke
parents:
diff changeset
201 } catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
202 throw new DebuggerException(e);
a61af66fc99e Initial load
duke
parents:
diff changeset
203 }
a61af66fc99e Initial load
duke
parents:
diff changeset
204 }
a61af66fc99e Initial load
duke
parents:
diff changeset
205
a61af66fc99e Initial load
duke
parents:
diff changeset
206 public CDebugger getCDebugger() throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
207 return null;
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 // Implementation of SymbolLookup interface
a61af66fc99e Initial load
duke
parents:
diff changeset
212
a61af66fc99e Initial load
duke
parents:
diff changeset
213 public Address lookup(String objectName, String symbol) {
a61af66fc99e Initial load
duke
parents:
diff changeset
214 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
215 long addr = remoteDebugger.lookupInProcess(objectName, symbol);
a61af66fc99e Initial load
duke
parents:
diff changeset
216 if (addr == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
217 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
218 }
a61af66fc99e Initial load
duke
parents:
diff changeset
219 return new RemoteAddress(this, addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
220 }
a61af66fc99e Initial load
duke
parents:
diff changeset
221 catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
222 throw new DebuggerException(e);
a61af66fc99e Initial load
duke
parents:
diff changeset
223 }
a61af66fc99e Initial load
duke
parents:
diff changeset
224 }
a61af66fc99e Initial load
duke
parents:
diff changeset
225
a61af66fc99e Initial load
duke
parents:
diff changeset
226 public OopHandle lookupOop(String objectName, String symbol) {
a61af66fc99e Initial load
duke
parents:
diff changeset
227 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
228 long addr = remoteDebugger.lookupInProcess(objectName, symbol);
a61af66fc99e Initial load
duke
parents:
diff changeset
229 if (addr == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
230 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
231 }
a61af66fc99e Initial load
duke
parents:
diff changeset
232 return new RemoteOopHandle(this, addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
233 }
a61af66fc99e Initial load
duke
parents:
diff changeset
234 catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
235 throw new DebuggerException(e);
a61af66fc99e Initial load
duke
parents:
diff changeset
236 }
a61af66fc99e Initial load
duke
parents:
diff changeset
237 }
a61af66fc99e Initial load
duke
parents:
diff changeset
238
a61af66fc99e Initial load
duke
parents:
diff changeset
239 /** Need to override this to relax alignment checks on x86. */
a61af66fc99e Initial load
duke
parents:
diff changeset
240 public long readCInteger(long address, long numBytes, boolean isUnsigned)
a61af66fc99e Initial load
duke
parents:
diff changeset
241 throws UnmappedAddressException, UnalignedAddressException {
a61af66fc99e Initial load
duke
parents:
diff changeset
242 if (!unalignedAccessesOkay) {
a61af66fc99e Initial load
duke
parents:
diff changeset
243 utils.checkAlignment(address, numBytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
244 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
245 // Only slightly relaxed semantics -- this is a hack, but is
a61af66fc99e Initial load
duke
parents:
diff changeset
246 // necessary on x86 where it seems the compiler is
a61af66fc99e Initial load
duke
parents:
diff changeset
247 // putting some global 64-bit data on 32-bit boundaries
a61af66fc99e Initial load
duke
parents:
diff changeset
248 if (numBytes == 8) {
a61af66fc99e Initial load
duke
parents:
diff changeset
249 utils.checkAlignment(address, 4);
a61af66fc99e Initial load
duke
parents:
diff changeset
250 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
251 utils.checkAlignment(address, numBytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
252 }
a61af66fc99e Initial load
duke
parents:
diff changeset
253 }
a61af66fc99e Initial load
duke
parents:
diff changeset
254 byte[] data = readBytes(address, numBytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
255 return utils.dataToCInteger(data, isUnsigned);
a61af66fc99e Initial load
duke
parents:
diff changeset
256 }
a61af66fc99e Initial load
duke
parents:
diff changeset
257
a61af66fc99e Initial load
duke
parents:
diff changeset
258 // Overridden from DebuggerBase because we need to relax alignment
a61af66fc99e Initial load
duke
parents:
diff changeset
259 // constraints on x86
a61af66fc99e Initial load
duke
parents:
diff changeset
260 public long readJLong(long address)
a61af66fc99e Initial load
duke
parents:
diff changeset
261 throws UnmappedAddressException, UnalignedAddressException {
a61af66fc99e Initial load
duke
parents:
diff changeset
262 // FIXME: allow this to be configurable. Undesirable to add a
a61af66fc99e Initial load
duke
parents:
diff changeset
263 // dependency on the runtime package here, though, since this
a61af66fc99e Initial load
duke
parents:
diff changeset
264 // package should be strictly underneath it.
a61af66fc99e Initial load
duke
parents:
diff changeset
265 if (unalignedAccessesOkay) {
a61af66fc99e Initial load
duke
parents:
diff changeset
266 utils.checkAlignment(address, jintSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
267 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
268 utils.checkAlignment(address, jlongSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
269 }
a61af66fc99e Initial load
duke
parents:
diff changeset
270 byte[] data = readBytes(address, jlongSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
271 return utils.dataToJLong(data, jlongSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
272 }
a61af66fc99e Initial load
duke
parents:
diff changeset
273
a61af66fc99e Initial load
duke
parents:
diff changeset
274
a61af66fc99e Initial load
duke
parents:
diff changeset
275 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
276 // Implementation of JVMDebugger interface
a61af66fc99e Initial load
duke
parents:
diff changeset
277 //
a61af66fc99e Initial load
duke
parents:
diff changeset
278
a61af66fc99e Initial load
duke
parents:
diff changeset
279 /** Unimplemented in this class (remote remoteDebugger should already be configured) */
a61af66fc99e Initial load
duke
parents:
diff changeset
280 public void configureJavaPrimitiveTypeSizes(long jbooleanSize,
a61af66fc99e Initial load
duke
parents:
diff changeset
281 long jbyteSize,
a61af66fc99e Initial load
duke
parents:
diff changeset
282 long jcharSize,
a61af66fc99e Initial load
duke
parents:
diff changeset
283 long jdoubleSize,
a61af66fc99e Initial load
duke
parents:
diff changeset
284 long jfloatSize,
a61af66fc99e Initial load
duke
parents:
diff changeset
285 long jintSize,
a61af66fc99e Initial load
duke
parents:
diff changeset
286 long jlongSize,
a61af66fc99e Initial load
duke
parents:
diff changeset
287 long jshortSize) {
a61af66fc99e Initial load
duke
parents:
diff changeset
288 throw new DebuggerException("Should not be called on RemoteDebuggerClient");
a61af66fc99e Initial load
duke
parents:
diff changeset
289 }
a61af66fc99e Initial load
duke
parents:
diff changeset
290
a61af66fc99e Initial load
duke
parents:
diff changeset
291 public void setMachineDescription(MachineDescription machDesc) {
a61af66fc99e Initial load
duke
parents:
diff changeset
292 throw new DebuggerException("Should not be called on RemoteDebuggerClient");
a61af66fc99e Initial load
duke
parents:
diff changeset
293 }
a61af66fc99e Initial load
duke
parents:
diff changeset
294
a61af66fc99e Initial load
duke
parents:
diff changeset
295 public int getRemoteProcessAddressSize() {
a61af66fc99e Initial load
duke
parents:
diff changeset
296 throw new DebuggerException("Should not be called on RemoteDebuggerClient");
a61af66fc99e Initial load
duke
parents:
diff changeset
297 }
a61af66fc99e Initial load
duke
parents:
diff changeset
298
a61af66fc99e Initial load
duke
parents:
diff changeset
299 public String addressValueToString(long addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
300 return utils.addressValueToString(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
301 }
a61af66fc99e Initial load
duke
parents:
diff changeset
302
a61af66fc99e Initial load
duke
parents:
diff changeset
303 public long getAddressValue(Address addr) throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
304 if (addr == null) return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
305 return ((RemoteAddress) addr).getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
306 }
a61af66fc99e Initial load
duke
parents:
diff changeset
307
a61af66fc99e Initial load
duke
parents:
diff changeset
308 public Address newAddress(long value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
309 if (value == 0) return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
310 return new RemoteAddress(this, value);
a61af66fc99e Initial load
duke
parents:
diff changeset
311 }
a61af66fc99e Initial load
duke
parents:
diff changeset
312
a61af66fc99e Initial load
duke
parents:
diff changeset
313 RemoteAddress readAddress(long address)
a61af66fc99e Initial load
duke
parents:
diff changeset
314 throws UnmappedAddressException, UnalignedAddressException {
a61af66fc99e Initial load
duke
parents:
diff changeset
315 long value = readAddressValue(address);
a61af66fc99e Initial load
duke
parents:
diff changeset
316 return (value == 0 ? null : new RemoteAddress(this, value));
a61af66fc99e Initial load
duke
parents:
diff changeset
317 }
a61af66fc99e Initial load
duke
parents:
diff changeset
318
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
319 RemoteAddress readCompOopAddress(long address)
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
320 throws UnmappedAddressException, UnalignedAddressException {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
321 long value = readCompOopAddressValue(address);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
322 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
323 }
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
324
6848
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6641
diff changeset
325 RemoteAddress readCompKlassAddress(long address)
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6641
diff changeset
326 throws UnmappedAddressException, UnalignedAddressException {
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6641
diff changeset
327 long value = readCompKlassAddressValue(address);
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6641
diff changeset
328 return (value == 0 ? null : new RemoteAddress(this, value));
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6641
diff changeset
329 }
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6641
diff changeset
330
0
a61af66fc99e Initial load
duke
parents:
diff changeset
331 RemoteOopHandle readOopHandle(long address)
a61af66fc99e Initial load
duke
parents:
diff changeset
332 throws UnmappedAddressException, UnalignedAddressException, NotInHeapException {
a61af66fc99e Initial load
duke
parents:
diff changeset
333 long value = readAddressValue(address);
a61af66fc99e Initial load
duke
parents:
diff changeset
334 return (value == 0 ? null : new RemoteOopHandle(this, value));
a61af66fc99e Initial load
duke
parents:
diff changeset
335 }
a61af66fc99e Initial load
duke
parents:
diff changeset
336
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
337 RemoteOopHandle readCompOopHandle(long address)
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
338 throws UnmappedAddressException, UnalignedAddressException, NotInHeapException {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
339 long value = readCompOopAddressValue(address);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
340 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
341 }
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
342
0
a61af66fc99e Initial load
duke
parents:
diff changeset
343 boolean areThreadsEqual(Address addr1, Address addr2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
344 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
345 return remoteDebugger.areThreadsEqual(getAddressValue(addr1), true,
a61af66fc99e Initial load
duke
parents:
diff changeset
346 getAddressValue(addr2), true);
a61af66fc99e Initial load
duke
parents:
diff changeset
347 } catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
348 }
a61af66fc99e Initial load
duke
parents:
diff changeset
349 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
350 }
a61af66fc99e Initial load
duke
parents:
diff changeset
351
a61af66fc99e Initial load
duke
parents:
diff changeset
352 boolean areThreadsEqual(long id1, long id2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
353 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
354 return remoteDebugger.areThreadsEqual(id1, false, id2, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
355 } catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
356 }
a61af66fc99e Initial load
duke
parents:
diff changeset
357 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
358 }
a61af66fc99e Initial load
duke
parents:
diff changeset
359
a61af66fc99e Initial load
duke
parents:
diff changeset
360 boolean areThreadsEqual(Address addr1, long id2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
361 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
362 return remoteDebugger.areThreadsEqual(getAddressValue(addr1), true, id2, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
363 } catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
364 }
a61af66fc99e Initial load
duke
parents:
diff changeset
365 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
366 }
a61af66fc99e Initial load
duke
parents:
diff changeset
367
a61af66fc99e Initial load
duke
parents:
diff changeset
368 boolean areThreadsEqual(long id1, Address addr2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
369 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
370 return remoteDebugger.areThreadsEqual(id1, false, getAddressValue(addr2), true);
a61af66fc99e Initial load
duke
parents:
diff changeset
371 } catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
372 }
a61af66fc99e Initial load
duke
parents:
diff changeset
373 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
374 }
a61af66fc99e Initial load
duke
parents:
diff changeset
375
a61af66fc99e Initial load
duke
parents:
diff changeset
376 int getThreadHashCode(Address a) {
a61af66fc99e Initial load
duke
parents:
diff changeset
377 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
378 return remoteDebugger.getThreadHashCode(getAddressValue(a), true);
a61af66fc99e Initial load
duke
parents:
diff changeset
379 } catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
380 }
a61af66fc99e Initial load
duke
parents:
diff changeset
381 return a.hashCode();
a61af66fc99e Initial load
duke
parents:
diff changeset
382 }
a61af66fc99e Initial load
duke
parents:
diff changeset
383
a61af66fc99e Initial load
duke
parents:
diff changeset
384 int getThreadHashCode(long id) {
a61af66fc99e Initial load
duke
parents:
diff changeset
385 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
386 return remoteDebugger.getThreadHashCode(id, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
387 } catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
388 }
a61af66fc99e Initial load
duke
parents:
diff changeset
389 return (int) id;
a61af66fc99e Initial load
duke
parents:
diff changeset
390 }
a61af66fc99e Initial load
duke
parents:
diff changeset
391
a61af66fc99e Initial load
duke
parents:
diff changeset
392 public ThreadProxy getThreadForIdentifierAddress(Address addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
393 return threadFactory.createThreadWrapper(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
394 }
a61af66fc99e Initial load
duke
parents:
diff changeset
395
a61af66fc99e Initial load
duke
parents:
diff changeset
396 public ThreadProxy getThreadForThreadId(long id) {
a61af66fc99e Initial load
duke
parents:
diff changeset
397 return threadFactory.createThreadWrapper(id);
a61af66fc99e Initial load
duke
parents:
diff changeset
398 }
a61af66fc99e Initial load
duke
parents:
diff changeset
399
a61af66fc99e Initial load
duke
parents:
diff changeset
400 public MachineDescription getMachineDescription() throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
401 return machDesc;
a61af66fc99e Initial load
duke
parents:
diff changeset
402 }
a61af66fc99e Initial load
duke
parents:
diff changeset
403
a61af66fc99e Initial load
duke
parents:
diff changeset
404 /** This reads bytes from the remote process. */
a61af66fc99e Initial load
duke
parents:
diff changeset
405 public ReadResult readBytesFromProcess(long address, long numBytes) {
a61af66fc99e Initial load
duke
parents:
diff changeset
406 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
407 return remoteDebugger.readBytesFromProcess(address, numBytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
408 }
a61af66fc99e Initial load
duke
parents:
diff changeset
409 catch (RemoteException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
410 throw new DebuggerException(e);
a61af66fc99e Initial load
duke
parents:
diff changeset
411 }
a61af66fc99e Initial load
duke
parents:
diff changeset
412 }
a61af66fc99e Initial load
duke
parents:
diff changeset
413
a61af66fc99e Initial load
duke
parents:
diff changeset
414 public void writeBytesToProcess(long a, long b, byte[] c) {
a61af66fc99e Initial load
duke
parents:
diff changeset
415 throw new DebuggerException("Unimplemented!");
a61af66fc99e Initial load
duke
parents:
diff changeset
416 }
a61af66fc99e Initial load
duke
parents:
diff changeset
417 }