Ghidra 11.3.2
Ghidra internal decompiler documentation.
Loading...
Searching...
No Matches
ghidra::TypeFactoryGhidra Class Reference

An implementation of the TypeFactory interface, query a Ghidra client for data-type information. More...

#include <typegrp_ghidra.hh>

Inheritance diagram for ghidra::TypeFactoryGhidra:
[legend]
Collaboration diagram for ghidra::TypeFactoryGhidra:
[legend]

Public Member Functions

 TypeFactoryGhidra (ArchitectureGhidra *g)
 Constructor.
 
- Public Member Functions inherited from ghidra::TypeFactory
 TypeFactory (Architecture *g)
 Construct a factory.
 
void setupSizes (void)
 Derive some size information from Architecture.
 
void clear (void)
 Clear out all types.
 
void clearNoncore (void)
 Clear out non-core types.
 
virtual ~TypeFactory (void)
 Destructor.
 
int4 getAlignment (uint4 size) const
 Get data-type alignment based on size.
 
int4 getPrimitiveAlignSize (uint4 size) const
 Get the aligned size of a primitive data-type.
 
int4 getSizeOfInt (void) const
 Get the size of the default "int".
 
int4 getSizeOfLong (void) const
 Get the size of the default "long".
 
int4 getSizeOfChar (void) const
 Get the size of the default "char".
 
int4 getSizeOfWChar (void) const
 Get the size of the default "wchar_t".
 
int4 getSizeOfPointer (void) const
 Get the size of pointers.
 
int4 getSizeOfAltPointer (void) const
 Get size of alternate pointers (or 0)
 
ArchitecturegetArch (void) const
 Get the Architecture object.
 
DatatypefindByName (const string &n)
 Return type of given name.
 
DatatypesetName (Datatype *ct, const string &n)
 Set the given types name.
 
void setDisplayFormat (Datatype *ct, uint4 format)
 Set the display format associated with the given data-type.
 
void setFields (const vector< TypeField > &fd, TypeStruct *ot, int4 newSize, int4 newAlign, uint4 flags)
 Set fields on a TypeStruct.
 
void setFields (const vector< TypeField > &fd, TypeUnion *ot, int4 newSize, int4 newAlign, uint4 flags)
 Set fields on a TypeUnion.
 
void setPrototype (const FuncProto *fp, TypeCode *newCode, uint4 flags)
 Set the prototype on a TypeCode.
 
void setEnumValues (const map< uintb, string > &nmap, TypeEnum *te)
 Set named values for an enumeration.
 
DatatypedecodeType (Decoder &decoder)
 Restore Datatype from a stream.
 
DatatypedecodeTypeWithCodeFlags (Decoder &decoder, bool isConstructor, bool isDestructor)
 Restore data-type from an element and extra "code" flags.
 
TypeVoidgetTypeVoid (void)
 Get the "void" data-type.
 
DatatypegetBaseNoChar (int4 s, type_metatype m)
 Get atomic type excluding "char".
 
DatatypegetBase (int4 s, type_metatype m)
 Get atomic type.
 
DatatypegetBase (int4 s, type_metatype m, const string &n)
 Get named atomic type.
 
DatatypegetTypeChar (int4 s)
 Get a character data-type by size.
 
TypeCodegetTypeCode (void)
 Get an "anonymous" function data-type.
 
TypePointergetTypePointerStripArray (int4 s, Datatype *pt, uint4 ws)
 Construct a pointer data-type, stripping an ARRAY level.
 
TypePointergetTypePointer (int4 s, Datatype *pt, uint4 ws)
 Construct an absolute pointer data-type.
 
TypePointergetTypePointer (int4 s, Datatype *pt, uint4 ws, const string &n)
 Construct a named pointer data-type.
 
TypeArraygetTypeArray (int4 as, Datatype *ao)
 Construct an array data-type.
 
TypeStructgetTypeStruct (const string &n)
 Create an (empty) structure.
 
TypePartialStructgetTypePartialStruct (Datatype *contain, int4 off, int4 sz)
 Create a partial structure.
 
TypeUniongetTypeUnion (const string &n)
 Create an (empty) union.
 
TypePartialUniongetTypePartialUnion (TypeUnion *contain, int4 off, int4 sz)
 Create a partial union.
 
TypeEnumgetTypeEnum (const string &n)
 Create an (empty) enumeration.
 
TypePartialEnumgetTypePartialEnum (TypeEnum *contain, int4 off, int4 sz)
 Create a partial enumeration.
 
TypeSpacebasegetTypeSpacebase (AddrSpace *id, const Address &addr)
 Create a "spacebase" type.
 
TypeCodegetTypeCode (const PrototypePieces &proto)
 Create a "function" datatype.
 
DatatypegetTypedef (Datatype *ct, const string &name, uint8 id, uint4 format)
 Create a new typedef data-type.
 
TypePointerRelgetTypePointerRel (TypePointer *parentPtr, Datatype *ptrTo, int4 off)
 Get pointer offset relative to a container.
 
TypePointerRelgetTypePointerRel (int4 sz, Datatype *parent, Datatype *ptrTo, int4 ws, int4 off, const string &nm)
 Build a named pointer offset into a larger container.
 
TypePointergetTypePointerWithSpace (Datatype *ptrTo, AddrSpace *spc, const string &nm)
 Build a named pointer with an address space attribute.
 
TypePointerresizePointer (TypePointer *ptr, int4 newSize)
 Build a resized pointer based on the given pointer.
 
DatatypegetExactPiece (Datatype *ct, int4 offset, int4 size)
 Get the data-type associated with piece of a structured data-type.
 
void destroyType (Datatype *ct)
 Remove a data-type from this.
 
Datatypeconcretize (Datatype *ct)
 Convert given data-type to concrete form.
 
void dependentOrder (vector< Datatype * > &deporder) const
 Place all data-types in dependency order.
 
void encode (Encoder &encoder) const
 Encode this container to stream.
 
void encodeCoreTypes (Encoder &encoder) const
 Encode core types to stream.
 
void decode (Decoder &decoder)
 Decode this from a <typegrp> element.
 
void decodeCoreTypes (Decoder &decoder)
 Initialize basic data-types from a stream.
 
void decodeDataOrganization (Decoder &decoder)
 Parse a <data_organization> element.
 
void parseEnumConfig (Decoder &decoder)
 Parse the <enum> tag.
 
void setCoreType (const string &name, int4 size, type_metatype meta, bool chartp)
 Create a core data-type.
 
void cacheCoreTypes (void)
 Cache common types.
 
list< DatatypeWarning >::const_iterator beginWarnings (void) const
 Start of data-type warnings.
 
list< DatatypeWarning >::const_iterator endWarnings (void) const
 End of data-type warnings.
 

Protected Member Functions

virtual DatatypefindById (const string &n, uint8 id, int4 sz)
 Search by name and/or id.
 
- Protected Member Functions inherited from ghidra::TypeFactory
DatatypefindByIdLocal (const string &nm, uint8 id) const
 Search locally by name and id.
 

Additional Inherited Members

- Protected Attributes inherited from ghidra::TypeFactory
Architectureglb
 The Architecture object that owns this TypeFactory.
 

Detailed Description

An implementation of the TypeFactory interface, query a Ghidra client for data-type information.

Requests for a specific data-type name and id are marshaled to the Ghidra client, which sends back a description of the data-type. The description is parsed and converted into a Datatype object and cached in this object.

Member Function Documentation

◆ findById()

Datatype * ghidra::TypeFactoryGhidra::findById ( const string &  n,
uint8  id,
int4  sz 
)
protectedvirtual

Search by name and/or id.

The id is expected to resolve uniquely. Internally, different length instances of a variable length data-type are stored as separate Datatype objects. A non-zero size can be given to distinguish these cases. Derived classes may search outside this container.

Parameters
nis the name of the data-type
idis the type id of the data-type
szis the given distinguishing size if non-zero
Returns
the matching Datatype object

Reimplemented from ghidra::TypeFactory.

References ghidra::TypeFactory::decodeType(), ghidra::DecoderError::explain, ghidra::TypeFactory::findById(), ghidra::ArchitectureGhidra::getDataType(), and ghidra::TypeFactory::glb.


The documentation for this class was generated from the following files: