annotate agent/src/share/classes/sun/jvm/hotspot/debugger/Address.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 2000-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;
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;
a61af66fc99e Initial load
duke
parents:
diff changeset
90
a61af66fc99e Initial load
duke
parents:
diff changeset
91 //
a61af66fc99e Initial load
duke
parents:
diff changeset
92 // Java-related routines
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 boolean getJBooleanAt (long offset) throws UnmappedAddressException, UnalignedAddressException;
a61af66fc99e Initial load
duke
parents:
diff changeset
96 public byte getJByteAt (long offset) throws UnmappedAddressException, UnalignedAddressException;
a61af66fc99e Initial load
duke
parents:
diff changeset
97 public char getJCharAt (long offset) throws UnmappedAddressException, UnalignedAddressException;
a61af66fc99e Initial load
duke
parents:
diff changeset
98 public double getJDoubleAt (long offset) throws UnmappedAddressException, UnalignedAddressException;
a61af66fc99e Initial load
duke
parents:
diff changeset
99 public float getJFloatAt (long offset) throws UnmappedAddressException, UnalignedAddressException;
a61af66fc99e Initial load
duke
parents:
diff changeset
100 public int getJIntAt (long offset) throws UnmappedAddressException, UnalignedAddressException;
a61af66fc99e Initial load
duke
parents:
diff changeset
101 public long getJLongAt (long offset) throws UnmappedAddressException, UnalignedAddressException;
a61af66fc99e Initial load
duke
parents:
diff changeset
102 public short getJShortAt (long offset) throws UnmappedAddressException, UnalignedAddressException;
a61af66fc99e Initial load
duke
parents:
diff changeset
103 /** This returns null if the address at the given offset is NULL. */
a61af66fc99e Initial load
duke
parents:
diff changeset
104 public OopHandle getOopHandleAt (long offset)
a61af66fc99e Initial load
duke
parents:
diff changeset
105 throws UnmappedAddressException, UnalignedAddressException, NotInHeapException;
a61af66fc99e Initial load
duke
parents:
diff changeset
106
a61af66fc99e Initial load
duke
parents:
diff changeset
107 //
a61af66fc99e Initial load
duke
parents:
diff changeset
108 // C/C++-related mutators. These throw UnmappedAddressException if
a61af66fc99e Initial load
duke
parents:
diff changeset
109 // the target is read-only (for example, a core file rather than an
a61af66fc99e Initial load
duke
parents:
diff changeset
110 // active process), if the target address is unmapped, or if it is
a61af66fc99e Initial load
duke
parents:
diff changeset
111 // read-only. The implementation may supply extra detail messages.
a61af66fc99e Initial load
duke
parents:
diff changeset
112 //
a61af66fc99e Initial load
duke
parents:
diff changeset
113
a61af66fc99e Initial load
duke
parents:
diff changeset
114 /** Sets a C integer numBytes in size at the specified offset. Note
a61af66fc99e Initial load
duke
parents:
diff changeset
115 that there is no "unsigned" flag for the accessor since the
a61af66fc99e Initial load
duke
parents:
diff changeset
116 value will not be sign-extended; the number of bytes are simply
a61af66fc99e Initial load
duke
parents:
diff changeset
117 copied from the value into the target address space. */
a61af66fc99e Initial load
duke
parents:
diff changeset
118 public void setCIntegerAt(long offset, long numBytes, long value);
a61af66fc99e Initial load
duke
parents:
diff changeset
119
a61af66fc99e Initial load
duke
parents:
diff changeset
120 /** Sets an Address at the specified location. */
a61af66fc99e Initial load
duke
parents:
diff changeset
121 public void setAddressAt(long offset, Address value);
a61af66fc99e Initial load
duke
parents:
diff changeset
122
a61af66fc99e Initial load
duke
parents:
diff changeset
123 //
a61af66fc99e Initial load
duke
parents:
diff changeset
124 // Java-related mutators -- see above.
a61af66fc99e Initial load
duke
parents:
diff changeset
125 //
a61af66fc99e Initial load
duke
parents:
diff changeset
126
a61af66fc99e Initial load
duke
parents:
diff changeset
127 public void setJBooleanAt (long offset, boolean value)
a61af66fc99e Initial load
duke
parents:
diff changeset
128 throws UnmappedAddressException, UnalignedAddressException;
a61af66fc99e Initial load
duke
parents:
diff changeset
129 public void setJByteAt (long offset, byte value)
a61af66fc99e Initial load
duke
parents:
diff changeset
130 throws UnmappedAddressException, UnalignedAddressException;
a61af66fc99e Initial load
duke
parents:
diff changeset
131 public void setJCharAt (long offset, char value)
a61af66fc99e Initial load
duke
parents:
diff changeset
132 throws UnmappedAddressException, UnalignedAddressException;
a61af66fc99e Initial load
duke
parents:
diff changeset
133 public void setJDoubleAt (long offset, double value)
a61af66fc99e Initial load
duke
parents:
diff changeset
134 throws UnmappedAddressException, UnalignedAddressException;
a61af66fc99e Initial load
duke
parents:
diff changeset
135 public void setJFloatAt (long offset, float value)
a61af66fc99e Initial load
duke
parents:
diff changeset
136 throws UnmappedAddressException, UnalignedAddressException;
a61af66fc99e Initial load
duke
parents:
diff changeset
137 public void setJIntAt (long offset, int value)
a61af66fc99e Initial load
duke
parents:
diff changeset
138 throws UnmappedAddressException, UnalignedAddressException;
a61af66fc99e Initial load
duke
parents:
diff changeset
139 public void setJLongAt (long offset, long value)
a61af66fc99e Initial load
duke
parents:
diff changeset
140 throws UnmappedAddressException, UnalignedAddressException;
a61af66fc99e Initial load
duke
parents:
diff changeset
141 public void setJShortAt (long offset, short value)
a61af66fc99e Initial load
duke
parents:
diff changeset
142 throws UnmappedAddressException, UnalignedAddressException;
a61af66fc99e Initial load
duke
parents:
diff changeset
143 public void setOopHandleAt (long offset, OopHandle value)
a61af66fc99e Initial load
duke
parents:
diff changeset
144 throws UnmappedAddressException, UnalignedAddressException;
a61af66fc99e Initial load
duke
parents:
diff changeset
145
a61af66fc99e Initial load
duke
parents:
diff changeset
146 //
a61af66fc99e Initial load
duke
parents:
diff changeset
147 // Arithmetic operations -- necessary evil.
a61af66fc99e Initial load
duke
parents:
diff changeset
148 //
a61af66fc99e Initial load
duke
parents:
diff changeset
149
a61af66fc99e Initial load
duke
parents:
diff changeset
150 /** This throws an UnsupportedOperationException if this address happens
a61af66fc99e Initial load
duke
parents:
diff changeset
151 to actually be an OopHandle, because interior object pointers
a61af66fc99e Initial load
duke
parents:
diff changeset
152 are not allowed. Negative offsets are allowed and handle the
a61af66fc99e Initial load
duke
parents:
diff changeset
153 subtraction case. */
a61af66fc99e Initial load
duke
parents:
diff changeset
154 public Address addOffsetTo (long offset) throws UnsupportedOperationException;
a61af66fc99e Initial load
duke
parents:
diff changeset
155
a61af66fc99e Initial load
duke
parents:
diff changeset
156 /** This method had to be added in order to support heap iteration
a61af66fc99e Initial load
duke
parents:
diff changeset
157 in the debugging system, and is effectively the dangerous
a61af66fc99e Initial load
duke
parents:
diff changeset
158 operation of allowing interior object pointers. For this reason
a61af66fc99e Initial load
duke
parents:
diff changeset
159 it was kept as a separate API and its use is forbidden in the
a61af66fc99e Initial load
duke
parents:
diff changeset
160 non-debugging (i.e., reflective system) case. It is strongly
a61af66fc99e Initial load
duke
parents:
diff changeset
161 recommended that this not be called by clients: it is currently
a61af66fc99e Initial load
duke
parents:
diff changeset
162 wrapped up in the Space's iteration mechanism. */
a61af66fc99e Initial load
duke
parents:
diff changeset
163 public OopHandle addOffsetToAsOopHandle(long offset) throws UnsupportedOperationException;
a61af66fc99e Initial load
duke
parents:
diff changeset
164
a61af66fc99e Initial load
duke
parents:
diff changeset
165 /** Performs the subtraction "this - arg", returning the resulting
a61af66fc99e Initial load
duke
parents:
diff changeset
166 offset in bytes. Note that this must handle a null argument
a61af66fc99e Initial load
duke
parents:
diff changeset
167 properly, and can be used to convert an Address into a long for
a61af66fc99e Initial load
duke
parents:
diff changeset
168 further manipulation, but that the reverse conversion is not
a61af66fc99e Initial load
duke
parents:
diff changeset
169 possible. (FIXME: any signed/unsigned issues? Should this work
a61af66fc99e Initial load
duke
parents:
diff changeset
170 for OopHandles?) */
a61af66fc99e Initial load
duke
parents:
diff changeset
171 public long minus(Address arg);
a61af66fc99e Initial load
duke
parents:
diff changeset
172
a61af66fc99e Initial load
duke
parents:
diff changeset
173 /** Performs unsigned comparison "this < arg".
a61af66fc99e Initial load
duke
parents:
diff changeset
174 (FIXME: should this work for OopHandles?) */
a61af66fc99e Initial load
duke
parents:
diff changeset
175 public boolean lessThan (Address arg);
a61af66fc99e Initial load
duke
parents:
diff changeset
176 /** Performs unsigned comparison "this <= arg".
a61af66fc99e Initial load
duke
parents:
diff changeset
177 (FIXME: should this work for OopHandles?) */
a61af66fc99e Initial load
duke
parents:
diff changeset
178 public boolean lessThanOrEqual (Address arg);
a61af66fc99e Initial load
duke
parents:
diff changeset
179 /** Performs unsigned comparison "this > arg".
a61af66fc99e Initial load
duke
parents:
diff changeset
180 (FIXME: should this work for OopHandles?) */
a61af66fc99e Initial load
duke
parents:
diff changeset
181 public boolean greaterThan (Address arg);
a61af66fc99e Initial load
duke
parents:
diff changeset
182 /** Performs unsigned comparison "this >= arg".
a61af66fc99e Initial load
duke
parents:
diff changeset
183 (FIXME: should this work for OopHandles?) */
a61af66fc99e Initial load
duke
parents:
diff changeset
184 public boolean greaterThanOrEqual(Address arg);
a61af66fc99e Initial load
duke
parents:
diff changeset
185
a61af66fc99e Initial load
duke
parents:
diff changeset
186 /** This throws an UnsupportedOperationException if this address happens
a61af66fc99e Initial load
duke
parents:
diff changeset
187 to actually be an OopHandle. Performs a logical "and" operation
a61af66fc99e Initial load
duke
parents:
diff changeset
188 of the bits of the address and the mask (least significant bits
a61af66fc99e Initial load
duke
parents:
diff changeset
189 of the Address and the mask are aligned) and returns the result
a61af66fc99e Initial load
duke
parents:
diff changeset
190 as an Address. Returns null if the result was zero. */
a61af66fc99e Initial load
duke
parents:
diff changeset
191 public Address andWithMask(long mask) throws UnsupportedOperationException;
a61af66fc99e Initial load
duke
parents:
diff changeset
192
a61af66fc99e Initial load
duke
parents:
diff changeset
193 /** This throws an UnsupportedOperationException if this address happens
a61af66fc99e Initial load
duke
parents:
diff changeset
194 to actually be an OopHandle. Performs a logical "or" operation
a61af66fc99e Initial load
duke
parents:
diff changeset
195 of the bits of the address and the mask (least significant bits
a61af66fc99e Initial load
duke
parents:
diff changeset
196 of the Address and the mask are aligned) and returns the result
a61af66fc99e Initial load
duke
parents:
diff changeset
197 as an Address. Returns null if the result was zero. */
a61af66fc99e Initial load
duke
parents:
diff changeset
198 public Address orWithMask(long mask) throws UnsupportedOperationException;
a61af66fc99e Initial load
duke
parents:
diff changeset
199
a61af66fc99e Initial load
duke
parents:
diff changeset
200 /** This throws an UnsupportedOperationException if this address happens
a61af66fc99e Initial load
duke
parents:
diff changeset
201 to actually be an OopHandle. Performs a logical "exclusive or"
a61af66fc99e Initial load
duke
parents:
diff changeset
202 operation of the bits of the address and the mask (least
a61af66fc99e Initial load
duke
parents:
diff changeset
203 significant bits of the Address and the mask are aligned) and
a61af66fc99e Initial load
duke
parents:
diff changeset
204 returns the result as an Address. Returns null if the result was
a61af66fc99e Initial load
duke
parents:
diff changeset
205 zero. */
a61af66fc99e Initial load
duke
parents:
diff changeset
206 public Address xorWithMask(long mask) throws UnsupportedOperationException;
a61af66fc99e Initial load
duke
parents:
diff changeset
207 }