/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
/** <P> DebuggerBase is a recommended base class for debugger
implementations. It can use a PageCache to cache data from the
target process. Note that this class would not be suitable if the
system were used to reflect upon itself; it would never be safe to
store the value in an OopHandle in anything but an OopHandle.
However, it provides a fair amount of code sharing to the current
dbx and win32 implementations. </P>
<P> NOTE that much of the code sharing is achieved by having this
class implement many of the methods in the Win32Debugger and
DbxDebugger interfaces. </P> */
// May be set lazily, but must be set before calling any of the read
// routines below
// Java primitive type sizes, set during bootstrapping. Do not call
// any of the Java read routines until these are set up.
protected long jbooleanSize;
protected long jbyteSize;
protected long jcharSize;
protected long jdoubleSize;
protected long jfloatSize;
protected long jintSize;
protected long jlongSize;
protected long jshortSize;
protected boolean javaPrimitiveTypesConfigured;
// heap data.
protected long oopSize;
protected long heapOopSize;
// Should be initialized if desired by calling initCache()
// State for faster accessors that don't allocate memory on each read
private boolean useFastAccessors;
private boolean bigEndian;
// Page-fetching functionality for LRU cache
// This assumes that if any byte is unmapped, that the entire
// page is. The common case, however, is that the page is
// mapped, so we always fetch the entire thing all at once to
// avoid two round-trip communications per page fetch, even
// though fetching of unmapped pages will be slow.
}
}
}
protected DebuggerBase() {
}
/** From the JVMDebugger interface. This is the only public method
of this class. */
long jbyteSize,
long jcharSize,
long jdoubleSize,
long jfloatSize,
long jintSize,
long jlongSize,
long jshortSize) {
this.jbooleanSize = jbooleanSize;
this.jdoubleSize = jdoubleSize;
this.jfloatSize = jfloatSize;
this.jshortSize = jshortSize;
if (jbooleanSize < 1) {
throw new RuntimeException("jboolean size is too small");
}
if (jbyteSize < 1) {
throw new RuntimeException("jbyte size is too small");
}
if (jcharSize < 2) {
throw new RuntimeException("jchar size is too small");
}
if (jdoubleSize < 8) {
throw new RuntimeException("jdouble size is too small");
}
if (jfloatSize < 4) {
throw new RuntimeException("jfloat size is too small");
}
if (jintSize < 4) {
throw new RuntimeException("jint size is too small");
}
if (jlongSize < 8) {
throw new RuntimeException("jlong size is too small");
}
if (jshortSize < 2) {
throw new RuntimeException("jshort size is too small");
}
if (jintSize != jfloatSize) {
// If dataToJFloat were rewritten, this wouldn't be necessary
throw new RuntimeException("jint size and jfloat size must be equal");
}
if (jlongSize != jdoubleSize) {
// If dataToJDouble were rewritten, this wouldn't be necessary
throw new RuntimeException("jlong size and jdouble size must be equal");
}
(jbooleanSize == 1) &&
(jbyteSize == 1) &&
(jcharSize == 2) &&
(jdoubleSize == 8) &&
(jfloatSize == 4) &&
(jintSize == 4) &&
(jlongSize == 8) &&
(jshortSize == 2));
javaPrimitiveTypesConfigured = true;
}
this.heapOopSize = heapOopSize;
this.narrowOopBase = narrowOopBase;
this.narrowOopShift = narrowOopShift;
}
/** May be called by subclasses if desired to initialize the page
cache but may not be overridden */
}
}
/** May be called by subclasses if needed (if the machine
description is not available at the time of cache
initialization, as on Solaris) but may not be overridden */
}
/** May be called by subclasses to clear out the cache but may not
be overridden. For convenience, this can be called even if the
cache has not been initialized. */
protected final void clearCache() {
}
}
/** May be called by subclasses to disable the cache (for example,
when the target process has been resumed) but may not be
overridden. For convenience, this can be called even if the
cache has not been initialized. */
protected final void disableCache() {
}
}
/** May be called by subclasses to re-enable the cache (for example,
when the target process has been suspended) but may not be
overridden. For convenience, this can be called even if the
cache has not been initialized. */
protected final void enableCache() {
}
}
/** May be called by subclasses directly but may not be overridden */
throws UnmappedAddressException, DebuggerException {
} else {
}
}
}
/** May be called by subclasses directly but may not be overridden */
throws UnmappedAddressException, DebuggerException {
}
}
if (useFastAccessors) {
} else {
}
}
if (useFastAccessors) {
} else {
}
}
// NOTE: assumes value does not span pages (may be bad assumption on
if (useFastAccessors) {
} else {
}
}
// NOTE: assumes value does not span pages (may be bad assumption on
if (useFastAccessors) {
} else {
}
}
// NOTE: assumes value does not span pages (may be bad assumption on
if (useFastAccessors) {
} else {
}
}
// NOTE: assumes value does not span pages (may be bad assumption on
if (useFastAccessors) {
} else {
}
}
// NOTE: assumes value does not span pages (may be bad assumption on
if (useFastAccessors) {
} else {
}
}
// NOTE: assumes value does not span pages (may be bad assumption on
if (useFastAccessors) {
} else {
}
}
// NOTE: assumes value does not span pages (may be bad assumption on
if (useFastAccessors) {
if (isUnsigned) {
switch((int) numBytes) {
default: {
}
}
} else {
switch((int) numBytes) {
default: {
}
}
}
} else {
}
}
}
}
}
}
}
}
}
}
}
}
if (value != 0) {
// See oop.inline.hpp decode_heap_oop
}
return value;
}
}
/** Can be called by subclasses but can not be overridden */
protected final void checkConfigured() {
throw new RuntimeException("MachineDescription must have been set by this point");
}
throw new RuntimeException("DebuggerUtilities must have been set by this point");
}
}
/** Can be called by subclasses but can not be overridden */
protected final void checkJavaConfigured() {
if (!javaPrimitiveTypesConfigured) {
throw new RuntimeException("Java primitive type sizes have not yet been configured");
}
}
/** Possibly override page cache size with user-specified property */
if (cacheNumPagesString != null) {
try {
} catch (Exception e) {
e.printStackTrace();
}
}
return defaultNum;
}
/** Interim solution for allowing subclasses to write bytes to
process until we make that functionality available in the basic
Address interface */
}
public long getJBooleanSize() {
return jbooleanSize;
}
public long getJByteSize() {
return jbyteSize;
}
public long getJCharSize() {
return jcharSize;
}
public long getJDoubleSize() {
return jdoubleSize;
}
public long getJFloatSize() {
return jfloatSize;
}
public long getJIntSize() {
return jintSize;
}
public long getJLongSize() {
return jlongSize;
}
public long getJShortSize() {
return jshortSize;
}
public long getHeapOopSize() {
return heapOopSize;
}
public long getNarrowOopBase() {
return narrowOopBase;
}
public int getNarrowOopShift() {
return narrowOopShift;
}
}