decompiler  1.0.0
Classes | Typedefs | Enumerations | Functions
type.hh File Reference

Classes for describing and printing data-types. More...

#include "address.hh"

Classes

class  ghidra::Datatype
 The base datatype class for the decompiler. More...
 
class  ghidra::TypeField
 A field within a structure or union. More...
 
struct  ghidra::DatatypeCompare
 Compare two Datatype pointers for equivalence of their description. More...
 
struct  ghidra::DatatypeNameCompare
 Compare two Datatype pointers: first by name, then by id. More...
 
class  ghidra::TypeBase
 Base class for the fundamental atomic types. More...
 
class  ghidra::TypeChar
 Base type for character data-types: i.e. char. More...
 
class  ghidra::TypeUnicode
 The unicode data-type: i.e. wchar. More...
 
class  ghidra::TypeVoid
 Formal "void" data-type object. More...
 
class  ghidra::TypePointer
 Datatype object representing a pointer. More...
 
class  ghidra::TypeArray
 Datatype object representing an array of elements. More...
 
class  ghidra::TypeEnum
 An enumerated Datatype object: an integer with named values. More...
 
class  ghidra::TypeStruct
 A composite Datatype object: A structure with component fields. More...
 
class  ghidra::TypeUnion
 A collection of overlapping Datatype objects: A union of component fields. More...
 
class  ghidra::TypePartialStruct
 A data-type that holds part of a TypeStruct or TypeArray. More...
 
class  ghidra::TypePartialUnion
 An internal data-type for holding information about a variable's relative position within a union data-type. More...
 
class  ghidra::TypePointerRel
 Relative pointer: A pointer with a fixed offset into a specific structure or other data-type. More...
 
class  ghidra::TypeCode
 Datatype object representing executable code. More...
 
class  ghidra::TypeSpacebase
 Special Datatype object used to describe pointers that index into the symbol table. More...
 
class  ghidra::TypeFactory
 Container class for all Datatype objects in an Architecture. More...
 

Typedefs

typedef set< Datatype *, DatatypeCompare > ghidra::DatatypeSet
 A set of data-types sorted by function.
 
typedef set< Datatype *, DatatypeNameCompare > ghidra::DatatypeNameSet
 A set of data-types sorted by name.
 

Enumerations

enum  ghidra::type_metatype {
  ghidra::TYPE_VOID = 14, ghidra::TYPE_SPACEBASE = 13, ghidra::TYPE_UNKNOWN = 12, ghidra::TYPE_INT = 11,
  ghidra::TYPE_UINT = 10, ghidra::TYPE_BOOL = 9, ghidra::TYPE_CODE = 8, ghidra::TYPE_FLOAT = 7,
  ghidra::TYPE_PTR = 6, ghidra::TYPE_PTRREL = 5, ghidra::TYPE_ARRAY = 4, ghidra::TYPE_STRUCT = 3,
  ghidra::TYPE_UNION = 2, ghidra::TYPE_PARTIALSTRUCT = 1, ghidra::TYPE_PARTIALUNION = 0
}
 
enum  ghidra::sub_metatype {
  ghidra::SUB_VOID = 22, ghidra::SUB_SPACEBASE = 21, ghidra::SUB_UNKNOWN = 20, ghidra::SUB_PARTIALSTRUCT = 19,
  ghidra::SUB_INT_CHAR = 18, ghidra::SUB_UINT_CHAR = 17, ghidra::SUB_INT_PLAIN = 16, ghidra::SUB_UINT_PLAIN = 15,
  ghidra::SUB_INT_ENUM = 14, ghidra::SUB_UINT_ENUM = 13, ghidra::SUB_INT_UNICODE = 12, ghidra::SUB_UINT_UNICODE = 11,
  ghidra::SUB_BOOL = 10, ghidra::SUB_CODE = 9, ghidra::SUB_FLOAT = 8, ghidra::SUB_PTRREL_UNK = 7,
  ghidra::SUB_PTR = 6, ghidra::SUB_PTRREL = 5, ghidra::SUB_PTR_STRUCT = 4, ghidra::SUB_ARRAY = 3,
  ghidra::SUB_STRUCT = 2, ghidra::SUB_UNION = 1, ghidra::SUB_PARTIALUNION = 0
}
 

Functions

void ghidra::print_data (ostream &s, uint1 *buffer, int4 size, const Address &baseaddr)
 Print a hex dump of a data buffer to stream. More...
 
void ghidra::metatype2string (type_metatype metatype, string &res)
 Convert type meta-type to name. More...
 
type_metatype ghidra::string2metatype (const string &metastring)
 Convert string to type meta-type. More...
 

Detailed Description

Classes for describing and printing data-types.

Enumeration Type Documentation

◆ sub_metatype

Specializations of the core meta-types. Each enumeration is associated with a specific #type_metatype. Ordering is important: The lower the number, the more specific the data-type, affecting propagation.

Enumerator
SUB_VOID 

Compare as a TYPE_VOID.

SUB_SPACEBASE 

Compare as a TYPE_SPACEBASE.

SUB_UNKNOWN 

Compare as a TYPE_UNKNOWN.

SUB_PARTIALSTRUCT 

Compare as TYPE_PARTIALSTRUCT.

SUB_INT_CHAR 

Signed 1-byte character, sub-type of TYPE_INT.

SUB_UINT_CHAR 

Unsigned 1-byte character, sub-type of TYPE_UINT.

SUB_INT_PLAIN 

Compare as a plain TYPE_INT.

SUB_UINT_PLAIN 

Compare as a plain TYPE_UINT.

SUB_INT_ENUM 

Signed enum, sub-type of TYPE_INT.

SUB_UINT_ENUM 

Unsigned enum, sub-type of TYPE_UINT.

SUB_INT_UNICODE 

Signed wide character, sub-type of TYPE_INT.

SUB_UINT_UNICODE 

Unsigned wide character, sub-type of TYPE_UINT.

SUB_BOOL 

Compare as TYPE_BOOL.

SUB_CODE 

Compare as TYPE_CODE.

SUB_FLOAT 

Compare as TYPE_FLOAT.

SUB_PTRREL_UNK 

Pointer to unknown field of struct, sub-type of TYPE_PTR.

SUB_PTR 

Compare as TYPE_PTR.

SUB_PTRREL 

Pointer relative to another data-type, sub-type of TYPE_PTR.

SUB_PTR_STRUCT 

Pointer into struct, sub-type of TYPE_PTR.

SUB_ARRAY 

Compare as TYPE_ARRAY.

SUB_STRUCT 

Compare as TYPE_STRUCT.

SUB_UNION 

Compare as TYPE_UNION.

SUB_PARTIALUNION 

Compare as a TYPE_PARTIALUNION.

◆ type_metatype

The core meta-types supported by the decompiler. These are sizeless templates for the elements making up the type algebra. Index is important for Datatype::base2sub array.

Enumerator
TYPE_VOID 

Standard "void" type, absence of type.

TYPE_SPACEBASE 

Placeholder for symbol/type look-up calculations.

TYPE_UNKNOWN 

An unknown low-level type. Treated as an unsigned integer.

TYPE_INT 

Signed integer. Signed is considered less specific than unsigned in C.

TYPE_UINT 

Unsigned integer.

TYPE_BOOL 

Boolean.

TYPE_CODE 

Data is actual executable code.

TYPE_FLOAT 

Floating-point.

TYPE_PTR 

Pointer data-type.

TYPE_PTRREL 

Pointer relative to another data-type (specialization of TYPE_PTR)

TYPE_ARRAY 

Array data-type, made up of a sequence of "element" datatype.

TYPE_STRUCT 

Structure data-type, made up of component datatypes.

TYPE_UNION 

An overlapping union of multiple datatypes.

TYPE_PARTIALSTRUCT 

Part of a structure, stored separately from the whole.

TYPE_PARTIALUNION 

Part of a union.

Function Documentation

◆ metatype2string()

void ghidra::metatype2string ( type_metatype  metatype,
string &  res 
)

Convert type meta-type to name.

Convert a type meta-type into the string name of the meta-type

Parameters
metatypeis the encoded type meta-type
reswill hold the resulting string

◆ print_data()

void ghidra::print_data ( ostream &  s,
uint1 *  buffer,
int4  size,
const Address baseaddr 
)

Print a hex dump of a data buffer to stream.

Display an array of bytes as a hex dump at a given address. Each line displays an address and 16 bytes in hexadecimal

Parameters
sis the stream to write to
bufferis a pointer to the bytes
sizeis the number of bytes
baseaddris the address of the first byte in the buffer

◆ string2metatype()

type_metatype ghidra::string2metatype ( const string &  metastring)

Convert string to type meta-type.

Given a string description of a type meta-type. Return the meta-type.

Parameters
metastringis the description of the meta-type
Returns
the encoded type meta-type