public class BasicTypeDataBase extends java.lang.Object implements TypeDataBase
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.
Constructor and Description |
---|
BasicTypeDataBase(MachineDescription machDesc,
VtblAccess vtblAccess) |
Modifier and Type | Method and Description |
---|---|
void |
addIntConstant(java.lang.String name,
int value)
This method should only be used by the builder of the
TypeDataBase.
|
void |
addLongConstant(java.lang.String name,
long value)
This method should only be used by the builder of the
TypeDataBase.
|
boolean |
addressTypeIsEqualToType(Address addr,
Type type)
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.
|
void |
addType(Type type)
This method should only be used by the builder of the
TypeDataBase.
|
long |
cIntegerTypeMaxValue(long sizeInBytes,
boolean isUnsigned) |
long |
cIntegerTypeMinValue(long sizeInBytes,
boolean isUnsigned) |
Type |
findDynamicTypeForAddress(Address addr,
Type baseType)
Helper routine for guessing the most derived type of a
polymorphic C++ object.
|
long |
getAddressSize()
Returns the size of a C address in bytes.
|
java.util.Iterator |
getIntConstants()
Returns an Iterator over the String names of the integer
constants in the database.
|
Type |
getJBooleanType()
Accessors for types representing the Java primitive types; used
for both proper type checking and for walking down Java arrays.
|
Type |
getJByteType() |
Type |
getJCharType() |
Type |
getJDoubleType() |
Type |
getJFloatType() |
Type |
getJIntType() |
Type |
getJLongType() |
Type |
getJShortType() |
java.util.Iterator |
getLongConstants()
Returns an Iterator over the String names of the long constants
in the database.
|
long |
getOopSize()
Returns the size of an oop in bytes.
|
java.util.Iterator |
getTypes()
Returns an Iterator over the Types in the database.
|
Type |
guessTypeForAddress(Address addr)
Helper routine for guessing the most derived type of a
polymorphic C++ object.
|
java.lang.Integer |
lookupIntConstant(java.lang.String constantName)
Equivalent to lookupIntConstant(constantName, true)
|
java.lang.Integer |
lookupIntConstant(java.lang.String constantName,
boolean throwException) |
java.lang.Long |
lookupLongConstant(java.lang.String constantName)
Equivalent to lookupLongConstant(constantName, true)
|
java.lang.Long |
lookupLongConstant(java.lang.String constantName,
boolean throwException) |
Type |
lookupType(java.lang.String cTypeName)
Equivalent to lookupType(cTypeName, true)
|
Type |
lookupType(java.lang.String cTypeName,
boolean throwException)
For simplicity of the initial implementation, this is not
guaranteed to work for primitive types.
|
void |
removeIntConstant(java.lang.String name)
This method should only be used by the builder of the
TypeDataBase.
|
void |
removeLongConstant(java.lang.String name)
This method should only be used by the builder of the
TypeDataBase.
|
void |
removeType(Type type)
This method should only be used by the builder of the
TypeDataBase.
|
void |
setJBooleanType(Type type)
This method should only be called by the builder of the
TypeDataBase and at most once
|
void |
setJByteType(Type type)
This method should only be called by the builder of the
TypeDataBase and at most once
|
void |
setJCharType(Type type)
This method should only be called by the builder of the
TypeDataBase and at most once
|
void |
setJDoubleType(Type type)
This method should only be called by the builder of the
TypeDataBase and at most once
|
void |
setJFloatType(Type type)
This method should only be called by the builder of the
TypeDataBase and at most once
|
void |
setJIntType(Type type)
This method should only be called by the builder of the
TypeDataBase and at most once
|
void |
setJLongType(Type type)
This method should only be called by the builder of the
TypeDataBase and at most once
|
void |
setJShortType(Type type)
This method should only be called by the builder of the
TypeDataBase and at most once
|
public BasicTypeDataBase(MachineDescription machDesc, VtblAccess vtblAccess)
public Type lookupType(java.lang.String cTypeName)
TypeDataBase
lookupType
in interface TypeDataBase
public Type lookupType(java.lang.String cTypeName, boolean throwException)
TypeDataBase
lookupType
in interface TypeDataBase
public java.lang.Integer lookupIntConstant(java.lang.String constantName)
TypeDataBase
lookupIntConstant
in interface TypeDataBase
public java.lang.Integer lookupIntConstant(java.lang.String constantName, boolean throwException)
lookupIntConstant
in interface TypeDataBase
public java.lang.Long lookupLongConstant(java.lang.String constantName)
TypeDataBase
lookupLongConstant
in interface TypeDataBase
public java.lang.Long lookupLongConstant(java.lang.String constantName, boolean throwException)
lookupLongConstant
in interface TypeDataBase
public Type getJBooleanType()
TypeDataBase
getJBooleanType
in interface TypeDataBase
public Type getJByteType()
getJByteType
in interface TypeDataBase
public Type getJCharType()
getJCharType
in interface TypeDataBase
public Type getJDoubleType()
getJDoubleType
in interface TypeDataBase
public Type getJFloatType()
getJFloatType
in interface TypeDataBase
public Type getJIntType()
getJIntType
in interface TypeDataBase
public Type getJLongType()
getJLongType
in interface TypeDataBase
public Type getJShortType()
getJShortType
in interface TypeDataBase
public long getAddressSize()
TypeDataBase
getAddressSize
in interface TypeDataBase
public long getOopSize()
TypeDataBase
getOopSize
in interface TypeDataBase
public boolean addressTypeIsEqualToType(Address addr, Type type)
TypeDataBase
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.
addressTypeIsEqualToType
in interface TypeDataBase
public Type findDynamicTypeForAddress(Address addr, Type baseType)
TypeDataBase
findDynamicTypeForAddress
in interface TypeDataBase
public Type guessTypeForAddress(Address addr)
TypeDataBase
guessTypeForAddress
in interface TypeDataBase
public long cIntegerTypeMaxValue(long sizeInBytes, boolean isUnsigned)
public long cIntegerTypeMinValue(long sizeInBytes, boolean isUnsigned)
public java.util.Iterator getTypes()
TypeDataBase
getTypes
in interface TypeDataBase
public java.util.Iterator getIntConstants()
TypeDataBase
getIntConstants
in interface TypeDataBase
public java.util.Iterator getLongConstants()
TypeDataBase
getLongConstants
in interface TypeDataBase
public void setJBooleanType(Type type)
public void setJByteType(Type type)
public void setJCharType(Type type)
public void setJDoubleType(Type type)
public void setJFloatType(Type type)
public void setJIntType(Type type)
public void setJLongType(Type type)
public void setJShortType(Type type)
public void addType(Type type)
public void removeType(Type type)
public void addIntConstant(java.lang.String name, int value)
public void removeIntConstant(java.lang.String name)
public void addLongConstant(java.lang.String name, long value)
public void removeLongConstant(java.lang.String name)
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.