decompiler
1.0.0
|
The base datatype class for the decompiler. More...
#include <type.hh>
Public Member Functions | |
Datatype (const Datatype &op) | |
Construct the base data-type copying low-level properties of another. | |
Datatype (int4 s, type_metatype m) | |
Construct the base data-type providing size and meta-type. | |
virtual | ~Datatype (void) |
Destructor. | |
bool | isCoreType (void) const |
Is this a core data-type. | |
bool | isCharPrint (void) const |
Does this print as a 'char'. | |
bool | isEnumType (void) const |
Is this an enumerated type. | |
bool | isPowerOfTwo (void) const |
Is this a flag-based enumeration. | |
bool | isASCII (void) const |
Does this print as an ASCII 'char'. | |
bool | isUTF16 (void) const |
Does this print as UTF16 'wchar'. | |
bool | isUTF32 (void) const |
Does this print as UTF32 'wchar'. | |
bool | isVariableLength (void) const |
Is this a variable length structure. | |
bool | hasSameVariableBase (const Datatype *ct) const |
Are these the same variable length data-type. More... | |
bool | isOpaqueString (void) const |
Is this an opaquely encoded string. | |
bool | isPointerRel (void) const |
Is this a TypePointerRel. | |
bool | isFormalPointerRel (void) const |
Is this a non-ephemeral TypePointerRel. | |
bool | hasStripped (void) const |
Return true if this has a stripped form. | |
bool | isIncomplete (void) const |
Is this an incompletely defined data-type. | |
bool | needsResolution (void) const |
Is this a union or a pointer to union. | |
uint4 | getInheritable (void) const |
Get properties pointers inherit. | |
uint4 | getDisplayFormat (void) const |
Get the display format for constants with this data-type. More... | |
type_metatype | getMetatype (void) const |
Get the type meta-type. | |
sub_metatype | getSubMeta (void) const |
Get the sub-metatype. | |
uint8 | getId (void) const |
Get the type id. | |
int4 | getSize (void) const |
Get the type size. | |
const string & | getName (void) const |
Get the type name. | |
const string & | getDisplayName (void) const |
Get string to use in display. | |
Datatype * | getTypedef (void) const |
Get the data-type immediately typedefed by this (or null) | |
virtual void | printRaw (ostream &s) const |
Print a description of the type to stream. More... | |
virtual const TypeField * | findTruncation (int8 off, int4 sz, const PcodeOp *op, int4 slot, int8 &newoff) const |
Find an immediate subfield of this data-type. More... | |
virtual Datatype * | getSubType (int8 off, int8 *newoff) const |
Recover component data-type one-level down. More... | |
virtual Datatype * | nearestArrayedComponentForward (int8 off, int8 *newoff, int8 *elSize) const |
virtual Datatype * | nearestArrayedComponentBackward (int8 off, int8 *newoff, int8 *elSize) const |
virtual int4 | getHoleSize (int4 off) const |
Get number of bytes at the given offset that are padding. | |
virtual int4 | numDepend (void) const |
Return number of component sub-types. | |
virtual Datatype * | getDepend (int4 index) const |
Return the i-th component sub-type. | |
virtual void | printNameBase (ostream &s) const |
Print name as short prefix. | |
virtual int4 | compare (const Datatype &op, int4 level) const |
Order types for propagation. More... | |
virtual int4 | compareDependency (const Datatype &op) const |
Compare for storage in tree structure. More... | |
virtual void | encode (Encoder &encoder) const |
Encode the data-type to a stream. More... | |
virtual bool | isPtrsubMatching (uintb off) const |
Is this data-type suitable as input to a CPUI_PTRSUB op. More... | |
virtual Datatype * | getStripped (void) const |
Get a stripped version of this for formal use in formal declarations. More... | |
virtual Datatype * | resolveInFlow (PcodeOp *op, int4 slot) |
Tailor data-type propagation based on Varnode use. More... | |
virtual Datatype * | findResolve (const PcodeOp *op, int4 slot) |
Find a previously resolved sub-type. More... | |
virtual int4 | findCompatibleResolve (Datatype *ct) const |
Find a resolution compatible with the given data-type. More... | |
virtual const TypeField * | resolveTruncation (int8 offset, PcodeOp *op, int4 slot, int8 &newoff) |
Resolve which union field is being used for a given PcodeOp when a truncation is involved. More... | |
int4 | typeOrder (const Datatype &op) const |
Order this with -op- datatype. | |
int4 | typeOrderBool (const Datatype &op) const |
Order this with -op-, treating bool data-type as special. More... | |
void | encodeRef (Encoder &encoder) const |
Encode a reference of this to a stream. More... | |
bool | isPieceStructured (void) const |
Does this data-type consist of separate pieces? More... | |
Static Public Member Functions | |
static uint4 | encodeIntegerFormat (const string &val) |
Encode the format attribute from an XML element. More... | |
static string | decodeIntegerFormat (uint4 val) |
Decode the given format value into an XML attribute string. More... | |
Protected Types | |
enum | { coretype = 1, chartype = 2, enumtype = 4, poweroftwo = 8, utf16 = 16, utf32 = 32, opaque_string = 64, variable_length = 128, has_stripped = 0x100, is_ptrrel = 0x200, type_incomplete = 0x400, needs_resolution = 0x800, force_format = 0x7000, truncate_bigendian = 0x8000 } |
Boolean properties of datatypes. More... | |
Protected Member Functions | |
void | decodeBasic (Decoder &decoder) |
Recover basic data-type properties. More... | |
void | encodeBasic (type_metatype meta, Encoder &encoder) const |
Encode basic data-type properties. More... | |
void | encodeTypedef (Encoder &encoder) const |
Encode this as a typedef element to a stream. More... | |
void | markComplete (void) |
Mark this data-type as completely defined. | |
void | setDisplayFormat (uint4 format) |
Set a specific display format. More... | |
virtual Datatype * | clone (void) const =0 |
Clone the data-type. | |
Static Protected Member Functions | |
static uint8 | hashName (const string &nm) |
Produce a data-type id by hashing the type name. More... | |
static uint8 | hashSize (uint8 id, int4 size) |
Reversibly hash size into id. More... | |
Protected Attributes | |
uint8 | id |
A unique id for the type (or 0 if an id is not assigned) | |
int4 | size |
Size (of variable holding a value of this type) | |
uint4 | flags |
Boolean properties of the type. | |
string | name |
Name of type. | |
string | displayName |
Name to display in output. | |
type_metatype | metatype |
Meta-type - type disregarding size. | |
sub_metatype | submeta |
Sub-type of of the meta-type, for comparisons. | |
Datatype * | typedefImm |
The immediate data-type being typedefed by this. | |
Static Protected Attributes | |
static sub_metatype | base2sub [15] |
Friends | |
class | TypeFactory |
struct | DatatypeCompare |
The base datatype class for the decompiler.
Used for symbols, function prototypes, type propagation etc.
|
protected |
Boolean properties of datatypes.
Enumerator | |
---|---|
coretype | This is a basic type which will never be redefined. |
chartype | ASCII character data. |
enumtype | An enumeration type (as well as an integer) |
poweroftwo | An enumeration type where all values are of 2^^n form. |
utf16 | 16-bit wide chars in unicode UTF16 |
utf32 | 32-bit wide chars in unicode UTF32 |
opaque_string | Structure that should be treated as a string. |
variable_length | May be other structures with same name different lengths. |
has_stripped | Datatype has a stripped form for formal declarations. |
is_ptrrel | Datatype is a TypePointerRel. |
type_incomplete | Set if this (recursive) data-type has not been fully defined yet. |
needs_resolution | Datatype (union, pointer to union) needs resolution before propagation. |
force_format | 3-bits encoding display format, 0=none, 1=hex, 2=dec, 3=oct, 4=bin, 5=char |
truncate_bigendian | Pointer can be truncated and is big endian. |
|
virtual |
Order types for propagation.
Order this with another data-type, in a way suitable for the type propagation algorithm. Bigger types come earlier. More specific types come earlier.
op | is the data-type to compare with this |
level | is maximum level to descend when recursively comparing |
Reimplemented in ghidra::TypeSpacebase, ghidra::TypeCode, ghidra::TypePointerRel, ghidra::TypePartialUnion, ghidra::TypePartialStruct, ghidra::TypeUnion, ghidra::TypeStruct, ghidra::TypeEnum, ghidra::TypeArray, and ghidra::TypePointer.
Referenced by ghidra::TypePointer::compare(), ghidra::TypeArray::compare(), ghidra::TypeStruct::compare(), ghidra::TypeUnion::compare(), ghidra::TypePartialStruct::compare(), ghidra::TypePartialUnion::compare(), ghidra::TypeCode::compare(), ghidra::TypeEnum::endEnum(), ghidra::TypeStruct::getDepend(), ghidra::TypeUnion::getDepend(), ghidra::TypePartialStruct::getParent(), ghidra::TypePartialUnion::getParentUnion(), ghidra::TypePointerRel::getPointerOffset(), ghidra::TypeCode::getPrototype(), printNameBase(), ghidra::TypePointer::printNameBase(), ghidra::TypeArray::printNameBase(), typeOrder(), typeOrderBool(), and ghidra::TypeSpacebase::TypeSpacebase().
|
virtual |
Compare for storage in tree structure.
Sort data-types for the main TypeFactory container. The sort needs to be based on the data-type structure so that an example data-type, constructed outside the factory, can be used to find the equivalent object inside the factory. This means the comparison should not examine the data-type id. In practice, the comparison only needs to go down one level in the component structure before just comparing component pointers.
op | is the data-type to compare with this |
Reimplemented in ghidra::TypeSpacebase, ghidra::TypeCode, ghidra::TypePointerRel, ghidra::TypePartialUnion, ghidra::TypePartialStruct, ghidra::TypeUnion, ghidra::TypeStruct, ghidra::TypeEnum, ghidra::TypeArray, and ghidra::TypePointer.
References metatype, size, submeta, ghidra::TYPE_ARRAY, ghidra::TYPE_BOOL, ghidra::TYPE_CODE, ghidra::TYPE_FLOAT, ghidra::TYPE_INT, ghidra::TYPE_PARTIALSTRUCT, ghidra::TYPE_PARTIALUNION, ghidra::TYPE_PTR, ghidra::TYPE_PTRREL, ghidra::TYPE_SPACEBASE, ghidra::TYPE_STRUCT, ghidra::TYPE_UINT, ghidra::TYPE_UNION, ghidra::TYPE_UNKNOWN, and ghidra::TYPE_VOID.
Referenced by ghidra::TypeEnum::compareDependency(), ghidra::TypeStruct::compareDependency(), ghidra::TypeUnion::compareDependency(), ghidra::TypeCode::compareDependency(), ghidra::TypeSpacebase::compareDependency(), ghidra::TypeFactory::decodeCode(), ghidra::TypeFactory::decodeStruct(), ghidra::TypeFactory::decodeUnion(), ghidra::TypeEnum::endEnum(), ghidra::TypeFactory::findAdd(), ghidra::TypeStruct::getDepend(), ghidra::TypeUnion::getDepend(), ghidra::TypePartialStruct::getParent(), ghidra::TypePartialUnion::getParentUnion(), ghidra::TypePointerRel::getPointerOffset(), ghidra::TypeCode::getPrototype(), ghidra::DatatypeCompare::operator()(), printNameBase(), ghidra::TypePointer::printNameBase(), ghidra::TypeArray::printNameBase(), and ghidra::TypeSpacebase::TypeSpacebase().
|
protected |
Recover basic data-type properties.
Restore the basic properties (name,size,id) of a data-type from an XML element Properties are read from the attributes of the element
decoder | is the stream decoder |
References base2sub, coretype, displayName, encodeIntegerFormat(), flags, ghidra::Decoder::getNextAttributeId(), hashName(), hashSize(), isVariableLength(), metatype, name, opaque_string, ghidra::Decoder::readBool(), ghidra::Decoder::readSignedInteger(), ghidra::Decoder::readString(), ghidra::Decoder::readUnsignedInteger(), setDisplayFormat(), submeta, ghidra::TYPE_VOID, and variable_length.
Referenced by ghidra::TypeChar::decode(), ghidra::TypeUnicode::decode(), ghidra::TypePointer::decode(), ghidra::TypeArray::decode(), ghidra::TypeEnum::decode(), ghidra::TypePointerRel::decode(), ghidra::TypeSpacebase::decode(), ghidra::TypeFactory::decodeStruct(), ghidra::TypeCode::decodeStub(), ghidra::TypeFactory::decodeTypeNoRef(), ghidra::TypeFactory::decodeTypeWithCodeFlags(), and ghidra::TypeFactory::decodeUnion().
|
static |
Decode the given format value into an XML attribute string.
Possible encoded values are 1-5 corresponding to "hex", "dec", "oct", "bin", "char"
val | is the value to decode |
Referenced by encodeBasic(), ghidra::Symbol::encodeHeader(), encodeTypedef(), and typeOrder().
|
virtual |
Encode the data-type to a stream.
Encode a formal description of the data-type as a <type> element. For composite data-types, the description goes down one level, describing the component types only by reference.
encoder | is the stream encoder |
Reimplemented in ghidra::TypeSpacebase, ghidra::TypeCode, ghidra::TypePointerRel, ghidra::TypePartialUnion, ghidra::TypeUnion, ghidra::TypeStruct, ghidra::TypeEnum, ghidra::TypeArray, ghidra::TypePointer, ghidra::TypeVoid, ghidra::TypeUnicode, and ghidra::TypeChar.
References ghidra::Encoder::closeElement(), encodeBasic(), and ghidra::Encoder::openElement().
Referenced by ghidra::TypeChar::clone(), ghidra::TypeUnicode::clone(), ghidra::TypeVoid::clone(), ghidra::TypePointer::clone(), ghidra::TypeArray::clone(), ghidra::TypeEnum::clone(), ghidra::TypeStruct::clone(), ghidra::TypeUnion::clone(), ghidra::TypePartialUnion::clone(), ghidra::TypePointerRel::clone(), ghidra::TypeCode::clone(), ghidra::TypeSpacebase::clone(), ghidra::CPoolRecord::encode(), ghidra::ProtoStoreInternal::encode(), ghidra::FuncProto::encode(), ghidra::TypeFactory::encodeCoreTypes(), encodeRef(), ghidra::TypeFactory::getArch(), ghidra::TypeField::operator<(), and printNameBase().
|
protected |
Encode basic data-type properties.
Encode basic data-type properties (name,size,id) as attributes. This routine presumes the initial element is already written to the stream.
meta | is the metatype attribute |
encoder | is the stream encoder |
References coretype, decodeIntegerFormat(), flags, getDisplayFormat(), hashSize(), id, isVariableLength(), name, opaque_string, ghidra::Encoder::writeBool(), ghidra::Encoder::writeSignedInteger(), ghidra::Encoder::writeString(), and ghidra::Encoder::writeUnsignedInteger().
Referenced by encode(), ghidra::TypeChar::encode(), ghidra::TypeUnicode::encode(), ghidra::TypePointer::encode(), ghidra::TypeArray::encode(), ghidra::TypeEnum::encode(), ghidra::TypeStruct::encode(), ghidra::TypeUnion::encode(), ghidra::TypePartialUnion::encode(), ghidra::TypePointerRel::encode(), ghidra::TypeCode::encode(), and ghidra::TypeSpacebase::encode().
|
static |
Encode the format attribute from an XML element.
Possible values are:
val | is the string to encode |
Referenced by decodeBasic(), ghidra::Symbol::decodeHeader(), ghidra::TypeFactory::decodeTypedef(), ghidra::IfcForceFormat::execute(), ghidra::IfcForceDatatypeFormat::execute(), and typeOrder().
void ghidra::Datatype::encodeRef | ( | Encoder & | encoder | ) | const |
Encode a reference of this to a stream.
Encode a simple reference to this data-type as a <typeref> element, including only the name and id.
encoder | is the stream encoder |
References ghidra::Encoder::closeElement(), encode(), hashSize(), isVariableLength(), name, ghidra::Encoder::openElement(), ghidra::TYPE_VOID, ghidra::Encoder::writeSignedInteger(), ghidra::Encoder::writeString(), and ghidra::Encoder::writeUnsignedInteger().
Referenced by ghidra::TypePartialUnion::encode(), encodeTypedef(), and typeOrder().
|
protected |
Encode this as a typedef element to a stream.
Called only if the typedefImm field is non-null. Encode the data-type to the stream as a simple <typedef> element including only the names and ids of this and the data-type it typedefs.
encoder | is the stream encoder |
References ghidra::Encoder::closeElement(), decodeIntegerFormat(), encodeRef(), getDisplayFormat(), name, ghidra::Encoder::openElement(), typedefImm, ghidra::Encoder::writeString(), and ghidra::Encoder::writeUnsignedInteger().
Referenced by ghidra::TypeChar::encode(), ghidra::TypeUnicode::encode(), ghidra::TypeVoid::encode(), ghidra::TypePointer::encode(), ghidra::TypeArray::encode(), ghidra::TypeEnum::encode(), ghidra::TypeStruct::encode(), ghidra::TypeUnion::encode(), ghidra::TypeCode::encode(), and ghidra::TypeSpacebase::encode().
|
virtual |
Find a resolution compatible with the given data-type.
If this data-type has an alternate data-type form that matches the given data-type, return an index indicating this form, otherwise return -1.
ct | is the given data-type |
Reimplemented in ghidra::TypePartialUnion, ghidra::TypeUnion, ghidra::TypeStruct, and ghidra::TypeArray.
Referenced by ghidra::TypeArray::clone(), ghidra::TypeStruct::clone(), ghidra::TypeUnion::clone(), ghidra::TypeArray::findCompatibleResolve(), ghidra::TypeStruct::findCompatibleResolve(), ghidra::TypeUnion::findCompatibleResolve(), ghidra::TypePartialUnion::getStripped(), printNameBase(), and ghidra::ActionSetCasts::tryResolutionAdjustment().
Find a previously resolved sub-type.
This is the constant version of resolveInFlow. If a resulting subtype has already been calculated, for the particular read (slot >= 0) or write (slot == -1), then return it. Otherwise return the original data-type.
op | is the PcodeOp using the Varnode assigned with this data-type |
slot | is the slot reading or writing the Varnode |
Reimplemented in ghidra::TypePartialUnion, ghidra::TypeUnion, ghidra::TypeStruct, ghidra::TypeArray, and ghidra::TypePointer.
Referenced by ghidra::ActionSetCasts::castOutput(), ghidra::TypePointer::clone(), ghidra::TypeArray::clone(), ghidra::TypeStruct::clone(), ghidra::TypeUnion::clone(), ghidra::TypePartialUnion::findResolve(), ghidra::Varnode::getHighTypeDefFacing(), ghidra::Varnode::getHighTypeReadFacing(), ghidra::TypePartialUnion::getStripped(), ghidra::Varnode::getTypeDefFacing(), ghidra::Varnode::getTypeReadFacing(), printNameBase(), and ghidra::PrintC::pushPartialSymbol().
|
virtual |
Find an immediate subfield of this data-type.
Given a byte range within this data-type, determine the field it is contained in and pass back the renormalized offset. This method applies to TYPE_STRUCT, TYPE_UNION, and TYPE_PARTIALUNION, data-types that have field components. For TYPE_UNION and TYPE_PARTIALUNION, the field may depend on the p-code op extracting or writing the value.
off | is the byte offset into this |
sz | is the size of the byte range |
op | is the PcodeOp reading/writing the data-type |
slot | is the index of the Varnode being accessed, -1 for the output, >=0 for an input |
newoff | points to the renormalized offset to pass back |
Reimplemented in ghidra::TypePartialUnion, ghidra::TypeUnion, and ghidra::TypeStruct.
Referenced by ghidra::TypeStruct::endField(), ghidra::TypeUnion::getField(), ghidra::TypeOpSubpiece::getOutputToken(), ghidra::TypePartialUnion::getParentUnion(), getTypedef(), ghidra::PrintC::opPtrsub(), ghidra::PrintC::opSubpiece(), and ghidra::PrintC::pushPartialSymbol().
|
inline |
Get the display format for constants with this data-type.
A non-zero result indicates the type of formatting that is forced on the constant. One of the following values is returned.
References flags, and force_format.
Referenced by encodeBasic(), encodeTypedef(), getInheritable(), ghidra::PrintC::push_integer(), and ghidra::PrintC::pushCharConstant().
|
virtual |
Get a stripped version of this for formal use in formal declarations.
Some data-types are ephemeral, and, in the final decompiler output, get replaced with a formal version that is a stripped down version of the original. This method returns this stripped down version, if it exists, or null otherwise. A non-null return should correspond with hasStripped returning true.
Reimplemented in ghidra::TypePointerRel, ghidra::TypePartialUnion, and ghidra::TypePartialStruct.
Referenced by ghidra::Scope::addSymbol(), ghidra::TypeFactory::getTypeArray(), ghidra::TypeFactory::getTypePointer(), ghidra::TypeFactory::getTypePointerStripArray(), printNameBase(), ghidra::TypeFactory::resizePointer(), and ghidra::ScopeInternal::retypeSymbol().
|
virtual |
Recover component data-type one-level down.
Given an offset into this data-type, return the component data-type at that offset. Also, pass back a "renormalized" offset suitable for recursize getSubType() calls: i.e. if the original offset hits the exact start of the sub-type, 0 is passed back. If there is no valid component data-type at the offset, return NULL and pass back the original offset
off | is the offset into this data-type |
newoff | is a pointer to the passed-back offset |
Reimplemented in ghidra::TypeSpacebase, ghidra::TypeCode, ghidra::TypePartialStruct, ghidra::TypeStruct, ghidra::TypeArray, and ghidra::TypePointer.
Referenced by ghidra::RuleStructOffset0::applyOp(), ghidra::SplitDatatype::buildPointers(), ghidra::RulePieceStructure::convertZextToPiece(), ghidra::ScoreUnionFields::derefPointer(), ghidra::RulePieceStructure::determineDatatype(), ghidra::TypePointer::downChain(), ghidra::TypeStruct::endField(), ghidra::TypePartialUnion::findResolve(), ghidra::SplitDatatype::getComponent(), ghidra::TypeFactory::getExactPiece(), ghidra::TypePartialStruct::getParent(), ghidra::TypeCode::getPrototype(), ghidra::TypePointerRel::getPtrToFromParent(), ghidra::TypePointer::getSpace(), ghidra::TypeStruct::getSubType(), ghidra::TypePartialStruct::getSubType(), getTypedef(), ghidra::AddTreeState::hasMatchingSubType(), ghidra::TypeArray::numElements(), ghidra::TypeOpPiece::propagateType(), ghidra::TypeOpSubpiece::propagateType(), ghidra::RangeHint::reconcile(), ghidra::TypePartialUnion::resolveInFlow(), ghidra::ScoreUnionFields::scoreTruncation(), ghidra::RulePieceStructure::spanningRange(), and ghidra::TypeSpacebase::TypeSpacebase().
|
staticprotected |
Produce a data-type id by hashing the type name.
If a type id is explicitly provided for a data-type, this routine is used to produce an id based on a hash of the name. IDs produced this way will have their sign-bit set to distinguish it from other IDs.
nm | is the type name to be hashed |
Referenced by decodeBasic(), ghidra::TypeFactory::decodeType(), ghidra::TypeFactory::decodeTypedef(), ghidra::TypeFactory::getBase(), ghidra::TypeFactory::getTypeChar(), ghidra::TypeFactory::getTypeCode(), ghidra::TypeFactory::getTypedef(), ghidra::TypeFactory::getTypeEnum(), ghidra::TypeFactory::getTypePointer(), ghidra::TypeFactory::getTypePointerRel(), ghidra::TypeFactory::getTypePointerWithSpace(), ghidra::TypeFactory::getTypeStruct(), ghidra::TypeFactory::getTypeUnicode(), ghidra::TypeFactory::getTypeUnion(), ghidra::TypeFactory::getTypeVoid(), markComplete(), and ghidra::TypeFactory::setName().
|
staticprotected |
Reversibly hash size into id.
This allows IDs for variable length structures to be uniquefied based on size. A base ID is given and a size of the specific instance. A unique ID is returned. The hashing is reversible by feeding the output ID back into this function with the same size.
id | is the given ID to (de)uniquify |
size | is the instance size of the structure |
Referenced by decodeBasic(), ghidra::TypeFactory::decodeTypedef(), encodeBasic(), encodeRef(), ghidra::TypeFactory::findById(), hasSameVariableBase(), and markComplete().
bool ghidra::Datatype::hasSameVariableBase | ( | const Datatype * | ct | ) | const |
Are these the same variable length data-type.
If this and the other given data-type are both variable length and come from the the same base data-type, return true.
ct | is the other given data-type to compare with this |
References hashSize(), id, isVariableLength(), and size.
Referenced by ghidra::CastStrategyC::castStandard(), and isVariableLength().
|
inline |
Does this data-type consist of separate pieces?
If a value with this data-type is put together from multiple pieces, is it better to display this construction as a sequence of separate assignments or as a single concatenation. Generally a TYPE_STRUCT or TYPE_ARRAY should be represented with separate assignments.
References metatype, and ghidra::TYPE_ARRAY.
Referenced by ghidra::RuleSubRight::applyOp(), ghidra::RulePieceStructure::determineDatatype(), ghidra::Varnode::getStructuredType(), ghidra::PrintC::opSubpiece(), ghidra::RulePieceStructure::separateSymbol(), ghidra::RulePieceStructure::spanningRange(), and typeOrder().
|
virtual |
Is this data-type suitable as input to a CPUI_PTRSUB op.
A CPUI_PTRSUB must act on a pointer data-type where the given offset addresses a component. Perform this check.
off | is the given offset |
Reimplemented in ghidra::TypePointerRel, and ghidra::TypePointer.
Referenced by ghidra::ActionSetCasts::apply(), ghidra::RulePtrsubUndo::applyOp(), ghidra::TypePointer::clone(), ghidra::TypePointerRel::clone(), and printNameBase().
|
virtual |
Find the first component data-type before the given offset that is (or contains) an array, and pass back the difference between the component's start and the given offset. Return the component data-type or null if no array is found.
off | is the given offset into this data-type |
newoff | is used to pass back the offset difference |
elSize | is used to pass back the array element size |
Reimplemented in ghidra::TypeSpacebase, and ghidra::TypeStruct.
Referenced by ghidra::TypeStruct::endField(), getTypedef(), ghidra::AddTreeState::hasMatchingSubType(), ghidra::TypeStruct::nearestArrayedComponentBackward(), ghidra::TypeSpacebase::nearestArrayedComponentBackward(), and ghidra::TypeSpacebase::TypeSpacebase().
|
virtual |
Find the first component data-type after the given offset that is (or contains) an array, and pass back the difference between the component's start and the given offset. Return the component data-type or null if no array is found.
off | is the given offset into this data-type |
newoff | is used to pass back the offset difference |
elSize | is used to pass back the array element size |
Reimplemented in ghidra::TypeSpacebase, and ghidra::TypeStruct.
Referenced by ghidra::TypeStruct::endField(), getTypedef(), ghidra::AddTreeState::hasMatchingSubType(), ghidra::TypeStruct::nearestArrayedComponentForward(), ghidra::TypeSpacebase::nearestArrayedComponentForward(), and ghidra::TypeSpacebase::TypeSpacebase().
|
virtual |
Print a description of the type to stream.
Print a raw description of the type to stream. Intended for debugging. Not intended to produce parsable C.
s | is the output stream |
Reimplemented in ghidra::TypeCode, ghidra::TypePointerRel, ghidra::TypePartialUnion, ghidra::TypePartialStruct, ghidra::TypeArray, and ghidra::TypePointer.
Referenced by ghidra::MapState::addRange(), ghidra::ActionPrototypeWarnings::apply(), ghidra::TypePartialStruct::getParent(), ghidra::TypePartialUnion::getParentUnion(), ghidra::TypePointerRel::getPointerOffset(), ghidra::TypeCode::getPrototype(), ghidra::TypePointer::getSpace(), getTypedef(), ghidra::TypeFactory::insert(), ghidra::TypeArray::numElements(), ghidra::SymbolEntry::printEntry(), ghidra::TypePartialStruct::printRaw(), and ghidra::TypePartialUnion::printRaw().
Tailor data-type propagation based on Varnode use.
For certain data-types, particularly union, variables of that data-type are transformed into a subtype depending on the particular use. Each read or write of the variable may use a different subtype. This method returns the particular subtype required based on a specific PcodeOp. A slot index >=0 indicates which operand reads the variable, or if the index is -1, the variable is written.
op | is the specific PcodeOp |
slot | indicates the input operand, or the output |
Reimplemented in ghidra::TypePartialUnion, ghidra::TypeUnion, ghidra::TypeStruct, ghidra::TypeArray, and ghidra::TypePointer.
Referenced by ghidra::RulePieceStructure::applyOp(), ghidra::ActionSetCasts::castOutput(), ghidra::TypePointer::clone(), ghidra::TypeArray::clone(), ghidra::TypeStruct::clone(), ghidra::TypeUnion::clone(), ghidra::TypePartialUnion::getStripped(), printNameBase(), ghidra::ActionInferTypes::propagateTypeEdge(), and ghidra::ActionSetCasts::resolveUnion().
|
virtual |
Resolve which union field is being used for a given PcodeOp when a truncation is involved.
This method applies to the TYPE_UNION and TYPE_PARTIALUNION data-types, when a Varnode is backed by a larger Symbol with a union data-type, or if the Varnode is produced by a CPUI_SUBPIECE where the input Varnode has a union data-type. Scoring is done to compute the best field and the result is cached with the function. The record of the best field is returned or null if there is no appropriate field
offset | is the byte offset into the union we are truncating to |
op | is either the PcodeOp reading the truncated Varnode or the CPUI_SUBPIECE doing the truncation |
slot | is either the input slot of the reading PcodeOp or the artificial SUBPIECE slot: 1 |
newoff | is used to pass back how much offset is left to resolve |
Reimplemented in ghidra::TypePartialUnion, and ghidra::TypeUnion.
Referenced by ghidra::TypeUnion::clone(), ghidra::TypePartialUnion::getStripped(), printNameBase(), ghidra::TypeOpSubpiece::propagateType(), and ghidra::TypePartialUnion::resolveInFlow().
|
inlineprotected |
Set a specific display format.
The display format for the data-type is changed based on the given format. A value of zero clears any preexisting format. Otherwise the value can be one of: 1=hex, 2=dec, 3=oct, 4=bin, 5=char
format | is the given format |
References flags, and force_format.
Referenced by decodeBasic(), ghidra::TypeFactory::getArch(), ghidra::TypeFactory::getTypedef(), markComplete(), and ghidra::TypeFactory::setDisplayFormat().
|
inline |
Order this with -op-, treating bool data-type as special.
Order data-types, with special handling of the bool data-type. Data-types are compared using the normal ordering, but bool is ordered after all other data-types. A return value of 0 indicates the data-types are the same, -1 indicates that this is prefered (ordered earlier), and 1 indicates this is ordered later.
op | is the other data-type to compare with this |
References compare(), metatype, and ghidra::TYPE_BOOL.
Referenced by ghidra::HighVariable::getTypeRepresentative(), and typeOrder().
|
staticprotected |
The base propagation ordering associated with each meta-type. The array elements correspond to the ordering of #type_metatype.
Referenced by decodeBasic().