Top Description Fields Constructors Methods
sun.jvm.hotspot.types.basic

public Class BasicTypeDataBase

extends Object
implements TypeDataBase
Class Inheritance
All Implemented Interfaces
sun.jvm.hotspot.types.TypeDataBase
Known Direct Subclasses
sun.jvm.hotspot.HotSpotTypeDataBase
Imports
java.util.HashMap, .Iterator, .Map, sun.jvm.hotspot.debugger.Address, .MachineDescription, sun.jvm.hotspot.runtime.VM, sun.jvm.hotspot.types.Type, .TypeDataBase, sun.jvm.hotspot.memory.FileMapInfo

This is a basic implementation of the TypeDataBase interface. It allows an external type database builder to add types to be consumed by a client through the Type interfaces. It has no knowledge of symbol lookup; for example, the builder is responsible for providing the addresses of static fields.

Among other things, the database builder is responsible for providing the Types for the Java primitive types, as well as their sizes.

Field Summary

Modifier and TypeField and Description
private static final boolean
DEBUG

For debugging

private Type
jbooleanType

Primitive types.

private Type
private Type
private Type
private Type
private Type
private Type
private Type
private MachineDescription
private Map<String, Integer>
nameToIntConstantMap

Maps strings to Integers, used for enums, etc.

private Map<String, Long>
nameToLongConstantMap

Maps strings to Longs, used for 32/64-bit constants, etc.

private Map<String, Type>
nameToTypeMap

Maps strings to Type objects.

private Map<Type, Address>
private VtblAccess

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
addIntConstant(String name, int value)

This method should only be used by the builder of the TypeDataBase.

public void
addLongConstant(String name, long value)

This method should only be used by the builder of the TypeDataBase.

public boolean
addressTypeIsEqualToType(Address addr, Type type)

Implements sun.jvm.hotspot.types.TypeDataBase.addressTypeIsEqualToType.

This is an experimental interface emulating C++'s run-time type information (RTTI) mechanism: determines whether the given address is a pointer to the start of a C++ object of precisely the given type -- it does not search superclasses of the type.

public void
addType(Type type)

This method should only be used by the builder of the TypeDataBase.

public long
cIntegerTypeMaxValue(long sizeInBytes, boolean isUnsigned)

public long
cIntegerTypeMinValue(long sizeInBytes, boolean isUnsigned)

public Type
findDynamicTypeForAddress(Address addr, Type baseType)

Implements sun.jvm.hotspot.types.TypeDataBase.findDynamicTypeForAddress.

Helper routine for guessing the most derived type of a polymorphic C++ object.
public long
getAddressSize()

Implements sun.jvm.hotspot.types.TypeDataBase.getAddressSize.

Returns the size of a C address in bytes.
public Iterator<E>
getIntConstants()

Implements sun.jvm.hotspot.types.TypeDataBase.getIntConstants.

Returns an Iterator over the String names of the integer constants in the database.
public Type
getJBooleanType()

Implements sun.jvm.hotspot.types.TypeDataBase.getJBooleanType.

Accessors for types representing the Java primitive types; used for both proper type checking and for walking down Java arrays.
public Type
public Type
public Type
public Type
public Type
public Type
public Type
public Iterator<E>
getLongConstants()

Implements sun.jvm.hotspot.types.TypeDataBase.getLongConstants.

Returns an Iterator over the String names of the long constants in the database.
public long
getOopSize()

Implements sun.jvm.hotspot.types.TypeDataBase.getOopSize.

Returns the size of an oop in bytes.
public Iterator<E>
getTypes()

Implements sun.jvm.hotspot.types.TypeDataBase.getTypes.

Returns an Iterator over the Types in the database.
public Type
guessTypeForAddress(Address addr)

Implements sun.jvm.hotspot.types.TypeDataBase.guessTypeForAddress.

Helper routine for guessing the most derived type of a polymorphic C++ object.
public Integer
lookupIntConstant(String constantName)

Implements sun.jvm.hotspot.types.TypeDataBase.lookupIntConstant.

Equivalent to lookupIntConstant(constantName, true)
public Integer
lookupIntConstant(String constantName, boolean throwException)

Implements sun.jvm.hotspot.types.TypeDataBase.lookupIntConstant.

public Long
lookupLongConstant(String constantName)

Implements sun.jvm.hotspot.types.TypeDataBase.lookupLongConstant.

Equivalent to lookupLongConstant(constantName, true)
public Long
lookupLongConstant(String constantName, boolean throwException)

Implements sun.jvm.hotspot.types.TypeDataBase.lookupLongConstant.

public Type
lookupType(String cTypeName)

Implements sun.jvm.hotspot.types.TypeDataBase.lookupType.

Equivalent to lookupType(cTypeName, true)
public Type
lookupType(String cTypeName, boolean throwException)

Implements sun.jvm.hotspot.types.TypeDataBase.lookupType.

For simplicity of the initial implementation, this is not guaranteed to work for primitive types.
public void
removeIntConstant(String name)

This method should only be used by the builder of the TypeDataBase.

public void
removeLongConstant(String name)

This method should only be used by the builder of the TypeDataBase.

public void
removeType(Type type)

This method should only be used by the builder of the TypeDataBase.

public void
setJBooleanType(Type type)

This method should only be called by the builder of the TypeDataBase and at most once

public void
setJByteType(Type type)

This method should only be called by the builder of the TypeDataBase and at most once

public void
setJCharType(Type type)

This method should only be called by the builder of the TypeDataBase and at most once

public void
setJDoubleType(Type type)

This method should only be called by the builder of the TypeDataBase and at most once

public void
setJFloatType(Type type)

This method should only be called by the builder of the TypeDataBase and at most once

public void
setJIntType(Type type)

This method should only be called by the builder of the TypeDataBase and at most once

public void
setJLongType(Type type)

This method should only be called by the builder of the TypeDataBase and at most once

public void
setJShortType(Type type)

This method should only be called by the builder of the TypeDataBase and at most once

public Address
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEBUGback to summary
private static final boolean DEBUG

For debugging

jbooleanTypeback to summary
private Type jbooleanType

Primitive types.

jbyteTypeback to summary
private Type jbyteType
jcharTypeback to summary
private Type jcharType
jdoubleTypeback to summary
private Type jdoubleType
jfloatTypeback to summary
private Type jfloatType
jintTypeback to summary
private Type jintType
jlongTypeback to summary
private Type jlongType
jshortTypeback to summary
private Type jshortType
machDescback to summary
private MachineDescription machDesc
nameToIntConstantMapback to summary
private Map<String, Integer> nameToIntConstantMap

Maps strings to Integers, used for enums, etc.

nameToLongConstantMapback to summary
private Map<String, Long> nameToLongConstantMap

Maps strings to Longs, used for 32/64-bit constants, etc.

nameToTypeMapback to summary
private Map<String, Type> nameToTypeMap

Maps strings to Type objects. This does not contain the primitive types.

typeToVtblback to summary
private Map<Type, Address> typeToVtbl
vtblAccessback to summary
private VtblAccess vtblAccess

Constructor Detail

BasicTypeDataBaseback to summary
public BasicTypeDataBase(MachineDescription machDesc, VtblAccess vtblAccess)

Method Detail

addIntConstantback to summary
public void addIntConstant(String name, int value)

This method should only be used by the builder of the TypeDataBase. Throws a RuntimeException if an integer constant with this name was already present.

addLongConstantback to summary
public void addLongConstant(String name, long value)

This method should only be used by the builder of the TypeDataBase. Throws a RuntimeException if a long constant with this name was already present.

addressTypeIsEqualToTypeback to summary
public boolean addressTypeIsEqualToType(Address addr, Type type)

Implements sun.jvm.hotspot.types.TypeDataBase.addressTypeIsEqualToType.

Doc from sun.jvm.hotspot.types.TypeDataBase.addressTypeIsEqualToType.

This is an experimental interface emulating C++'s run-time type information (RTTI) mechanism: determines whether the given address is a pointer to the start of a C++ object of precisely the given type -- it does not search superclasses of the type. The convention is that this returns false for the null pointer. It is needed to allow wrapper Java objects of the appropriate type to be constructed for existing C++ objects of polymorphic type. This method is only intended to work for C++ types (implying that we should rename this package and the classes contained within back to "ctypes"). Further, since the vptr offset in an object is known at compile time but not necessarily at runtime (unless debugging information is available), it is reasonable for an implementation of this method to search nearby memory for the (known) vtbl value for the given type. For this reason, this method is not intended to support scans through memory finding C++ objects, but is instead targeted towards discovering the true type of a pointer assumed to be intact.

The reason this method was placed in the type database is that the latter is the first level at which it could be exposed, and placing it here could avoid modifying the Type interface. It is unclear what other, if any, vtbl access would be useful (or implementable), so we are trying to avoid changing interfaces at this point to support this kind of functionality.

This method necessarily does not support multiple inheritance.

addTypeback to summary
public void addType(Type type)

This method should only be used by the builder of the TypeDataBase. Throws a RuntimeException if a class with this name was already present.

cIntegerTypeMaxValueback to summary
public long cIntegerTypeMaxValue(long sizeInBytes, boolean isUnsigned)
cIntegerTypeMinValueback to summary
public long cIntegerTypeMinValue(long sizeInBytes, boolean isUnsigned)
findDynamicTypeForAddressback to summary
public Type findDynamicTypeForAddress(Address addr, Type baseType)

Implements sun.jvm.hotspot.types.TypeDataBase.findDynamicTypeForAddress.

Doc from sun.jvm.hotspot.types.TypeDataBase.findDynamicTypeForAddress.

Helper routine for guessing the most derived type of a polymorphic C++ object. Requires a baseType that must be virtual so that lookup can be performed without false positives

getAddressSizeback to summary
public long getAddressSize()

Implements sun.jvm.hotspot.types.TypeDataBase.getAddressSize.

Doc from sun.jvm.hotspot.types.TypeDataBase.getAddressSize.

Returns the size of a C address in bytes. This is currently needed in order to properly traverse an array of pointers. Traversing an array of structs, for example, is possible by looking up the type of the struct and multiplying the index by its size when indexing off of a base Address. (FIXME: what about alignment?)

getIntConstantsback to summary
public Iterator<E> getIntConstants()

Implements sun.jvm.hotspot.types.TypeDataBase.getIntConstants.

Doc from sun.jvm.hotspot.types.TypeDataBase.getIntConstants.

Returns an Iterator over the String names of the integer constants in the database.

getJBooleanTypeback to summary
public Type getJBooleanType()

Implements sun.jvm.hotspot.types.TypeDataBase.getJBooleanType.

Doc from sun.jvm.hotspot.types.TypeDataBase.getJBooleanType.

Accessors for types representing the Java primitive types; used for both proper type checking and for walking down Java arrays.

getJByteTypeback to summary
public Type getJByteType()

Implements sun.jvm.hotspot.types.TypeDataBase.getJByteType.

getJCharTypeback to summary
public Type getJCharType()

Implements sun.jvm.hotspot.types.TypeDataBase.getJCharType.

getJDoubleTypeback to summary
public Type getJDoubleType()

Implements sun.jvm.hotspot.types.TypeDataBase.getJDoubleType.

getJFloatTypeback to summary
public Type getJFloatType()

Implements sun.jvm.hotspot.types.TypeDataBase.getJFloatType.

getJIntTypeback to summary
public Type getJIntType()

Implements sun.jvm.hotspot.types.TypeDataBase.getJIntType.

getJLongTypeback to summary
public Type getJLongType()

Implements sun.jvm.hotspot.types.TypeDataBase.getJLongType.

getJShortTypeback to summary
public Type getJShortType()

Implements sun.jvm.hotspot.types.TypeDataBase.getJShortType.

getLongConstantsback to summary
public Iterator<E> getLongConstants()

Implements sun.jvm.hotspot.types.TypeDataBase.getLongConstants.

Doc from sun.jvm.hotspot.types.TypeDataBase.getLongConstants.

Returns an Iterator over the String names of the long constants in the database.

getOopSizeback to summary
public long getOopSize()

Implements sun.jvm.hotspot.types.TypeDataBase.getOopSize.

Doc from sun.jvm.hotspot.types.TypeDataBase.getOopSize.

Returns the size of an oop in bytes. This is currently needed in order to properly traverse an array of oops; it is distinguished from the address size, above, because object pointers could conceivably have a different representation than direct pointers. Traversing an array of structs, for example, is possible by looking up the type of the struct and multiplying the index by its size when indexing off of a base Address.

getTypesback to summary
public Iterator<E> getTypes()

Implements sun.jvm.hotspot.types.TypeDataBase.getTypes.

Doc from sun.jvm.hotspot.types.TypeDataBase.getTypes.

Returns an Iterator over the Types in the database.

guessTypeForAddressback to summary
public Type guessTypeForAddress(Address addr)

Implements sun.jvm.hotspot.types.TypeDataBase.guessTypeForAddress.

Doc from sun.jvm.hotspot.types.TypeDataBase.guessTypeForAddress.

Helper routine for guessing the most derived type of a polymorphic C++ object. Iterates the type database calling addressTypeIsEqualToType for all known types. Returns a matching Type for the given address if one was found, or null if none was found.

lookupIntConstantback to summary
public Integer lookupIntConstant(String constantName)

Implements sun.jvm.hotspot.types.TypeDataBase.lookupIntConstant.

Doc from sun.jvm.hotspot.types.TypeDataBase.lookupIntConstant.

Equivalent to lookupIntConstant(constantName, true)

lookupIntConstantback to summary
public Integer lookupIntConstant(String constantName, boolean throwException)

Implements sun.jvm.hotspot.types.TypeDataBase.lookupIntConstant.

lookupLongConstantback to summary
public Long lookupLongConstant(String constantName)

Implements sun.jvm.hotspot.types.TypeDataBase.lookupLongConstant.

Doc from sun.jvm.hotspot.types.TypeDataBase.lookupLongConstant.

Equivalent to lookupLongConstant(constantName, true)

lookupLongConstantback to summary
public Long lookupLongConstant(String constantName, boolean throwException)

Implements sun.jvm.hotspot.types.TypeDataBase.lookupLongConstant.

lookupTypeback to summary
public Type lookupType(String cTypeName)

Implements sun.jvm.hotspot.types.TypeDataBase.lookupType.

Doc from sun.jvm.hotspot.types.TypeDataBase.lookupType.

Equivalent to lookupType(cTypeName, true)

lookupTypeback to summary
public Type lookupType(String cTypeName, boolean throwException)

Implements sun.jvm.hotspot.types.TypeDataBase.lookupType.

Doc from sun.jvm.hotspot.types.TypeDataBase.lookupType.

For simplicity of the initial implementation, this is not guaranteed to work for primitive types. If throwException is true, throws an (unspecified) run-time exception if the type is not found.

removeIntConstantback to summary
public void removeIntConstant(String name)

This method should only be used by the builder of the TypeDataBase. Throws a RuntimeException if an integer constant with this name was not present.

removeLongConstantback to summary
public void removeLongConstant(String name)

This method should only be used by the builder of the TypeDataBase. Throws a RuntimeException if a long constant with this name was not present.

removeTypeback to summary
public void removeType(Type type)

This method should only be used by the builder of the TypeDataBase. Throws a RuntimeException if this class was not present.

setJBooleanTypeback to summary
public void setJBooleanType(Type type)

This method should only be called by the builder of the TypeDataBase and at most once

setJByteTypeback to summary
public void setJByteType(Type type)

This method should only be called by the builder of the TypeDataBase and at most once

setJCharTypeback to summary
public void setJCharType(Type type)

This method should only be called by the builder of the TypeDataBase and at most once

setJDoubleTypeback to summary
public void setJDoubleType(Type type)

This method should only be called by the builder of the TypeDataBase and at most once

setJFloatTypeback to summary
public void setJFloatType(Type type)

This method should only be called by the builder of the TypeDataBase and at most once

setJIntTypeback to summary
public void setJIntType(Type type)

This method should only be called by the builder of the TypeDataBase and at most once

setJLongTypeback to summary
public void setJLongType(Type type)

This method should only be called by the builder of the TypeDataBase and at most once

setJShortTypeback to summary
public void setJShortType(Type type)

This method should only be called by the builder of the TypeDataBase and at most once

vtblForTypeback to summary
public Address vtblForType(Type type)