annotate agent/src/share/classes/sun/jvm/hotspot/debugger/dummy/DummyAddress.java @ 196:d1605aabd0a1 jdk7-b30

6719955: Update copyright year Summary: Update copyright year for files that have been modified in 2008 Reviewed-by: ohair, tbell
author xdono
date Wed, 02 Jul 2008 12:55:16 -0700
parents ba764ed4b6f2
children c18cbe5936b8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
196
d1605aabd0a1 6719955: Update copyright year
xdono
parents: 113
diff changeset
2 * Copyright 2000-2008 Sun Microsystems, Inc. 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 *
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.dummy;
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 /** For testing purposes */
a61af66fc99e Initial load
duke
parents:
diff changeset
30
a61af66fc99e Initial load
duke
parents:
diff changeset
31 class DummyAddress implements Address {
a61af66fc99e Initial load
duke
parents:
diff changeset
32 protected DummyDebugger debugger;
a61af66fc99e Initial load
duke
parents:
diff changeset
33 protected long addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
34 private static final long badLong = 0xBAADBABEL;
a61af66fc99e Initial load
duke
parents:
diff changeset
35 private static final double badDouble = 1.23456;
a61af66fc99e Initial load
duke
parents:
diff changeset
36
a61af66fc99e Initial load
duke
parents:
diff changeset
37 DummyAddress(DummyDebugger debugger, long addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
38 this.debugger = debugger;
a61af66fc99e Initial load
duke
parents:
diff changeset
39 this.addr = addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
40 }
a61af66fc99e Initial load
duke
parents:
diff changeset
41
a61af66fc99e Initial load
duke
parents:
diff changeset
42 //
a61af66fc99e Initial load
duke
parents:
diff changeset
43 // Basic Java routines
a61af66fc99e Initial load
duke
parents:
diff changeset
44 //
a61af66fc99e Initial load
duke
parents:
diff changeset
45
a61af66fc99e Initial load
duke
parents:
diff changeset
46 public boolean equals(Object arg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
47 if (arg == null) {
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 if (!(arg instanceof DummyAddress)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
52 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
53 }
a61af66fc99e Initial load
duke
parents:
diff changeset
54
a61af66fc99e Initial load
duke
parents:
diff changeset
55 return (addr == ((DummyAddress) arg).addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
56 }
a61af66fc99e Initial load
duke
parents:
diff changeset
57
a61af66fc99e Initial load
duke
parents:
diff changeset
58 public int hashCode() {
a61af66fc99e Initial load
duke
parents:
diff changeset
59 // FIXME: suggestions on a better hash code?
a61af66fc99e Initial load
duke
parents:
diff changeset
60 return (int) 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 public String toString() {
a61af66fc99e Initial load
duke
parents:
diff changeset
64 return debugger.addressToString(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
65 }
a61af66fc99e Initial load
duke
parents:
diff changeset
66
a61af66fc99e Initial load
duke
parents:
diff changeset
67 //
a61af66fc99e Initial load
duke
parents:
diff changeset
68 // C/C++-related routines
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 long getCIntegerAt(long offset, long numBytes, boolean isUnsigned) throws UnalignedAddressException, UnmappedAddressException {
a61af66fc99e Initial load
duke
parents:
diff changeset
72 return badLong;
a61af66fc99e Initial load
duke
parents:
diff changeset
73 }
a61af66fc99e Initial load
duke
parents:
diff changeset
74
a61af66fc99e Initial load
duke
parents:
diff changeset
75 public Address getAddressAt(long offset) throws UnalignedAddressException, UnmappedAddressException {
a61af66fc99e Initial load
duke
parents:
diff changeset
76 return new DummyAddress(debugger, badLong);
a61af66fc99e Initial load
duke
parents:
diff changeset
77 }
a61af66fc99e Initial load
duke
parents:
diff changeset
78
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
79 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
80 return new DummyAddress(debugger, badLong);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
81 }
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
82
0
a61af66fc99e Initial load
duke
parents:
diff changeset
83 //
a61af66fc99e Initial load
duke
parents:
diff changeset
84 // Java-related routines
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 boolean getJBooleanAt(long offset) throws UnalignedAddressException, UnmappedAddressException {
a61af66fc99e Initial load
duke
parents:
diff changeset
88 return false;
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 byte getJByteAt(long offset) throws UnalignedAddressException, UnmappedAddressException {
a61af66fc99e Initial load
duke
parents:
diff changeset
92 return (byte) badLong;
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 char getJCharAt(long offset) throws UnalignedAddressException, UnmappedAddressException {
a61af66fc99e Initial load
duke
parents:
diff changeset
96 return (char) badLong;
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 double getJDoubleAt(long offset) throws UnalignedAddressException, UnmappedAddressException {
a61af66fc99e Initial load
duke
parents:
diff changeset
100 return badDouble;
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 float getJFloatAt(long offset) throws UnalignedAddressException, UnmappedAddressException {
a61af66fc99e Initial load
duke
parents:
diff changeset
104 return (float) badDouble;
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 int getJIntAt(long offset) throws UnalignedAddressException, UnmappedAddressException {
a61af66fc99e Initial load
duke
parents:
diff changeset
108 return (int) badLong;
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 long getJLongAt(long offset) throws UnalignedAddressException, UnmappedAddressException {
a61af66fc99e Initial load
duke
parents:
diff changeset
112 return badLong;
a61af66fc99e Initial load
duke
parents:
diff changeset
113 }
a61af66fc99e Initial load
duke
parents:
diff changeset
114
a61af66fc99e Initial load
duke
parents:
diff changeset
115 public short getJShortAt(long offset) throws UnalignedAddressException, UnmappedAddressException {
a61af66fc99e Initial load
duke
parents:
diff changeset
116 return (short) badLong;
a61af66fc99e Initial load
duke
parents:
diff changeset
117 }
a61af66fc99e Initial load
duke
parents:
diff changeset
118
a61af66fc99e Initial load
duke
parents:
diff changeset
119 public OopHandle getOopHandleAt(long offset)
a61af66fc99e Initial load
duke
parents:
diff changeset
120 throws UnalignedAddressException, UnmappedAddressException, NotInHeapException {
a61af66fc99e Initial load
duke
parents:
diff changeset
121 return new DummyOopHandle(debugger, badLong);
a61af66fc99e Initial load
duke
parents:
diff changeset
122 }
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
123 public OopHandle getCompOopHandleAt(long offset)
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
124 throws UnalignedAddressException, UnmappedAddressException, NotInHeapException {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
125 return new DummyOopHandle(debugger, badLong);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
126 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
127
a61af66fc99e Initial load
duke
parents:
diff changeset
128 // Mutators -- not implemented
a61af66fc99e Initial load
duke
parents:
diff changeset
129 public void setCIntegerAt(long offset, long numBytes, long value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
130 throw new DebuggerException("Unimplemented");
a61af66fc99e Initial load
duke
parents:
diff changeset
131 }
a61af66fc99e Initial load
duke
parents:
diff changeset
132 public void setAddressAt(long offset, Address value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
133 throw new DebuggerException("Unimplemented");
a61af66fc99e Initial load
duke
parents:
diff changeset
134 }
a61af66fc99e Initial load
duke
parents:
diff changeset
135 public void setJBooleanAt (long offset, boolean value)
a61af66fc99e Initial load
duke
parents:
diff changeset
136 throws UnmappedAddressException, UnalignedAddressException {
a61af66fc99e Initial load
duke
parents:
diff changeset
137 throw new DebuggerException("Unimplemented");
a61af66fc99e Initial load
duke
parents:
diff changeset
138 }
a61af66fc99e Initial load
duke
parents:
diff changeset
139 public void setJByteAt (long offset, byte value)
a61af66fc99e Initial load
duke
parents:
diff changeset
140 throws UnmappedAddressException, UnalignedAddressException {
a61af66fc99e Initial load
duke
parents:
diff changeset
141 throw new DebuggerException("Unimplemented");
a61af66fc99e Initial load
duke
parents:
diff changeset
142 }
a61af66fc99e Initial load
duke
parents:
diff changeset
143 public void setJCharAt (long offset, char value)
a61af66fc99e Initial load
duke
parents:
diff changeset
144 throws UnmappedAddressException, UnalignedAddressException {
a61af66fc99e Initial load
duke
parents:
diff changeset
145 throw new DebuggerException("Unimplemented");
a61af66fc99e Initial load
duke
parents:
diff changeset
146 }
a61af66fc99e Initial load
duke
parents:
diff changeset
147 public void setJDoubleAt (long offset, double value)
a61af66fc99e Initial load
duke
parents:
diff changeset
148 throws UnmappedAddressException, UnalignedAddressException {
a61af66fc99e Initial load
duke
parents:
diff changeset
149 throw new DebuggerException("Unimplemented");
a61af66fc99e Initial load
duke
parents:
diff changeset
150 }
a61af66fc99e Initial load
duke
parents:
diff changeset
151 public void setJFloatAt (long offset, float value)
a61af66fc99e Initial load
duke
parents:
diff changeset
152 throws UnmappedAddressException, UnalignedAddressException {
a61af66fc99e Initial load
duke
parents:
diff changeset
153 throw new DebuggerException("Unimplemented");
a61af66fc99e Initial load
duke
parents:
diff changeset
154 }
a61af66fc99e Initial load
duke
parents:
diff changeset
155 public void setJIntAt (long offset, int value)
a61af66fc99e Initial load
duke
parents:
diff changeset
156 throws UnmappedAddressException, UnalignedAddressException {
a61af66fc99e Initial load
duke
parents:
diff changeset
157 throw new DebuggerException("Unimplemented");
a61af66fc99e Initial load
duke
parents:
diff changeset
158 }
a61af66fc99e Initial load
duke
parents:
diff changeset
159 public void setJLongAt (long offset, long value)
a61af66fc99e Initial load
duke
parents:
diff changeset
160 throws UnmappedAddressException, UnalignedAddressException {
a61af66fc99e Initial load
duke
parents:
diff changeset
161 throw new DebuggerException("Unimplemented");
a61af66fc99e Initial load
duke
parents:
diff changeset
162 }
a61af66fc99e Initial load
duke
parents:
diff changeset
163 public void setJShortAt (long offset, short value)
a61af66fc99e Initial load
duke
parents:
diff changeset
164 throws UnmappedAddressException, UnalignedAddressException {
a61af66fc99e Initial load
duke
parents:
diff changeset
165 throw new DebuggerException("Unimplemented");
a61af66fc99e Initial load
duke
parents:
diff changeset
166 }
a61af66fc99e Initial load
duke
parents:
diff changeset
167 public void setOopHandleAt (long offset, OopHandle value)
a61af66fc99e Initial load
duke
parents:
diff changeset
168 throws UnmappedAddressException, UnalignedAddressException {
a61af66fc99e Initial load
duke
parents:
diff changeset
169 throw new DebuggerException("Unimplemented");
a61af66fc99e Initial load
duke
parents:
diff changeset
170 }
a61af66fc99e Initial load
duke
parents:
diff changeset
171
a61af66fc99e Initial load
duke
parents:
diff changeset
172 //
a61af66fc99e Initial load
duke
parents:
diff changeset
173 // Arithmetic operations -- necessary evil.
a61af66fc99e Initial load
duke
parents:
diff changeset
174 //
a61af66fc99e Initial load
duke
parents:
diff changeset
175
a61af66fc99e Initial load
duke
parents:
diff changeset
176 public Address addOffsetTo (long offset) throws UnsupportedOperationException {
a61af66fc99e Initial load
duke
parents:
diff changeset
177 long value = addr + offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
178 if (value == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
179 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
180 }
a61af66fc99e Initial load
duke
parents:
diff changeset
181 return new DummyAddress(debugger, value);
a61af66fc99e Initial load
duke
parents:
diff changeset
182 }
a61af66fc99e Initial load
duke
parents:
diff changeset
183
a61af66fc99e Initial load
duke
parents:
diff changeset
184 public OopHandle addOffsetToAsOopHandle(long offset) throws UnsupportedOperationException {
a61af66fc99e Initial load
duke
parents:
diff changeset
185 long value = addr + offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
186 if (value == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
187 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
188 }
a61af66fc99e Initial load
duke
parents:
diff changeset
189 return new DummyOopHandle(debugger, value);
a61af66fc99e Initial load
duke
parents:
diff changeset
190 }
a61af66fc99e Initial load
duke
parents:
diff changeset
191
a61af66fc99e Initial load
duke
parents:
diff changeset
192 /** (FIXME: any signed/unsigned issues? Should this work for
a61af66fc99e Initial load
duke
parents:
diff changeset
193 OopHandles?) */
a61af66fc99e Initial load
duke
parents:
diff changeset
194 public long minus(Address arg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
195 if (arg == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
196 return addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
197 }
a61af66fc99e Initial load
duke
parents:
diff changeset
198 return addr - ((DummyAddress) arg).addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
199 }
a61af66fc99e Initial load
duke
parents:
diff changeset
200
a61af66fc99e Initial load
duke
parents:
diff changeset
201 // Two's complement representation.
a61af66fc99e Initial load
duke
parents:
diff changeset
202 // All negative numbers are larger than positive numbers.
a61af66fc99e Initial load
duke
parents:
diff changeset
203 // Numbers with the same sign can be compared normally.
a61af66fc99e Initial load
duke
parents:
diff changeset
204 // Test harness is below in main().
a61af66fc99e Initial load
duke
parents:
diff changeset
205
a61af66fc99e Initial load
duke
parents:
diff changeset
206 public boolean lessThan (Address arg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
207 DummyAddress DummyArg = (DummyAddress) arg;
a61af66fc99e Initial load
duke
parents:
diff changeset
208 if ((addr >= 0) && (DummyArg.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) && (DummyArg.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 < DummyArg.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 arg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
218 DummyAddress DummyArg = (DummyAddress) arg;
a61af66fc99e Initial load
duke
parents:
diff changeset
219 if ((addr >= 0) && (DummyArg.addr < 0)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
220 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
221 }
a61af66fc99e Initial load
duke
parents:
diff changeset
222 if ((addr < 0) && (DummyArg.addr >= 0)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
223 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
224 }
a61af66fc99e Initial load
duke
parents:
diff changeset
225 return (addr <= DummyArg.addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
226 }
a61af66fc99e Initial load
duke
parents:
diff changeset
227
a61af66fc99e Initial load
duke
parents:
diff changeset
228 public boolean greaterThan (Address arg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
229 DummyAddress DummyArg = (DummyAddress) arg;
a61af66fc99e Initial load
duke
parents:
diff changeset
230 if ((addr >= 0) && (DummyArg.addr < 0)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
231 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
232 }
a61af66fc99e Initial load
duke
parents:
diff changeset
233 if ((addr < 0) && (DummyArg.addr >= 0)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
234 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
235 }
a61af66fc99e Initial load
duke
parents:
diff changeset
236 return (addr > DummyArg.addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
237 }
a61af66fc99e Initial load
duke
parents:
diff changeset
238
a61af66fc99e Initial load
duke
parents:
diff changeset
239 public boolean greaterThanOrEqual(Address arg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
240 DummyAddress DummyArg = (DummyAddress) arg;
a61af66fc99e Initial load
duke
parents:
diff changeset
241 if ((addr >= 0) && (DummyArg.addr < 0)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
242 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
243 }
a61af66fc99e Initial load
duke
parents:
diff changeset
244 if ((addr < 0) && (DummyArg.addr >= 0)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
245 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
246 }
a61af66fc99e Initial load
duke
parents:
diff changeset
247 return (addr >= DummyArg.addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
248 }
a61af66fc99e Initial load
duke
parents:
diff changeset
249
a61af66fc99e Initial load
duke
parents:
diff changeset
250 public Address andWithMask(long mask) throws UnsupportedOperationException {
a61af66fc99e Initial load
duke
parents:
diff changeset
251 long value = addr & mask;
a61af66fc99e Initial load
duke
parents:
diff changeset
252 if (value == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
253 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
254 }
a61af66fc99e Initial load
duke
parents:
diff changeset
255 return new DummyAddress(debugger, value);
a61af66fc99e Initial load
duke
parents:
diff changeset
256 }
a61af66fc99e Initial load
duke
parents:
diff changeset
257
a61af66fc99e Initial load
duke
parents:
diff changeset
258 public Address orWithMask(long mask) throws UnsupportedOperationException {
a61af66fc99e Initial load
duke
parents:
diff changeset
259 long value = addr | mask;
a61af66fc99e Initial load
duke
parents:
diff changeset
260 if (value == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
261 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
262 }
a61af66fc99e Initial load
duke
parents:
diff changeset
263 return new DummyAddress(debugger, value);
a61af66fc99e Initial load
duke
parents:
diff changeset
264 }
a61af66fc99e Initial load
duke
parents:
diff changeset
265
a61af66fc99e Initial load
duke
parents:
diff changeset
266 public Address xorWithMask(long mask) throws UnsupportedOperationException {
a61af66fc99e Initial load
duke
parents:
diff changeset
267 long value = addr ^ mask;
a61af66fc99e Initial load
duke
parents:
diff changeset
268 if (value == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
269 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
270 }
a61af66fc99e Initial load
duke
parents:
diff changeset
271 return new DummyAddress(debugger, value);
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 // Internals only below this point
a61af66fc99e Initial load
duke
parents:
diff changeset
276 //
a61af66fc99e Initial load
duke
parents:
diff changeset
277
a61af66fc99e Initial load
duke
parents:
diff changeset
278 long getValue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
279 return addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
280 }
a61af66fc99e Initial load
duke
parents:
diff changeset
281
a61af66fc99e Initial load
duke
parents:
diff changeset
282 private static void check(boolean arg, String failMessage) {
a61af66fc99e Initial load
duke
parents:
diff changeset
283 if (!arg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
284 System.err.println(failMessage + ": FAILED");
a61af66fc99e Initial load
duke
parents:
diff changeset
285 System.exit(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
286 }
a61af66fc99e Initial load
duke
parents:
diff changeset
287 }
a61af66fc99e Initial load
duke
parents:
diff changeset
288
a61af66fc99e Initial load
duke
parents:
diff changeset
289 // Test harness
a61af66fc99e Initial load
duke
parents:
diff changeset
290 public static void main(String[] args) {
a61af66fc99e Initial load
duke
parents:
diff changeset
291 // p/n indicates whether the interior address is really positive
a61af66fc99e Initial load
duke
parents:
diff changeset
292 // or negative. In unsigned terms, p1 < p2 < n1 < n2.
a61af66fc99e Initial load
duke
parents:
diff changeset
293
a61af66fc99e Initial load
duke
parents:
diff changeset
294 DummyAddress p1 = new DummyAddress(null, 0x7FFFFFFFFFFFFFF0L);
a61af66fc99e Initial load
duke
parents:
diff changeset
295 DummyAddress p2 = (DummyAddress) p1.addOffsetTo(10);
a61af66fc99e Initial load
duke
parents:
diff changeset
296 DummyAddress n1 = (DummyAddress) p2.addOffsetTo(10);
a61af66fc99e Initial load
duke
parents:
diff changeset
297 DummyAddress n2 = (DummyAddress) n1.addOffsetTo(10);
a61af66fc99e Initial load
duke
parents:
diff changeset
298
a61af66fc99e Initial load
duke
parents:
diff changeset
299 // lessThan positive tests
a61af66fc99e Initial load
duke
parents:
diff changeset
300 check(p1.lessThan(p2), "lessThan 1");
a61af66fc99e Initial load
duke
parents:
diff changeset
301 check(p1.lessThan(n1), "lessThan 2");
a61af66fc99e Initial load
duke
parents:
diff changeset
302 check(p1.lessThan(n2), "lessThan 3");
a61af66fc99e Initial load
duke
parents:
diff changeset
303 check(p2.lessThan(n1), "lessThan 4");
a61af66fc99e Initial load
duke
parents:
diff changeset
304 check(p2.lessThan(n2), "lessThan 5");
a61af66fc99e Initial load
duke
parents:
diff changeset
305 check(n1.lessThan(n2), "lessThan 6");
a61af66fc99e Initial load
duke
parents:
diff changeset
306
a61af66fc99e Initial load
duke
parents:
diff changeset
307 // lessThan negative tests
a61af66fc99e Initial load
duke
parents:
diff changeset
308 check(!p1.lessThan(p1), "lessThan 7");
a61af66fc99e Initial load
duke
parents:
diff changeset
309 check(!p2.lessThan(p2), "lessThan 8");
a61af66fc99e Initial load
duke
parents:
diff changeset
310 check(!n1.lessThan(n1), "lessThan 9");
a61af66fc99e Initial load
duke
parents:
diff changeset
311 check(!n2.lessThan(n2), "lessThan 10");
a61af66fc99e Initial load
duke
parents:
diff changeset
312
a61af66fc99e Initial load
duke
parents:
diff changeset
313 check(!p2.lessThan(p1), "lessThan 11");
a61af66fc99e Initial load
duke
parents:
diff changeset
314 check(!n1.lessThan(p1), "lessThan 12");
a61af66fc99e Initial load
duke
parents:
diff changeset
315 check(!n2.lessThan(p1), "lessThan 13");
a61af66fc99e Initial load
duke
parents:
diff changeset
316 check(!n1.lessThan(p2), "lessThan 14");
a61af66fc99e Initial load
duke
parents:
diff changeset
317 check(!n2.lessThan(p2), "lessThan 15");
a61af66fc99e Initial load
duke
parents:
diff changeset
318 check(!n2.lessThan(n1), "lessThan 16");
a61af66fc99e Initial load
duke
parents:
diff changeset
319
a61af66fc99e Initial load
duke
parents:
diff changeset
320 // lessThanOrEqual positive tests
a61af66fc99e Initial load
duke
parents:
diff changeset
321 check(p1.lessThanOrEqual(p1), "lessThanOrEqual 1");
a61af66fc99e Initial load
duke
parents:
diff changeset
322 check(p2.lessThanOrEqual(p2), "lessThanOrEqual 2");
a61af66fc99e Initial load
duke
parents:
diff changeset
323 check(n1.lessThanOrEqual(n1), "lessThanOrEqual 3");
a61af66fc99e Initial load
duke
parents:
diff changeset
324 check(n2.lessThanOrEqual(n2), "lessThanOrEqual 4");
a61af66fc99e Initial load
duke
parents:
diff changeset
325
a61af66fc99e Initial load
duke
parents:
diff changeset
326 check(p1.lessThanOrEqual(p2), "lessThanOrEqual 5");
a61af66fc99e Initial load
duke
parents:
diff changeset
327 check(p1.lessThanOrEqual(n1), "lessThanOrEqual 6");
a61af66fc99e Initial load
duke
parents:
diff changeset
328 check(p1.lessThanOrEqual(n2), "lessThanOrEqual 7");
a61af66fc99e Initial load
duke
parents:
diff changeset
329 check(p2.lessThanOrEqual(n1), "lessThanOrEqual 8");
a61af66fc99e Initial load
duke
parents:
diff changeset
330 check(p2.lessThanOrEqual(n2), "lessThanOrEqual 9");
a61af66fc99e Initial load
duke
parents:
diff changeset
331 check(n1.lessThanOrEqual(n2), "lessThanOrEqual 10");
a61af66fc99e Initial load
duke
parents:
diff changeset
332
a61af66fc99e Initial load
duke
parents:
diff changeset
333 // lessThanOrEqual negative tests
a61af66fc99e Initial load
duke
parents:
diff changeset
334 check(!p2.lessThanOrEqual(p1), "lessThanOrEqual 11");
a61af66fc99e Initial load
duke
parents:
diff changeset
335 check(!n1.lessThanOrEqual(p1), "lessThanOrEqual 12");
a61af66fc99e Initial load
duke
parents:
diff changeset
336 check(!n2.lessThanOrEqual(p1), "lessThanOrEqual 13");
a61af66fc99e Initial load
duke
parents:
diff changeset
337 check(!n1.lessThanOrEqual(p2), "lessThanOrEqual 14");
a61af66fc99e Initial load
duke
parents:
diff changeset
338 check(!n2.lessThanOrEqual(p2), "lessThanOrEqual 15");
a61af66fc99e Initial load
duke
parents:
diff changeset
339 check(!n2.lessThanOrEqual(n1), "lessThanOrEqual 16");
a61af66fc99e Initial load
duke
parents:
diff changeset
340
a61af66fc99e Initial load
duke
parents:
diff changeset
341 // greaterThan positive tests
a61af66fc99e Initial load
duke
parents:
diff changeset
342 check(n2.greaterThan(p1), "greaterThan 1");
a61af66fc99e Initial load
duke
parents:
diff changeset
343 check(n2.greaterThan(p2), "greaterThan 2");
a61af66fc99e Initial load
duke
parents:
diff changeset
344 check(n2.greaterThan(n1), "greaterThan 3");
a61af66fc99e Initial load
duke
parents:
diff changeset
345 check(n1.greaterThan(p1), "greaterThan 4");
a61af66fc99e Initial load
duke
parents:
diff changeset
346 check(n1.greaterThan(p2), "greaterThan 5");
a61af66fc99e Initial load
duke
parents:
diff changeset
347 check(p2.greaterThan(p1), "greaterThan 6");
a61af66fc99e Initial load
duke
parents:
diff changeset
348
a61af66fc99e Initial load
duke
parents:
diff changeset
349 // greaterThan negative tests
a61af66fc99e Initial load
duke
parents:
diff changeset
350 check(!p1.greaterThan(p1), "greaterThan 7");
a61af66fc99e Initial load
duke
parents:
diff changeset
351 check(!p2.greaterThan(p2), "greaterThan 8");
a61af66fc99e Initial load
duke
parents:
diff changeset
352 check(!n1.greaterThan(n1), "greaterThan 9");
a61af66fc99e Initial load
duke
parents:
diff changeset
353 check(!n2.greaterThan(n2), "greaterThan 10");
a61af66fc99e Initial load
duke
parents:
diff changeset
354
a61af66fc99e Initial load
duke
parents:
diff changeset
355 check(!p1.greaterThan(n2), "greaterThan 11");
a61af66fc99e Initial load
duke
parents:
diff changeset
356 check(!p2.greaterThan(n2), "greaterThan 12");
a61af66fc99e Initial load
duke
parents:
diff changeset
357 check(!n1.greaterThan(n2), "greaterThan 13");
a61af66fc99e Initial load
duke
parents:
diff changeset
358 check(!p1.greaterThan(n1), "greaterThan 14");
a61af66fc99e Initial load
duke
parents:
diff changeset
359 check(!p2.greaterThan(n1), "greaterThan 15");
a61af66fc99e Initial load
duke
parents:
diff changeset
360 check(!p1.greaterThan(p2), "greaterThan 16");
a61af66fc99e Initial load
duke
parents:
diff changeset
361
a61af66fc99e Initial load
duke
parents:
diff changeset
362 // greaterThanOrEqual positive tests
a61af66fc99e Initial load
duke
parents:
diff changeset
363 check(p1.greaterThanOrEqual(p1), "greaterThanOrEqual 1");
a61af66fc99e Initial load
duke
parents:
diff changeset
364 check(p2.greaterThanOrEqual(p2), "greaterThanOrEqual 2");
a61af66fc99e Initial load
duke
parents:
diff changeset
365 check(n1.greaterThanOrEqual(n1), "greaterThanOrEqual 3");
a61af66fc99e Initial load
duke
parents:
diff changeset
366 check(n2.greaterThanOrEqual(n2), "greaterThanOrEqual 4");
a61af66fc99e Initial load
duke
parents:
diff changeset
367
a61af66fc99e Initial load
duke
parents:
diff changeset
368 check(n2.greaterThanOrEqual(p1), "greaterThanOrEqual 5");
a61af66fc99e Initial load
duke
parents:
diff changeset
369 check(n2.greaterThanOrEqual(p2), "greaterThanOrEqual 6");
a61af66fc99e Initial load
duke
parents:
diff changeset
370 check(n2.greaterThanOrEqual(n1), "greaterThanOrEqual 7");
a61af66fc99e Initial load
duke
parents:
diff changeset
371 check(n1.greaterThanOrEqual(p1), "greaterThanOrEqual 8");
a61af66fc99e Initial load
duke
parents:
diff changeset
372 check(n1.greaterThanOrEqual(p2), "greaterThanOrEqual 9");
a61af66fc99e Initial load
duke
parents:
diff changeset
373 check(p2.greaterThanOrEqual(p1), "greaterThanOrEqual 10");
a61af66fc99e Initial load
duke
parents:
diff changeset
374
a61af66fc99e Initial load
duke
parents:
diff changeset
375 // greaterThanOrEqual negative tests
a61af66fc99e Initial load
duke
parents:
diff changeset
376 check(!p1.greaterThanOrEqual(n2), "greaterThanOrEqual 11");
a61af66fc99e Initial load
duke
parents:
diff changeset
377 check(!p2.greaterThanOrEqual(n2), "greaterThanOrEqual 12");
a61af66fc99e Initial load
duke
parents:
diff changeset
378 check(!n1.greaterThanOrEqual(n2), "greaterThanOrEqual 13");
a61af66fc99e Initial load
duke
parents:
diff changeset
379 check(!p1.greaterThanOrEqual(n1), "greaterThanOrEqual 14");
a61af66fc99e Initial load
duke
parents:
diff changeset
380 check(!p2.greaterThanOrEqual(n1), "greaterThanOrEqual 15");
a61af66fc99e Initial load
duke
parents:
diff changeset
381 check(!p1.greaterThanOrEqual(p2), "greaterThanOrEqual 16");
a61af66fc99e Initial load
duke
parents:
diff changeset
382
a61af66fc99e Initial load
duke
parents:
diff changeset
383 System.err.println("DummyAddress: all tests passed successfully.");
a61af66fc99e Initial load
duke
parents:
diff changeset
384 }
a61af66fc99e Initial load
duke
parents:
diff changeset
385 }