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

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