Mercurial > hg > truffle
annotate agent/src/share/classes/sun/jvm/hotspot/debugger/remote/RemoteAddress.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 | c18cbe5936b8 |
children | 8e47bac5643a |
rev | line source |
---|---|
0 | 1 /* |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
196
diff
changeset
|
2 * Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
196
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
196
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:
196
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
25 package sun.jvm.hotspot.debugger.remote; | |
26 | |
27 import sun.jvm.hotspot.debugger.*; | |
28 | |
29 class RemoteAddress implements Address { | |
30 protected RemoteDebuggerClient debugger; | |
31 protected long addr; | |
32 | |
33 RemoteAddress(RemoteDebuggerClient debugger, long addr) { | |
34 this.debugger = debugger; | |
35 this.addr = addr; | |
36 } | |
37 | |
38 // | |
39 // Basic Java routines | |
40 // | |
41 | |
42 public boolean equals(Object arg) { | |
43 if (arg == null) { | |
44 return false; | |
45 } | |
46 | |
47 if (!(arg instanceof RemoteAddress)) { | |
48 return false; | |
49 } | |
50 | |
51 return (addr == ((RemoteAddress) arg).addr); | |
52 } | |
53 | |
54 public int hashCode() { | |
55 // FIXME: suggestions on a better hash code? | |
56 return (int) addr; | |
57 } | |
58 | |
59 public String toString() { | |
60 return debugger.addressValueToString(addr); | |
61 } | |
62 | |
63 // | |
64 // C/C++-related routines | |
65 // | |
66 | |
67 public long getCIntegerAt(long offset, long numBytes, boolean isUnsigned) throws UnalignedAddressException, UnmappedAddressException { | |
68 return debugger.readCInteger(addr + offset, numBytes, isUnsigned); | |
69 } | |
70 | |
71 public Address getAddressAt(long offset) throws UnalignedAddressException, UnmappedAddressException { | |
72 return debugger.readAddress(addr + offset); | |
73 } | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
74 public Address getCompOopAddressAt(long offset) throws UnalignedAddressException, UnmappedAddressException { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
75 return debugger.readCompOopAddress(addr + offset); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
76 } |
0 | 77 |
78 // | |
79 // Java-related routines | |
80 // | |
81 | |
82 public boolean getJBooleanAt(long offset) throws UnalignedAddressException, UnmappedAddressException { | |
83 return debugger.readJBoolean(addr + offset); | |
84 } | |
85 | |
86 public byte getJByteAt(long offset) throws UnalignedAddressException, UnmappedAddressException { | |
87 return debugger.readJByte(addr + offset); | |
88 } | |
89 | |
90 public char getJCharAt(long offset) throws UnalignedAddressException, UnmappedAddressException { | |
91 return debugger.readJChar(addr + offset); | |
92 } | |
93 | |
94 public double getJDoubleAt(long offset) throws UnalignedAddressException, UnmappedAddressException { | |
95 return debugger.readJDouble(addr + offset); | |
96 } | |
97 | |
98 public float getJFloatAt(long offset) throws UnalignedAddressException, UnmappedAddressException { | |
99 return debugger.readJFloat(addr + offset); | |
100 } | |
101 | |
102 public int getJIntAt(long offset) throws UnalignedAddressException, UnmappedAddressException { | |
103 return debugger.readJInt(addr + offset); | |
104 } | |
105 | |
106 public long getJLongAt(long offset) throws UnalignedAddressException, UnmappedAddressException { | |
107 return debugger.readJLong(addr + offset); | |
108 } | |
109 | |
110 public short getJShortAt(long offset) throws UnalignedAddressException, UnmappedAddressException { | |
111 return debugger.readJShort(addr + offset); | |
112 } | |
113 | |
114 public OopHandle getOopHandleAt(long offset) | |
115 throws UnalignedAddressException, UnmappedAddressException, NotInHeapException { | |
116 return debugger.readOopHandle(addr + offset); | |
117 } | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
118 public OopHandle getCompOopHandleAt(long offset) |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
119 throws UnalignedAddressException, UnmappedAddressException, NotInHeapException { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
120 return debugger.readCompOopHandle(addr + offset); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
121 } |
0 | 122 |
123 // Mutators -- not implemented for now (FIXME) | |
124 public void setCIntegerAt(long offset, long numBytes, long value) { | |
125 throw new DebuggerException("Unimplemented"); | |
126 } | |
127 public void setAddressAt(long offset, Address value) { | |
128 throw new DebuggerException("Unimplemented"); | |
129 } | |
130 public void setJBooleanAt (long offset, boolean value) | |
131 throws UnmappedAddressException, UnalignedAddressException { | |
132 throw new DebuggerException("Unimplemented"); | |
133 } | |
134 public void setJByteAt (long offset, byte value) | |
135 throws UnmappedAddressException, UnalignedAddressException { | |
136 throw new DebuggerException("Unimplemented"); | |
137 } | |
138 public void setJCharAt (long offset, char value) | |
139 throws UnmappedAddressException, UnalignedAddressException { | |
140 throw new DebuggerException("Unimplemented"); | |
141 } | |
142 public void setJDoubleAt (long offset, double value) | |
143 throws UnmappedAddressException, UnalignedAddressException { | |
144 throw new DebuggerException("Unimplemented"); | |
145 } | |
146 public void setJFloatAt (long offset, float value) | |
147 throws UnmappedAddressException, UnalignedAddressException { | |
148 throw new DebuggerException("Unimplemented"); | |
149 } | |
150 public void setJIntAt (long offset, int value) | |
151 throws UnmappedAddressException, UnalignedAddressException { | |
152 throw new DebuggerException("Unimplemented"); | |
153 } | |
154 public void setJLongAt (long offset, long value) | |
155 throws UnmappedAddressException, UnalignedAddressException { | |
156 throw new DebuggerException("Unimplemented"); | |
157 } | |
158 public void setJShortAt (long offset, short value) | |
159 throws UnmappedAddressException, UnalignedAddressException { | |
160 throw new DebuggerException("Unimplemented"); | |
161 } | |
162 public void setOopHandleAt (long offset, OopHandle value) | |
163 throws UnmappedAddressException, UnalignedAddressException { | |
164 throw new DebuggerException("Unimplemented"); | |
165 } | |
166 | |
167 // | |
168 // Arithmetic operations -- necessary evil. | |
169 // | |
170 | |
171 public Address addOffsetTo (long offset) throws UnsupportedOperationException { | |
172 long value = addr + offset; | |
173 if (value == 0) { | |
174 return null; | |
175 } | |
176 return new RemoteAddress(debugger, value); | |
177 } | |
178 | |
179 public OopHandle addOffsetToAsOopHandle(long offset) throws UnsupportedOperationException { | |
180 long value = addr + offset; | |
181 if (value == 0) { | |
182 return null; | |
183 } | |
184 return new RemoteOopHandle(debugger, value); | |
185 } | |
186 | |
187 /** (FIXME: any signed/unsigned issues? Should this work for | |
188 OopHandles?) */ | |
189 public long minus(Address arg) { | |
190 if (arg == null) { | |
191 return addr; | |
192 } | |
193 return addr - ((RemoteAddress) arg).addr; | |
194 } | |
195 | |
196 // Two's complement representation. | |
197 // All negative numbers are larger than positive numbers. | |
198 // Numbers with the same sign can be compared normally. | |
199 // Test harness is below in main(). | |
200 | |
201 public boolean lessThan (Address arg) { | |
202 if (arg == null) { | |
203 return false; | |
204 } | |
205 RemoteAddress remoteArg = (RemoteAddress) arg; | |
206 if ((addr >= 0) && (remoteArg.addr < 0)) { | |
207 return true; | |
208 } | |
209 if ((addr < 0) && (remoteArg.addr >= 0)) { | |
210 return false; | |
211 } | |
212 return (addr < remoteArg.addr); | |
213 } | |
214 | |
215 public boolean lessThanOrEqual (Address arg) { | |
216 if (arg == null) { | |
217 return false; | |
218 } | |
219 RemoteAddress remoteArg = (RemoteAddress) arg; | |
220 if ((addr >= 0) && (remoteArg.addr < 0)) { | |
221 return true; | |
222 } | |
223 if ((addr < 0) && (remoteArg.addr >= 0)) { | |
224 return false; | |
225 } | |
226 return (addr <= remoteArg.addr); | |
227 } | |
228 | |
229 public boolean greaterThan (Address arg) { | |
230 if (arg == null) { | |
231 return true; | |
232 } | |
233 RemoteAddress remoteArg = (RemoteAddress) arg; | |
234 if ((addr >= 0) && (remoteArg.addr < 0)) { | |
235 return false; | |
236 } | |
237 if ((addr < 0) && (remoteArg.addr >= 0)) { | |
238 return true; | |
239 } | |
240 return (addr > remoteArg.addr); | |
241 } | |
242 | |
243 public boolean greaterThanOrEqual(Address arg) { | |
244 if (arg == null) { | |
245 return true; | |
246 } | |
247 RemoteAddress remoteArg = (RemoteAddress) arg; | |
248 if ((addr >= 0) && (remoteArg.addr < 0)) { | |
249 return false; | |
250 } | |
251 if ((addr < 0) && (remoteArg.addr >= 0)) { | |
252 return true; | |
253 } | |
254 return (addr >= remoteArg.addr); | |
255 } | |
256 | |
257 public Address andWithMask(long mask) throws UnsupportedOperationException { | |
258 long value = addr & mask; | |
259 if (value == 0) { | |
260 return null; | |
261 } | |
262 return new RemoteAddress(debugger, value); | |
263 } | |
264 | |
265 public Address orWithMask(long mask) throws UnsupportedOperationException { | |
266 long value = addr | mask; | |
267 if (value == 0) { | |
268 return null; | |
269 } | |
270 return new RemoteAddress(debugger, value); | |
271 } | |
272 | |
273 public Address xorWithMask(long mask) throws UnsupportedOperationException { | |
274 long value = addr ^ mask; | |
275 if (value == 0) { | |
276 return null; | |
277 } | |
278 return new RemoteAddress(debugger, value); | |
279 } | |
280 | |
281 | |
282 //-------------------------------------------------------------------------------- | |
283 // Internals only below this point | |
284 // | |
285 | |
286 long getValue() { | |
287 return addr; | |
288 } | |
289 | |
290 | |
291 private static void check(boolean arg, String failMessage) { | |
292 if (!arg) { | |
293 System.err.println(failMessage + ": FAILED"); | |
294 System.exit(1); | |
295 } | |
296 } | |
297 | |
298 // Test harness | |
299 public static void main(String[] args) { | |
300 // p/n indicates whether the interior address is really positive | |
301 // or negative. In unsigned terms, p1 < p2 < n1 < n2. | |
302 | |
303 RemoteAddress p1 = new RemoteAddress(null, 0x7FFFFFFFFFFFFFF0L); | |
304 RemoteAddress p2 = (RemoteAddress) p1.addOffsetTo(10); | |
305 RemoteAddress n1 = (RemoteAddress) p2.addOffsetTo(10); | |
306 RemoteAddress n2 = (RemoteAddress) n1.addOffsetTo(10); | |
307 | |
308 // lessThan positive tests | |
309 check(p1.lessThan(p2), "lessThan 1"); | |
310 check(p1.lessThan(n1), "lessThan 2"); | |
311 check(p1.lessThan(n2), "lessThan 3"); | |
312 check(p2.lessThan(n1), "lessThan 4"); | |
313 check(p2.lessThan(n2), "lessThan 5"); | |
314 check(n1.lessThan(n2), "lessThan 6"); | |
315 | |
316 // lessThan negative tests | |
317 check(!p1.lessThan(p1), "lessThan 7"); | |
318 check(!p2.lessThan(p2), "lessThan 8"); | |
319 check(!n1.lessThan(n1), "lessThan 9"); | |
320 check(!n2.lessThan(n2), "lessThan 10"); | |
321 | |
322 check(!p2.lessThan(p1), "lessThan 11"); | |
323 check(!n1.lessThan(p1), "lessThan 12"); | |
324 check(!n2.lessThan(p1), "lessThan 13"); | |
325 check(!n1.lessThan(p2), "lessThan 14"); | |
326 check(!n2.lessThan(p2), "lessThan 15"); | |
327 check(!n2.lessThan(n1), "lessThan 16"); | |
328 | |
329 // lessThanOrEqual positive tests | |
330 check(p1.lessThanOrEqual(p1), "lessThanOrEqual 1"); | |
331 check(p2.lessThanOrEqual(p2), "lessThanOrEqual 2"); | |
332 check(n1.lessThanOrEqual(n1), "lessThanOrEqual 3"); | |
333 check(n2.lessThanOrEqual(n2), "lessThanOrEqual 4"); | |
334 | |
335 check(p1.lessThanOrEqual(p2), "lessThanOrEqual 5"); | |
336 check(p1.lessThanOrEqual(n1), "lessThanOrEqual 6"); | |
337 check(p1.lessThanOrEqual(n2), "lessThanOrEqual 7"); | |
338 check(p2.lessThanOrEqual(n1), "lessThanOrEqual 8"); | |
339 check(p2.lessThanOrEqual(n2), "lessThanOrEqual 9"); | |
340 check(n1.lessThanOrEqual(n2), "lessThanOrEqual 10"); | |
341 | |
342 // lessThanOrEqual negative tests | |
343 check(!p2.lessThanOrEqual(p1), "lessThanOrEqual 11"); | |
344 check(!n1.lessThanOrEqual(p1), "lessThanOrEqual 12"); | |
345 check(!n2.lessThanOrEqual(p1), "lessThanOrEqual 13"); | |
346 check(!n1.lessThanOrEqual(p2), "lessThanOrEqual 14"); | |
347 check(!n2.lessThanOrEqual(p2), "lessThanOrEqual 15"); | |
348 check(!n2.lessThanOrEqual(n1), "lessThanOrEqual 16"); | |
349 | |
350 // greaterThan positive tests | |
351 check(n2.greaterThan(p1), "greaterThan 1"); | |
352 check(n2.greaterThan(p2), "greaterThan 2"); | |
353 check(n2.greaterThan(n1), "greaterThan 3"); | |
354 check(n1.greaterThan(p1), "greaterThan 4"); | |
355 check(n1.greaterThan(p2), "greaterThan 5"); | |
356 check(p2.greaterThan(p1), "greaterThan 6"); | |
357 | |
358 // greaterThan negative tests | |
359 check(!p1.greaterThan(p1), "greaterThan 7"); | |
360 check(!p2.greaterThan(p2), "greaterThan 8"); | |
361 check(!n1.greaterThan(n1), "greaterThan 9"); | |
362 check(!n2.greaterThan(n2), "greaterThan 10"); | |
363 | |
364 check(!p1.greaterThan(n2), "greaterThan 11"); | |
365 check(!p2.greaterThan(n2), "greaterThan 12"); | |
366 check(!n1.greaterThan(n2), "greaterThan 13"); | |
367 check(!p1.greaterThan(n1), "greaterThan 14"); | |
368 check(!p2.greaterThan(n1), "greaterThan 15"); | |
369 check(!p1.greaterThan(p2), "greaterThan 16"); | |
370 | |
371 // greaterThanOrEqual positive tests | |
372 check(p1.greaterThanOrEqual(p1), "greaterThanOrEqual 1"); | |
373 check(p2.greaterThanOrEqual(p2), "greaterThanOrEqual 2"); | |
374 check(n1.greaterThanOrEqual(n1), "greaterThanOrEqual 3"); | |
375 check(n2.greaterThanOrEqual(n2), "greaterThanOrEqual 4"); | |
376 | |
377 check(n2.greaterThanOrEqual(p1), "greaterThanOrEqual 5"); | |
378 check(n2.greaterThanOrEqual(p2), "greaterThanOrEqual 6"); | |
379 check(n2.greaterThanOrEqual(n1), "greaterThanOrEqual 7"); | |
380 check(n1.greaterThanOrEqual(p1), "greaterThanOrEqual 8"); | |
381 check(n1.greaterThanOrEqual(p2), "greaterThanOrEqual 9"); | |
382 check(p2.greaterThanOrEqual(p1), "greaterThanOrEqual 10"); | |
383 | |
384 // greaterThanOrEqual negative tests | |
385 check(!p1.greaterThanOrEqual(n2), "greaterThanOrEqual 11"); | |
386 check(!p2.greaterThanOrEqual(n2), "greaterThanOrEqual 12"); | |
387 check(!n1.greaterThanOrEqual(n2), "greaterThanOrEqual 13"); | |
388 check(!p1.greaterThanOrEqual(n1), "greaterThanOrEqual 14"); | |
389 check(!p2.greaterThanOrEqual(n1), "greaterThanOrEqual 15"); | |
390 check(!p1.greaterThanOrEqual(p2), "greaterThanOrEqual 16"); | |
391 | |
392 System.err.println("RemoteAddress: all tests passed successfully."); | |
393 } | |
394 } |