Ghidra Decompiler Analysis Engine
|
Go to the documentation of this file.
25 extern void print_data(ostream &s,uint1 *buffer,int4 size,
const Address &baseaddr);
89 static uint8
hashName(
const string &nm);
101 bool isEnumType(
void)
const {
return ((
flags&
enumtype)!=0); }
104 bool isUTF16(
void)
const {
return ((
flags&
utf16)!=0); }
105 bool isUTF32(
void)
const {
return ((
flags&
utf32)!=0); }
109 uint4 getInheritable(
void)
const {
return (
flags &
coretype); }
111 uint8 getId(
void)
const {
return id; }
112 int4 getSize(
void)
const {
return size; }
113 const string &getName(
void)
const {
return name; }
114 virtual void printRaw(ostream &s)
const;
118 virtual int4 numDepend(
void)
const {
return 0; }
120 virtual void printNameBase(ostream &s)
const {
if (!
name.empty()) s<<
name[0]; }
124 virtual void saveXml(ostream &s)
const;
125 int4 typeOrder(
const Datatype &op)
const {
if (
this==&op)
return 0;
return compare(op,10); }
145 if (res != 0)
return (res<0);
146 return a->getId() < b->getId(); }
153 int4 res = a->getName().
compare( b->getName() );
154 if (res != 0)
return (res < 0);
155 return a->getId() < b->getId(); }
192 virtual void saveXml(ostream &s)
const;
208 virtual void saveXml(ostream &s)
const;
224 virtual void saveXml(ostream &s)
const;
242 uint4 getWordSize(
void)
const {
return wordsize; }
243 virtual void printRaw(ostream &s)
const;
244 virtual int4 numDepend(
void)
const {
return 1; }
245 virtual Datatype *getDepend(int4 index)
const {
return ptrto; }
246 virtual void printNameBase(ostream &s)
const { s <<
'p';
ptrto->printNameBase(s); }
250 virtual void saveXml(ostream &s)
const;
269 int4 numElements(
void)
const {
return arraysize; }
271 virtual void printRaw(ostream &s)
const;
273 virtual int4 numDepend(
void)
const {
return 1; }
275 virtual void printNameBase(ostream &s)
const { s <<
'a';
arrayof->printNameBase(s); }
279 virtual void saveXml(ostream &s)
const;
291 void setNameMap(
const map<uintb,string> &nmap);
300 map<uintb,string>::const_iterator beginEnum(
void)
const {
return namemap.begin(); }
301 map<uintb,string>::const_iterator endEnum(
void)
const {
return namemap.end(); }
302 bool getMatches(uintb val,vector<string> &matchname)
const;
306 virtual void saveXml(ostream &s)
const;
314 void setFields(
const vector<TypeField> &fd);
321 vector<TypeField>::const_iterator beginField(
void)
const {
return field.begin(); }
322 vector<TypeField>::const_iterator endField(
void)
const {
return field.end(); }
327 virtual int4 numDepend(
void)
const {
return field.size(); }
328 virtual Datatype *getDepend(int4 index)
const {
return field[index].type; }
332 virtual void saveXml(ostream &s)
const;
347 Datatype *outtype,
const vector<Datatype *> &intypes,
357 virtual void printRaw(ostream &s)
const;
362 virtual void saveXml(ostream &s)
const;
379 spaceid = op.spaceid; localframe=op.localframe;
glb=op.glb;
392 virtual void saveXml(ostream &s)
const;
411 void clearCache(
void);
412 TypeChar *getTypeChar(
const string &n);
425 void setStructAlign(int4 al) { align = al; }
426 int4 getStructAlign(
void)
const {
return align; }
427 int4 getSizeOfInt(
void)
const {
return sizeOfInt; }
433 const vector<uintb> &vallist,
434 const vector<bool> &assignlist,
451 const vector<Datatype *> &intypes,
457 void saveXml(ostream &s)
const;
476 if (
this == &op)
return 0;
bool hasSameVariableBase(const Datatype *ct) const
Are these the same variable length data-type.
Definition: type.cc:70
virtual void restoreXml(const Element *el, TypeFactory &typegrp)
Restore data-type from XML.
Definition: type.cc:457
TypeArray(int4 n, Datatype *ao)
Construct given an array size and element data-type.
Definition: type.hh:266
virtual Datatype * nearestArrayedComponentForward(uintb off, uintb *newoff, int4 *elSize) const
Definition: type.cc:114
TypePointer(void)
Internal constructor for use with restoreXml.
Definition: type.hh:235
TypePointer(int4 s, Datatype *pt, uint4 ws)
Construct from a size, pointed-to type, and wordsize.
Definition: type.hh:240
TypeEnum(int4 s, type_metatype m)
Construct from a size and meta-type (TYPE_INT or TYPE_UINT)
Definition: type.hh:297
A region where processor data is stored.
Definition: space.hh:73
Datatype object representing a pointer.
Definition: type.hh:228
virtual Datatype * clone(void) const
Clone the data-type.
Definition: type.hh:278
uint4 wordsize
What size unit does the pointer address.
Definition: type.hh:232
void metatype2string(type_metatype metatype, string &res)
Convert type meta-type to name.
Definition: type.cc:169
virtual void restoreXml(const Element *el, TypeFactory &typegrp)
Restore data-type from XML.
Definition: type.cc:624
TypeEnum(int4 s, type_metatype m, const string &nm)
Construct from a size, meta-type, and name.
Definition: type.hh:299
virtual void saveXml(ostream &s) const
Serialize the data-type to XML.
Definition: type.cc:613
@ utf32
32-bit wide chars in unicode UTF32
Definition: type.hh:76
TypePointer * getTypePointer(int4 s, Datatype *pt, uint4 ws)
Construct an absolute pointer data-type.
Definition: type.cc:2038
Datatype * getBase(int4 s, type_metatype m)
Get atomic type.
Definition: type.cc:1947
TypePointer(const TypePointer &op)
Construct from another TypePointer.
Definition: type.hh:238
Datatype * restoreXmlType(const Element *el)
Restore Datatype from XML.
Definition: type.cc:2188
int4 arraysize
Number of elements in the array.
Definition: type.hh:258
virtual void printRaw(ostream &s) const
Print a description of the type to stream.
Definition: type.cc:1150
virtual Datatype * getSubType(uintb off, uintb *newoff) const
Recover component data-type one-level down.
Definition: type.cc:100
virtual void saveXml(ostream &s) const
Serialize the data-type to XML.
Definition: type.cc:435
@ TYPE_ARRAY
Array data-type, made up of a sequence of "element" datatype.
Definition: type.hh:44
TypeUnicode(const string &nm, int4 sz, type_metatype m)
Construct given name,size, meta-type.
Definition: type.cc:465
TypeBase(int4 s, type_metatype m)
Construct TypeBase from a size and meta-type.
Definition: type.hh:174
void clearNoncore(void)
Clear out non-core types.
Definition: type.cc:1604
bool isPtrsubMatching(uintb offset) const
Is this data-type suitable as input to a CPUI_PTRSUB op.
Definition: type.cc:323
int4 getFieldIter(int4 off) const
Get index into field list.
Definition: type.cc:847
void saveXml(ostream &s) const
Save this container to stream.
Definition: type.cc:2248
Datatype * ptrto
Type being pointed to.
Definition: type.hh:231
@ opaque_string
Structure that should be treated as a string.
Definition: type.hh:77
Scope * getMap(void) const
Get the symbol table indexed by this.
Definition: type.cc:1309
Datatype * arrayof
type of which we have an array
Definition: type.hh:257
virtual Datatype * getSubType(uintb off, uintb *newoff) const
Recover component data-type one-level down.
Definition: type.cc:1321
void setupSizes(void)
Derive some size information from Architecture.
Definition: type.cc:1495
@ poweroftwo
An enumeration type where all values are of 2^^n form.
Definition: type.hh:74
TypeSpacebase * getTypeSpacebase(AddrSpace *id, const Address &addr)
Create a "spacebase" type.
Definition: type.cc:2107
@ chartype
ASCII character data.
Definition: type.hh:72
@ TYPE_INT
Signed integer. Signed is considered less specific than unsigned in C.
Definition: type.hh:37
virtual Datatype * findById(const string &n, uint8 id)
Search by name and id.
Definition: type.cc:1657
string name
Name of type.
Definition: type.hh:83
void set(TypeFactory *tfact, ProtoModel *model, Datatype *outtype, const vector< Datatype * > &intypes, bool dotdotdot, Datatype *voidtype)
Establish a function pointer.
Definition: type.cc:1101
void print_data(ostream &s, uint1 *buffer, int4 size, const Address &baseaddr)
Print a hex dump of a data buffer to stream.
Definition: type.cc:27
void destroyType(Datatype *ct)
Remove a data-type from this.
Definition: type.cc:2132
bool setEnumValues(const vector< string > &namelist, const vector< uintb > &vallist, const vector< bool > &assignlist, TypeEnum *te)
Set named values for an enumeration.
Definition: type.cc:1818
Datatype(int4 s, type_metatype m)
Construct the base data-type providing size and meta-type.
Definition: type.hh:95
void setFields(const vector< TypeField > &fd)
Establish fields for this.
Definition: type.cc:828
uint8 id
A unique id for the type (or 0 if an id is not assigned)
Definition: type.hh:86
Base type for character data-types: i.e. char.
Definition: type.hh:183
TypeEnum * getTypeEnum(const string &n)
Create an (empty) enumeration.
Definition: type.cc:2095
virtual void printRaw(ostream &s) const
Print a description of the type to stream.
Definition: type.cc:552
static uint8 hashSize(uint8 id, int4 size)
Reversibly hash size into id.
Definition: type.cc:426
virtual Datatype * clone(void) const
Clone the data-type.
Definition: type.hh:207
int4 compareBasic(const TypeCode *op) const
Compare surface characteristics of two TypeCodes.
Definition: type.cc:1177
Datatype * findByIdLocal(const string &nm, uint8 id) const
Search locally by name and id.
Definition: type.cc:1633
Datatype(const Datatype &op)
Construct the base data-type copying low-level properties of another.
Definition: type.hh:93
virtual ~TypeFactory(void)
Destructor.
Definition: type.cc:1623
Datatype object representing executable code.
Definition: type.hh:341
A collection of Symbol objects within a single (namespace or functional) scope.
Definition: database.hh:402
A composite Datatype object: A "structure" with component "fields".
Definition: type.hh:310
virtual void restoreXml(const Element *el, TypeFactory &typegrp)
Restore data-type from XML.
Definition: type.cc:1287
virtual void saveXml(ostream &s) const
Serialize the data-type to XML.
Definition: type.cc:1447
int4 getLowerBoundField(int4 off) const
Get index of last field before or equal to given offset.
Definition: type.cc:871
virtual void restoreXml(const Element *el, TypeFactory &typegrp)
Restore data-type from XML.
Definition: type.cc:537
@ TYPE_SPACEBASE
Placeholder for symbol/type look-up calculations.
Definition: type.hh:35
TypePointer * getTypePointerNoDepth(int4 s, Datatype *pt, uint4 ws)
Construct a depth limited pointer data-type.
Definition: type.cc:2050
Compare two Datatype pointers for equivalence of their description.
Definition: type.hh:141
An XML element. A node in the DOM tree.
Definition: xml.hh:150
@ utf16
16-bit wide chars in unicode UTF16
Definition: type.hh:75
TypeVoid * getTypeVoid(void)
Get the "void" data-type.
Definition: type.cc:1891
virtual int4 compare(const Datatype &op, int4 level) const
Compare for functional equivalence.
Definition: type.cc:559
vector< uintb > masklist
Masks for each bitfield within the enum.
Definition: type.hh:290
virtual void saveXml(ostream &s) const
Serialize the data-type to XML.
Definition: type.cc:268
int4 typeOrderBool(const Datatype &op) const
Order this with -op-, treating bool data-type as special.
Definition: type.hh:473
void restoreXmlCoreTypes(const Element *el)
Initialize basic type names.
Definition: type.cc:2476
Manager for all the major decompiler subsystems.
Definition: architecture.hh:119
Compare two Datatype pointers: first by name, then by id.
Definition: type.hh:150
TypeArray(const TypeArray &op)
Construct from another TypeArray.
Definition: type.hh:264
Datatype * downChain(Datatype *ptrtype, uintb &off)
Find a sub-type matching a pointer and offset.
Definition: type.cc:2150
The unicode data-type: i.e. wchar.
Definition: type.hh:198
virtual Datatype * clone(void) const
Clone the data-type.
Definition: type.hh:177
Datatype * setName(Datatype *ct, const string &n)
Set the given types name.
Definition: type.cc:1732
type_metatype string2metatype(const string &metastring)
Convert string to type meta-type.
Definition: type.cc:214
bool setFields(vector< TypeField > &fd, TypeStruct *ot, int4 fixedsize, uint4 flags)
Set fields on a TypeStruct.
Definition: type.cc:1754
TypeChar(const string &n)
Construct a char (always 1-byte) given a name.
Definition: type.hh:190
@ coretype
This is a basic type which will never be redefined.
Definition: type.hh:66
virtual Datatype * nearestArrayedComponentBackward(uintb off, uintb *newoff, int4 *elSize) const
Definition: type.cc:925
virtual void restoreXml(const Element *el, TypeFactory &typegrp)
Restore data-type from XML.
Definition: type.cc:797
virtual void saveXml(ostream &s) const
Serialize the data-type to XML.
Definition: type.cc:1049
FuncProto * proto
If non-null, this describes the prototype of the underlying function.
Definition: type.hh:344
@ TYPE_PTR
Pointer data-type.
Definition: type.hh:43
An enumerated Datatype object: an integer with named values.
Definition: type.hh:286
A prototype model: a model for passing parameters between functions.
Definition: fspec.hh:622
virtual int4 compare(const Datatype &op, int4 level) const
Compare for functional equivalence.
Definition: type.cc:752
virtual void restoreXml(const Element *el, TypeFactory &typegrp)
Restore data-type from XML.
Definition: type.cc:394
const TypeField * getField(int4 off, int4 sz, int4 *newoff) const
Get field based on offset.
Definition: type.cc:897
static uint8 hashName(const string &nm)
Produce a data-type id by hashing the type name.
Definition: type.cc:404
virtual int4 compare(const Datatype &op, int4 level) const
Compare for functional equivalence.
Definition: type.cc:1413
virtual Datatype * getSubType(uintb off, uintb *newoff) const
Recover component data-type one-level down.
Definition: type.cc:587
void setCoreType(const string &name, int4 size, type_metatype meta, bool chartp)
Create a core data-type.
Definition: type.cc:1522
virtual int4 compareDependency(const Datatype &op) const
Compare for storage in tree structure.
Definition: type.cc:575
Datatype * concretize(Datatype *ct)
Convert given data-type to concrete form.
Definition: type.cc:2173
TypeArray * getTypeArray(int4 as, Datatype *ao)
Construct an array data-type.
Definition: type.cc:2071
virtual Datatype * clone(void) const
Clone the data-type.
Definition: type.hh:391
void setProperties(bool isConstructor, bool isDestructor)
Set additional function properties.
Definition: type.cc:1163
void clear(void)
Clear out all types.
Definition: type.cc:1591
Formal "void" data-type object.
Definition: type.hh:215
int4 offset
Offset (into containing struct) of subfield.
Definition: type.hh:134
virtual Datatype * clone(void) const
Clone the data-type.
Definition: type.hh:249
TypeEnum(const TypeEnum &op)
Construct from another TypeEnum.
Definition: type.cc:637
virtual int4 compare(const Datatype &op, int4 level) const
Compare for functional equivalence.
Definition: type.cc:1220
virtual Datatype * getSubType(uintb off, uintb *newoff) const
Recover component data-type one-level down.
Definition: type.cc:913
Base class for the fundamental atomic types.
Definition: type.hh:167
virtual void saveXml(ostream &s) const
Serialize the data-type to XML.
Definition: type.cc:525
type_metatype metatype
Meta-type - type disregarding size.
Definition: type.hh:84
bool getMatches(uintb val, vector< string > &matchname) const
Recover the named representation.
Definition: type.cc:715
map< uintb, string > namemap
Map from integer to name.
Definition: type.hh:289
TypeBase(int4 s, type_metatype m, const string &n)
Construct TypeBase from a size, meta-type, and name.
Definition: type.hh:176
bool operator()(const Datatype *a, const Datatype *b) const
Comparison operator.
Definition: type.hh:143
TypeStruct * getTypeStruct(const string &n)
Create an (empty) structure.
Definition: type.cc:2081
void parseDataOrganization(const Element *el)
Parse the <data_organization> tag.
Definition: type.cc:2493
string name
Name of subfield.
Definition: type.hh:135
virtual int4 compareDependency(const Datatype &op) const
Compare for storage in tree structure.
Definition: type.cc:1419
void restoreXmlBasic(const Element *el)
Recover basic data-type properties.
Definition: type.cc:351
void parseEnumConfig(const Element *el)
Parse the <enum> tag.
Definition: type.cc:2527
uint4 flags
Boolean properties of the type.
Definition: type.hh:85
Specifies subfields of a structure or what a pointer points to.
Definition: type.hh:133
void dependentOrder(vector< Datatype * > &deporder) const
Place all data-types in dependency order.
Definition: type.cc:1879
TypeArray(void)
Internal constructor for restoreXml.
Definition: type.hh:261
set< Datatype *, DatatypeNameCompare > DatatypeNameSet
A set of data-types sorted by name.
Definition: type.hh:162
Address getAddress(uintb off, int4 sz, const Address &point) const
Construct an Address given an offset.
Definition: type.cc:1437
A low-level machine address for labelling bytes and data.
Definition: address.hh:46
void restoreXml(const Element *el)
Restore this container from a stream.
Definition: type.cc:2448
virtual void printRaw(ostream &s) const
Print a description of the type to stream.
Definition: type.cc:486
TypeFactory(Architecture *g)
Construct a factory.
Definition: type.cc:1470
void saveXmlRef(ostream &s) const
Write an XML reference of this to stream.
Definition: type.cc:306
The base datatype class for the decompiler.
Definition: type.hh:62
Datatype object representing an array of elements.
Definition: type.hh:254
@ TYPE_VOID
Standard "void" type, absence of type.
Definition: type.hh:34
Container class for all Datatype objects in an Architecture.
Definition: type.hh:396
virtual void saveXml(ostream &s) const
Serialize the data-type to XML.
Definition: type.cc:1276
virtual Datatype * clone(void) const
Clone the data-type.
Definition: type.hh:305
int4 size
Size (of variable holding a value of this type)
Definition: type.hh:82
virtual int4 compareDependency(const Datatype &op) const
Compare for storage in tree structure.
Definition: type.cc:150
void saveXmlCoreTypes(ostream &s) const
Save core types to stream.
Definition: type.cc:2279
bool operator()(const Datatype *a, const Datatype *b) const
Comparison operator.
Definition: type.hh:152
@ TYPE_CODE
Data is actual executable code.
Definition: type.hh:40
void setNameMap(const map< uintb, string > &nmap)
Establish the value -> name map.
Definition: type.cc:648
Datatype * getBaseNoChar(int4 s, type_metatype m)
Get atomic type excluding "char".
Definition: type.cc:1935
TypeStruct(const TypeStruct &op)
Construct from another TypeStruct.
Definition: type.cc:818
Datatype * restoreXmlTypeWithCodeFlags(const Element *el, bool isConstructor, bool isDestructor)
Restore data-type from XML with extra "code" flags.
Definition: type.cc:2220
TypePointer * getTypePointerStripArray(int4 s, Datatype *pt, uint4 ws)
Construct a pointer data-type, stripping an ARRAY level.
Definition: type.cc:2024
Datatype * getSubEntry(int4 off, int4 sz, int4 *newoff, int4 *el) const
Figure out what a byte range overlaps.
Definition: type.cc:601
TypeCode * getTypeCode(void)
Get an "anonymous" function data-type.
Definition: type.cc:1994
@ TYPE_UNKNOWN
An unknown low-level type. Treated as an unsigned integer.
Definition: type.hh:36
virtual Datatype * clone(void) const =0
Clone the data-type.
@ TYPE_STRUCT
Structure data-type, made up of component datatypes.
Definition: type.hh:45
Special Datatype object used to describe pointers that index into the symbol table.
Definition: type.hh:370
virtual Datatype * clone(void) const
Clone the data-type.
Definition: type.hh:361
virtual Datatype * clone(void) const
Clone the data-type.
Definition: type.hh:223
TypeCode(const TypeCode &op)
Construct from another TypeCode.
Definition: type.cc:1125
virtual void restoreXml(const Element *el, TypeFactory &typegrp)
Restore data-type from XML.
Definition: type.cc:1067
TypeBase(const TypeBase &op)
Construct TypeBase copying properties from another data-type.
Definition: type.hh:172
TypeFactory * factory
Factory owning this.
Definition: type.hh:345
set< Datatype *, DatatypeCompare > DatatypeSet
A set of data-types sorted by function.
Definition: type.hh:159
virtual Datatype * clone(void) const
Clone the data-type.
Definition: type.hh:331
virtual Datatype * clone(void) const
Clone the data-type.
Definition: type.hh:191
virtual Datatype * nearestArrayedComponentBackward(uintb off, uintb *newoff, int4 *elSize) const
Definition: type.cc:127
Architecture * glb
The Architecture object that owns this TypeFactory.
Definition: type.hh:416
TypeVoid(void)
Constructor.
Definition: type.hh:222
Datatype * type
type of subfield
Definition: type.hh:136
virtual Datatype * getSubType(uintb off, uintb *newoff) const
Recover component data-type one-level down.
Definition: type.cc:1212
TypeVoid(const TypeVoid &op)
Construct from another TypeVoid.
Definition: type.hh:220
TypeSpacebase(AddrSpace *id, const Address &frame, Architecture *g)
Construct given an address space, scope, and architecture.
Definition: type.hh:382
@ variable_length
May be other structures with same name different lengths.
Definition: type.hh:78
virtual void printRaw(ostream &s) const
Print a description of the type to stream.
Definition: type.cc:83
Classes for specifying addresses and other low-level constants.
TypeSpacebase(const TypeSpacebase &op)
Construct from another TypeSpacebase.
Definition: type.hh:378
@ enumtype
An enumeration type (as well as an integer)
Definition: type.hh:73
void saveXmlBasic(ostream &s) const
Save basic data-type properties.
Definition: type.cc:279
virtual Datatype * nearestArrayedComponentForward(uintb off, uintb *newoff, int4 *elSize) const
Definition: type.cc:1345
virtual void saveXml(ostream &s) const
Serialize the data-type to XML.
Definition: type.cc:471
virtual int4 compare(const Datatype &op, int4 level) const
Compare for functional equivalence.
Definition: type.cc:493
vector< TypeField > field
The list of fields.
Definition: type.hh:313
A function prototype.
Definition: fspec.hh:1164
type_metatype
Definition: type.hh:33
virtual int4 compareDependency(const Datatype &op) const
Compare for storage in tree structure.
Definition: type.cc:1250
@ TYPE_BOOL
Boolean.
Definition: type.hh:39
virtual int4 compare(const Datatype &op, int4 level) const
Compare for functional equivalence.
Definition: type.cc:139
virtual int4 compareDependency(const Datatype &op) const
Compare for storage in tree structure.
Definition: type.cc:758
virtual void saveXml(ostream &s) const
Serialize the data-type to XML.
Definition: type.cc:480
virtual Datatype * nearestArrayedComponentForward(uintb off, uintb *newoff, int4 *elSize) const
Definition: type.cc:952
virtual int4 compareDependency(const Datatype &op) const
Compare for storage in tree structure.
Definition: type.cc:511
TypeChar(const TypeChar &op)
Construct TypeChar copying properties from another data-type.
Definition: type.hh:188
Datatype * findByName(const string &n)
Return type of given name.
Definition: type.cc:1666
virtual void saveXml(ostream &s) const
Serialize the data-type to XML.
Definition: type.cc:780
@ TYPE_FLOAT
Floating-point.
Definition: type.hh:41
virtual int4 compareDependency(const Datatype &op) const
Compare for storage in tree structure.
Definition: type.cc:1021
@ TYPE_UINT
Unsigned integer.
Definition: type.hh:38
Datatype(int4 s, type_metatype m, const string &n)
Construct the base data-type providing size, meta-type, and name.
Definition: type.hh:97
void cacheCoreTypes(void)
Cache common types.
Definition: type.cc:1544
virtual int4 compare(const Datatype &op, int4 level) const
Compare for functional equivalence.
Definition: type.cc:980
virtual Datatype * nearestArrayedComponentBackward(uintb off, uintb *newoff, int4 *elSize) const
Definition: type.cc:1394