annotate agent/src/share/classes/sun/jvm/hotspot/debugger/Address.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;
a61af66fc99e Initial load
duke
parents:
diff changeset
26
a61af66fc99e Initial load
duke
parents:
diff changeset
27 /** <P> This is the bottom-most interface which abstracts address
a61af66fc99e Initial load
duke
parents:
diff changeset
28 access for both debugging and introspection. In the situation of
a61af66fc99e Initial load
duke
parents:
diff changeset
29 debugging a target VM, these routines can throw the specified
a61af66fc99e Initial load
duke
parents:
diff changeset
30 RuntimeExceptions to indicate failure and allow recovery of the
a61af66fc99e Initial load
duke
parents:
diff changeset
31 debugging system. If these are used for introspecting the current
a61af66fc99e Initial load
duke
parents:
diff changeset
32 VM and implementing functionality in it, however, it is expected
a61af66fc99e Initial load
duke
parents:
diff changeset
33 that these kinds of failures will not occur and, in fact, a crash
a61af66fc99e Initial load
duke
parents:
diff changeset
34 will occur if the situation arises where they would have been
a61af66fc99e Initial load
duke
parents:
diff changeset
35 thrown. </P>
a61af66fc99e Initial load
duke
parents:
diff changeset
36
a61af66fc99e Initial load
duke
parents:
diff changeset
37 <P> Addresses are immutable. Further, it was decided not to expose
a61af66fc99e Initial load
duke
parents:
diff changeset
38 the representation of the Address (and provide a corresponding
a61af66fc99e Initial load
duke
parents:
diff changeset
39 factory method from, for example, long to Address). Unfortunately,
a61af66fc99e Initial load
duke
parents:
diff changeset
40 because of the existence of C and "reuse" of low bits of pointers,
a61af66fc99e Initial load
duke
parents:
diff changeset
41 it is occasionally necessary to perform logical operations like
a61af66fc99e Initial load
duke
parents:
diff changeset
42 masking off the low bits of an "address". While these operations
a61af66fc99e Initial load
duke
parents:
diff changeset
43 could be used to generate arbitrary Address objects, allowing this
a61af66fc99e Initial load
duke
parents:
diff changeset
44 is not the intent of providing these operations. </P>
a61af66fc99e Initial load
duke
parents:
diff changeset
45
a61af66fc99e Initial load
duke
parents:
diff changeset
46 <P> This interface is able to fetch all Java primitive types,
a61af66fc99e Initial load
duke
parents:
diff changeset
47 addresses, oops, and C integers of arbitrary size (see @see
a61af66fc99e Initial load
duke
parents:
diff changeset
48 sun.jvm.hotspot.types.CIntegerType for further discussion). Note
a61af66fc99e Initial load
duke
parents:
diff changeset
49 that the result of the latter is restricted to fitting into a
a61af66fc99e Initial load
duke
parents:
diff changeset
50 64-bit value and the high-order bytes will be silently discarded
a61af66fc99e Initial load
duke
parents:
diff changeset
51 if too many bytes are requested. </P>
a61af66fc99e Initial load
duke
parents:
diff changeset
52
a61af66fc99e Initial load
duke
parents:
diff changeset
53 <P> Implementations may have restrictions, for example that the
a61af66fc99e Initial load
duke
parents:
diff changeset
54 Java-related routines may not be called until a certain point in
a61af66fc99e Initial load
duke
parents:
diff changeset
55 the bootstrapping process once the sizes of the Java primitive
a61af66fc99e Initial load
duke
parents:
diff changeset
56 types are known. (The current implementation has that property.)
a61af66fc99e Initial load
duke
parents:
diff changeset
57 </P>
a61af66fc99e Initial load
duke
parents:
diff changeset
58
a61af66fc99e Initial load
duke
parents:
diff changeset
59 <P> A note of warning: in C addresses, when represented as
a61af66fc99e Initial load
duke
parents:
diff changeset
60 integers, are usually represented with unsigned types.
a61af66fc99e Initial load
duke
parents:
diff changeset
61 Unfortunately, there are no unsigned primitive types in Java, so
a61af66fc99e Initial load
duke
parents:
diff changeset
62 care will have to be taken in the implementation of this interface
a61af66fc99e Initial load
duke
parents:
diff changeset
63 if using longs as the representation for 64-bit correctness. This
a61af66fc99e Initial load
duke
parents:
diff changeset
64 is not so simple for the comparison operators. </P> */
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66 public interface Address {
a61af66fc99e Initial load
duke
parents:
diff changeset
67
a61af66fc99e Initial load
duke
parents:
diff changeset
68 /** This is stated explicitly here because it is important for
a61af66fc99e Initial load
duke
parents:
diff changeset
69 implementations to understand that equals() and hashCode() must
a61af66fc99e Initial load
duke
parents:
diff changeset
70 absolutely, positively work properly -- i.e., two Address
a61af66fc99e Initial load
duke
parents:
diff changeset
71 objects representing the same address are both equal (via
a61af66fc99e Initial load
duke
parents:
diff changeset
72 equals()) and have the same hash code. */
a61af66fc99e Initial load
duke
parents:
diff changeset
73 public boolean equals(Object arg);
a61af66fc99e Initial load
duke
parents:
diff changeset
74
a61af66fc99e Initial load
duke
parents:
diff changeset
75 /** This is stated explicitly here because it is important for
a61af66fc99e Initial load
duke
parents:
diff changeset
76 implementations to understand that equals() and hashCode() must
a61af66fc99e Initial load
duke
parents:
diff changeset
77 absolutely, positively work properly -- i.e., two Address
a61af66fc99e Initial load
duke
parents:
diff changeset
78 objects representing the same address are both equal (via
a61af66fc99e Initial load
duke
parents:
diff changeset
79 equals()) and have the same hash code. */
a61af66fc99e Initial load
duke
parents:
diff changeset
80 public int hashCode();
a61af66fc99e Initial load
duke
parents:
diff changeset
81
a61af66fc99e Initial load
duke
parents:
diff changeset
82 //
a61af66fc99e Initial load
duke
parents:
diff changeset
83 // C/C++-related routines
a61af66fc99e Initial load
duke
parents:
diff changeset
84 //
a61af66fc99e Initial load
duke
parents:
diff changeset
85
a61af66fc99e Initial load
duke
parents:
diff changeset
86 public long getCIntegerAt (long offset, long numBytes, boolean isUnsigned)
a61af66fc99e Initial load
duke
parents:
diff changeset
87 throws UnmappedAddressException, UnalignedAddressException;
a61af66fc99e Initial load
duke
parents:
diff changeset
88 /** This returns null if the address at the given offset is NULL. */
a61af66fc99e Initial load
duke
parents:
diff changeset
89 public Address getAddressAt (long offset) throws UnmappedAddressException, UnalignedAddressException;
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
90 /** Returns the decoded address at the given offset */
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
91 public Address getCompOopAddressAt (long offset) throws UnmappedAddressException, UnalignedAddressException;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
92
a61af66fc99e Initial load
duke
parents:
diff changeset
93 //
a61af66fc99e Initial load
duke
parents:
diff changeset
94 // Java-related routines
a61af66fc99e Initial load
duke
parents:
diff changeset
95 //
a61af66fc99e Initial load
duke
parents:
diff changeset
96
a61af66fc99e Initial load
duke
parents:
diff changeset
97 public boolean getJBooleanAt (long offset) throws UnmappedAddressException, UnalignedAddressException;
a61af66fc99e Initial load
duke
parents:
diff changeset
98 public byte getJByteAt (long offset) throws UnmappedAddressException, UnalignedAddressException;
a61af66fc99e Initial load
duke
parents:
diff changeset
99 public char getJCharAt (long offset) throws UnmappedAddressException, UnalignedAddressException;
a61af66fc99e Initial load
duke
parents:
diff changeset
100 public double getJDoubleAt (long offset) throws UnmappedAddressException, UnalignedAddressException;
a61af66fc99e Initial load
duke
parents:
diff changeset
101 public float getJFloatAt (long offset) throws UnmappedAddressException, UnalignedAddressException;
a61af66fc99e Initial load
duke
parents:
diff changeset
102 public int getJIntAt (long offset) throws UnmappedAddressException, UnalignedAddressException;
a61af66fc99e Initial load
duke
parents:
diff changeset
103 public long getJLongAt (long offset) throws UnmappedAddressException, UnalignedAddressException;
a61af66fc99e Initial load
duke
parents:
diff changeset
104 public short getJShortAt (long offset) throws UnmappedAddressException, UnalignedAddressException;
a61af66fc99e Initial load
duke
parents:
diff changeset
105 /** This returns null if the address at the given offset is NULL. */
a61af66fc99e Initial load
duke
parents:
diff changeset
106 public OopHandle getOopHandleAt (long offset)
a61af66fc99e Initial load
duke
parents:
diff changeset
107 throws UnmappedAddressException, UnalignedAddressException, NotInHeapException;
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
108 public OopHandle getCompOopHandleAt (long offset)
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
109 throws UnmappedAddressException, UnalignedAddressException, NotInHeapException;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
110
a61af66fc99e Initial load
duke
parents:
diff changeset
111 //
a61af66fc99e Initial load
duke
parents:
diff changeset
112 // C/C++-related mutators. These throw UnmappedAddressException if
a61af66fc99e Initial load
duke
parents:
diff changeset
113 // the target is read-only (for example, a core file rather than an
a61af66fc99e Initial load
duke
parents:
diff changeset
114 // active process), if the target address is unmapped, or if it is
a61af66fc99e Initial load
duke
parents:
diff changeset
115 // read-only. The implementation may supply extra detail messages.
a61af66fc99e Initial load
duke
parents:
diff changeset
116 //
a61af66fc99e Initial load
duke
parents:
diff changeset
117
a61af66fc99e Initial load
duke
parents:
diff changeset
118 /** Sets a C integer numBytes in size at the specified offset. Note
a61af66fc99e Initial load
duke
parents:
diff changeset
119 that there is no "unsigned" flag for the accessor since the
a61af66fc99e Initial load
duke
parents:
diff changeset
120 value will not be sign-extended; the number of bytes are simply
a61af66fc99e Initial load
duke
parents:
diff changeset
121 copied from the value into the target address space. */
a61af66fc99e Initial load
duke
parents:
diff changeset
122 public void setCIntegerAt(long offset, long numBytes, long value);
a61af66fc99e Initial load
duke
parents:
diff changeset
123
a61af66fc99e Initial load
duke
parents:
diff changeset
124 /** Sets an Address at the specified location. */
a61af66fc99e Initial load
duke
parents:
diff changeset
125 public void setAddressAt(long offset, Address value);
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 -- see above.
a61af66fc99e Initial load
duke
parents:
diff changeset
129 //
a61af66fc99e Initial load
duke
parents:
diff changeset
130
a61af66fc99e Initial load
duke
parents:
diff changeset
131 public void setJBooleanAt (long offset, boolean value)
a61af66fc99e Initial load
duke
parents:
diff changeset
132 throws UnmappedAddressException, UnalignedAddressException;
a61af66fc99e Initial load
duke
parents:
diff changeset
133 public void setJByteAt (long offset, byte value)
a61af66fc99e Initial load
duke
parents:
diff changeset
134 throws UnmappedAddressException, UnalignedAddressException;
a61af66fc99e Initial load
duke
parents:
diff changeset
135 public void setJCharAt (long offset, char value)
a61af66fc99e Initial load
duke
parents:
diff changeset
136 throws UnmappedAddressException, UnalignedAddressException;
a61af66fc99e Initial load
duke
parents:
diff changeset
137 public void setJDoubleAt (long offset, double value)
a61af66fc99e Initial load
duke
parents:
diff changeset
138 throws UnmappedAddressException, UnalignedAddressException;
a61af66fc99e Initial load
duke
parents:
diff changeset
139 public void setJFloatAt (long offset, float value)
a61af66fc99e Initial load
duke
parents:
diff changeset
140 throws UnmappedAddressException, UnalignedAddressException;
a61af66fc99e Initial load
duke
parents:
diff changeset
141 public void setJIntAt (long offset, int value)
a61af66fc99e Initial load
duke
parents:
diff changeset
142 throws UnmappedAddressException, UnalignedAddressException;
a61af66fc99e Initial load
duke
parents:
diff changeset
143 public void setJLongAt (long offset, long value)
a61af66fc99e Initial load
duke
parents:
diff changeset
144 throws UnmappedAddressException, UnalignedAddressException;
a61af66fc99e Initial load
duke
parents:
diff changeset
145 public void setJShortAt (long offset, short value)
a61af66fc99e Initial load
duke
parents:
diff changeset
146 throws UnmappedAddressException, UnalignedAddressException;
a61af66fc99e Initial load
duke
parents:
diff changeset
147 public void setOopHandleAt (long offset, OopHandle value)
a61af66fc99e Initial load
duke
parents:
diff changeset
148 throws UnmappedAddressException, UnalignedAddressException;
a61af66fc99e Initial load
duke
parents:
diff changeset
149
a61af66fc99e Initial load
duke
parents:
diff changeset
150 //
a61af66fc99e Initial load
duke
parents:
diff changeset
151 // Arithmetic operations -- necessary evil.
a61af66fc99e Initial load
duke
parents:
diff changeset
152 //
a61af66fc99e Initial load
duke
parents:
diff changeset
153
a61af66fc99e Initial load
duke
parents:
diff changeset
154 /** This throws an UnsupportedOperationException if this address happens
a61af66fc99e Initial load
duke
parents:
diff changeset
155 to actually be an OopHandle, because interior object pointers
a61af66fc99e Initial load
duke
parents:
diff changeset
156 are not allowed. Negative offsets are allowed and handle the
a61af66fc99e Initial load
duke
parents:
diff changeset
157 subtraction case. */
a61af66fc99e Initial load
duke
parents:
diff changeset
158 public Address addOffsetTo (long offset) throws UnsupportedOperationException;
a61af66fc99e Initial load
duke
parents:
diff changeset
159
a61af66fc99e Initial load
duke
parents:
diff changeset
160 /** This method had to be added in order to support heap iteration
a61af66fc99e Initial load
duke
parents:
diff changeset
161 in the debugging system, and is effectively the dangerous
a61af66fc99e Initial load
duke
parents:
diff changeset
162 operation of allowing interior object pointers. For this reason
a61af66fc99e Initial load
duke
parents:
diff changeset
163 it was kept as a separate API and its use is forbidden in the
a61af66fc99e Initial load
duke
parents:
diff changeset
164 non-debugging (i.e., reflective system) case. It is strongly
a61af66fc99e Initial load
duke
parents:
diff changeset
165 recommended that this not be called by clients: it is currently
a61af66fc99e Initial load
duke
parents:
diff changeset
166 wrapped up in the Space's iteration mechanism. */
a61af66fc99e Initial load
duke
parents:
diff changeset
167 public OopHandle addOffsetToAsOopHandle(long offset) throws UnsupportedOperationException;
a61af66fc99e Initial load
duke
parents:
diff changeset
168
a61af66fc99e Initial load
duke
parents:
diff changeset
169 /** Performs the subtraction "this - arg", returning the resulting
a61af66fc99e Initial load
duke
parents:
diff changeset
170 offset in bytes. Note that this must handle a null argument
a61af66fc99e Initial load
duke
parents:
diff changeset
171 properly, and can be used to convert an Address into a long for
a61af66fc99e Initial load
duke
parents:
diff changeset
172 further manipulation, but that the reverse conversion is not
a61af66fc99e Initial load
duke
parents:
diff changeset
173 possible. (FIXME: any signed/unsigned issues? Should this work
a61af66fc99e Initial load
duke
parents:
diff changeset
174 for OopHandles?) */
a61af66fc99e Initial load
duke
parents:
diff changeset
175 public long minus(Address arg);
a61af66fc99e Initial load
duke
parents:
diff changeset
176
a61af66fc99e Initial load
duke
parents:
diff changeset
177 /** Performs unsigned comparison "this < arg".
a61af66fc99e Initial load
duke
parents:
diff changeset
178 (FIXME: should this work for OopHandles?) */
a61af66fc99e Initial load
duke
parents:
diff changeset
179 public boolean lessThan (Address arg);
a61af66fc99e Initial load
duke
parents:
diff changeset
180 /** Performs unsigned comparison "this <= arg".
a61af66fc99e Initial load
duke
parents:
diff changeset
181 (FIXME: should this work for OopHandles?) */
a61af66fc99e Initial load
duke
parents:
diff changeset
182 public boolean lessThanOrEqual (Address arg);
a61af66fc99e Initial load
duke
parents:
diff changeset
183 /** Performs unsigned comparison "this > arg".
a61af66fc99e Initial load
duke
parents:
diff changeset
184 (FIXME: should this work for OopHandles?) */
a61af66fc99e Initial load
duke
parents:
diff changeset
185 public boolean greaterThan (Address arg);
a61af66fc99e Initial load
duke
parents:
diff changeset
186 /** Performs unsigned comparison "this >= arg".
a61af66fc99e Initial load
duke
parents:
diff changeset
187 (FIXME: should this work for OopHandles?) */
a61af66fc99e Initial load
duke
parents:
diff changeset
188 public boolean greaterThanOrEqual(Address arg);
a61af66fc99e Initial load
duke
parents:
diff changeset
189
a61af66fc99e Initial load
duke
parents:
diff changeset
190 /** This throws an UnsupportedOperationException if this address happens
a61af66fc99e Initial load
duke
parents:
diff changeset
191 to actually be an OopHandle. Performs a logical "and" operation
a61af66fc99e Initial load
duke
parents:
diff changeset
192 of the bits of the address and the mask (least significant bits
a61af66fc99e Initial load
duke
parents:
diff changeset
193 of the Address and the mask are aligned) and returns the result
a61af66fc99e Initial load
duke
parents:
diff changeset
194 as an Address. Returns null if the result was zero. */
a61af66fc99e Initial load
duke
parents:
diff changeset
195 public Address andWithMask(long mask) throws UnsupportedOperationException;
a61af66fc99e Initial load
duke
parents:
diff changeset
196
a61af66fc99e Initial load
duke
parents:
diff changeset
197 /** This throws an UnsupportedOperationException if this address happens
a61af66fc99e Initial load
duke
parents:
diff changeset
198 to actually be an OopHandle. Performs a logical "or" operation
a61af66fc99e Initial load
duke
parents:
diff changeset
199 of the bits of the address and the mask (least significant bits
a61af66fc99e Initial load
duke
parents:
diff changeset
200 of the Address and the mask are aligned) and returns the result
a61af66fc99e Initial load
duke
parents:
diff changeset
201 as an Address. Returns null if the result was zero. */
a61af66fc99e Initial load
duke
parents:
diff changeset
202 public Address orWithMask(long mask) throws UnsupportedOperationException;
a61af66fc99e Initial load
duke
parents:
diff changeset
203
a61af66fc99e Initial load
duke
parents:
diff changeset
204 /** This throws an UnsupportedOperationException if this address happens
a61af66fc99e Initial load
duke
parents:
diff changeset
205 to actually be an OopHandle. Performs a logical "exclusive or"
a61af66fc99e Initial load
duke
parents:
diff changeset
206 operation of the bits of the address and the mask (least
a61af66fc99e Initial load
duke
parents:
diff changeset
207 significant bits of the Address and the mask are aligned) and
a61af66fc99e Initial load
duke
parents:
diff changeset
208 returns the result as an Address. Returns null if the result was
a61af66fc99e Initial load
duke
parents:
diff changeset
209 zero. */
a61af66fc99e Initial load
duke
parents:
diff changeset
210 public Address xorWithMask(long mask) throws UnsupportedOperationException;
a61af66fc99e Initial load
duke
parents:
diff changeset
211 }