Ghidra Decompiler Analysis Engine
|
Go to the documentation of this file.
23 #ifndef __CPUI_DATABASE__
24 #define __CPUI_DATABASE__
76 : uselimit(ul) { symbol = sym; extraflags=exfl; space = spc; offset = off; }
96 if (val) { useindex=0xffff; }
97 else { useindex=0; useoffset=0; }
101 useindex = op2.useindex;
102 useoffset = op2.useoffset;
106 if (useindex != op2.useindex)
107 return (useindex < op2.useindex);
108 return (useoffset < op2.useoffset);
118 bool isDynamic(
void)
const {
return addr.
isInvalid(); }
119 bool isInvalid(
void)
const {
return (addr.
isInvalid() && (hash==0)); }
121 int4 getOffset(
void)
const {
return offset; }
122 uintb getFirst(
void)
const {
return addr.
getOffset(); }
123 uintb getLast(
void)
const {
return (addr.
getOffset()+size-1); }
125 Symbol *getSymbol(
void)
const {
return symbol; }
126 const Address &getAddr(
void)
const {
return addr; }
127 uint8 getHash(
void)
const {
return hash; }
128 int4 getSize(
void)
const {
return size; }
130 const RangeList &getUseLimit(
void)
const {
return uselimit; }
132 void setUseLimit(
const RangeList &uselim) { uselimit = uselim; }
137 void saveXml(ostream &s)
const;
192 const string &getName(
void)
const {
return name; }
194 uint8 getId(
void)
const {
return symbolId; }
195 uint4 getFlags(
void)
const {
return flags; }
196 uint4 getDisplayFormat(
void)
const {
return (
dispflags & 7); }
197 int2 getCategory(
void)
const {
return category; }
198 uint2 getCategoryIndex(
void)
const {
return catindex; }
206 bool isMultiEntry(
void)
const {
return (
wholeCount > 1); }
214 int4 numEntries(
void)
const {
return mapentry.size(); }
222 virtual void saveXml(ostream &s)
const;
240 return extraflags | symbol->getFlags();
255 void buildType(
void);
260 virtual void saveXml(ostream &s)
const;
274 uintb getValue(
void)
const {
return value; }
276 virtual void saveXml(ostream &s)
const;
282 void buildType(
void);
286 virtual void saveXml(ostream &s)
const;
298 void buildNameType(
void);
303 const Address &getRefAddr(
void)
const {
return refaddr; }
304 virtual void saveXml(ostream &s)
const;
318 int4 comp = sym1->
name.compare(sym2->
name);
319 if (comp < 0)
return true;
320 if (comp > 0)
return false;
331 const vector<EntryMap *> *map;
332 vector<EntryMap *>::const_iterator curmap;
333 list<SymbolEntry>::const_iterator curiter;
335 MapIterator(
void) { map = (
const vector<EntryMap *> *)0; }
343 vector<EntryMap *>::const_iterator cm,
344 list<SymbolEntry>::const_iterator ci) {
345 map = m; curmap = cm; curiter = ci;
350 map = op2.map; curmap = op2.curmap; curiter = op2.curiter;
352 const SymbolEntry *operator*(
void)
const {
return &(*curiter); }
360 curiter = op2.curiter;
366 if (curmap != op2.curmap)
return false;
367 if (curmap == map->end())
return true;
368 return (curiter==op2.curiter);
373 if (curmap != op2.curmap)
return true;
374 if (curmap == map->end())
return false;
375 return (curiter!=op2.curiter);
404 friend class ScopeCompare;
409 void attachScope(
Scope *child);
410 void detachScope(ScopeMap::iterator iter);
411 static uint8 hashScopeName(uint8 baseId,
const string &nm);
445 const RangeList &getRangeTree(
void)
const {
return rangetree; }
496 void setSymbolId(
Symbol *sym,uint8
id)
const { sym->
symbolId = id; }
498 #ifdef OPACTION_DEBUG
499 mutable bool debugon;
500 void turnOnDebug(
void)
const { debugon =
true; }
501 void turnOffDebug(
void)
const { debugon =
false; }
506 #ifdef OPACTION_DEBUG
513 virtual list<SymbolEntry>::const_iterator
beginDynamic(
void)
const=0;
514 virtual list<SymbolEntry>::const_iterator
endDynamic(
void)
const=0;
515 virtual list<SymbolEntry>::iterator
beginDynamic(
void)=0;
516 virtual list<SymbolEntry>::iterator
endDynamic(
void)=0;
517 virtual void clear(
void)=0;
536 return rangetree.
inRange(addr,size); }
568 const Address &usepoint)
const=0;
577 const Address &usepoint)
const=0;
609 virtual void findByName(
const string &
name,vector<Symbol *> &res)
const=0;
636 Datatype *ct,int4 &index,uint4 flags)
const=0;
649 virtual void saveXml(ostream &s)
const=0;
676 const string &getName(
void)
const {
return name; }
677 uint8 getId(
void)
const {
return uniqueId; }
678 bool isGlobal(
void)
const {
return (
fd == (
Funcdata *)0); }
684 const Address &usepoint)
const;
686 const Address &usepoint)
const;
688 const Address &usepoint,uint4 &flags)
const;
695 ScopeMap::const_iterator childrenBegin()
const {
return children.begin(); }
696 ScopeMap::const_iterator childrenEnd()
const {
return children.end(); }
706 Scope *getParent(
void)
const {
return parent; }
717 void printBounds(ostream &s)
const { rangetree.
printBounds(s); }
727 void processHole(
const Element *el);
728 void processCollision(
const Element *el);
729 void insertNameTree(
Symbol *sym);
730 SymbolNameTree::const_iterator findFirstByName(
const string &
name)
const;
746 virtual void clear(
void);
755 virtual list<SymbolEntry>::const_iterator
beginDynamic(
void)
const;
756 virtual list<SymbolEntry>::const_iterator
endDynamic(
void)
const;
758 virtual list<SymbolEntry>::iterator
endDynamic(
void);
769 const Address &usepoint)
const;
771 const Address &usepoint)
const;
777 virtual void findByName(
const string &
name,vector<Symbol *> &res)
const;
783 Datatype *ct,int4 &index,uint4 flags)
const;
786 virtual void saveXml(ostream &s)
const;
793 set<Symbol *>::const_iterator beginMultiEntry(
void)
const {
return multiEntrySet.begin(); }
794 set<Symbol *>::const_iterator endMultiEntry(
void)
const {
return multiEntrySet.end(); }
808 NullSubsort(
bool val) {}
809 NullSubsort(
const NullSubsort &op2) {}
810 bool operator<(
const NullSubsort &op2) {
return false; }
822 scope = data; first = f; last = l; }
823 Address getFirst(
void)
const {
return first; }
824 Address getLast(
void)
const {
return last; }
825 NullSubsort getSubsort(
void)
const {
return NullSubsort(); }
826 Scope *getScope(
void)
const {
return scope; }
851 void clearResolve(
Scope *scope);
852 void clearReferences(
Scope *scope);
853 void fillResolve(
Scope *scope);
867 Scope *getGlobalScope(
void)
const {
return globalscope; }
874 uint4 getProperty(
const Address &addr)
const {
return flagbase.
getValue(addr); }
878 void saveXml(ostream &s)
const;
const Scope * mapScope(const Scope *qpoint, const Address &addr, const Address &usepoint) const
Determine the lowest-level Scope which might contain the given address as a Symbol.
Definition: database.cc:3077
virtual void clearUnlocked(void)=0
Clear all unlocked symbols from this scope.
MapIterator & operator++(void)
Pre-increment the iterator.
Definition: database.cc:787
virtual Symbol * getCategorySymbol(int4 cat, int4 ind) const
Retrieve a Symbol by index within a specific category.
Definition: database.cc:2713
SymbolEntry * queryByAddr(const Address &addr, const Address &usepoint) const
Get Symbol with matching address.
Definition: database.cc:1192
_valuetype & getValue(const _linetype &pnt)
Get the value object at a point.
Definition: partmap.hh:81
virtual void findByName(const string &name, vector< Symbol * > &res) const =0
Find a Symbol by name within this Scope.
SymbolNameTree nametree
The set of Symbol objects, sorted by name.
Definition: database.hh:737
virtual Symbol * getCategorySymbol(int4 cat, int4 ind) const =0
Retrieve a Symbol by index within a specific category.
@ namelock
The Name of the Varnode is locked.
Definition: varnode.hh:83
uint4 flags
Varnode-like properties of the symbol.
Definition: database.hh:161
The base class API for emitting a high-level language.
Definition: printlanguage.hh:134
virtual int4 getBytesConsumed(void) const
Get number of bytes consumed within the address->symbol map.
Definition: database.hh:262
void setRange(Scope *scope, const RangeList &rlist)
Set the ownership range for a Scope.
Definition: database.cc:2933
~Database(void)
Destructor.
Definition: database.cc:2830
@ force_char
Force integer to be printed as a character constant.
Definition: database.hh:183
virtual void clearAttribute(Symbol *sym, uint4 attr)=0
Clear boolean Varnode properties on a Symbol.
ExternRefSymbol(Scope *sc, const Address &ref, const string &nm)
Construct given a placeholder address.
Definition: database.cc:752
MapIterator(const vector< EntryMap * > *m, vector< EntryMap * >::const_iterator cm, list< SymbolEntry >::const_iterator ci)
Construct iterator at a specific position.
Definition: database.hh:342
A region where processor data is stored.
Definition: space.hh:73
bool isReadOnly(const Address &addr, int4 size, const Address &usepoint) const
Is the given memory range marked as read-only.
Definition: database.cc:1711
string name
The local name of the symbol.
Definition: database.hh:158
virtual MapIterator end(void) const
Ending iterator to mapped SymbolEntrys.
Definition: database.cc:1827
virtual void restoreXml(const Element *el)
Restore this Symbol from an XML stream.
Definition: database.cc:678
The partmap<> template mapping a linear space to value objects.
virtual void restoreXml(const Element *el)=0
Restore this Scope from a <scope> XML tag.
virtual Funcdata * resolveExternalRefFunction(ExternRefSymbol *sym) const =0
Convert an external reference to the referenced function.
ScopeInternal(uint8 id, const string &nm, Architecture *g)
Construct the Scope.
Definition: database.cc:1861
@ hiddenretparm
Does this varnode point to the return value storage location.
Definition: varnode.hh:104
string buildDefaultName(Symbol *sym, int4 &base, Varnode *vn) const
Create a default name for the given Symbol.
Definition: database.cc:1671
virtual void adjustCaches(void)
Let scopes internally adjust any caches.
Definition: database.cc:2017
A function Symbol referring to an external location.
Definition: database.hh:296
LabSymbol * addCodeLabel(const Address &addr, const string &nm)
Create a code label at the given address in this Scope.
Definition: database.cc:1624
const Scope * findDistinguishingScope(const Scope *op2) const
Find first ancestor of this not shared by given scope.
Definition: database.cc:1442
EntrySubsort(const EntrySubsort &op2)
Copy constructor.
Definition: database.hh:100
uint8 nextUniqueId
Next available symbol id.
Definition: database.hh:742
Database(Architecture *g, bool idByName)
Constructor.
Definition: database.cc:2821
virtual void renameSymbol(Symbol *sym, const string &newname)
Rename a Symbol within this Scope.
Definition: database.cc:2058
virtual string makeNameUnique(const string &nm) const =0
Produce a version of the given symbol name that won't collide with other names in this Scope.
Scope * discoverScope(const Address &addr, int4 sz, const Address &usepoint)
Find the owning Scope of a given memory range.
Definition: database.cc:1314
bool inUse(const Address &usepoint) const
Is this storage valid for the given code address.
Definition: database.cc:90
Address linetype
The linear element for a rangemap.
Definition: database.hh:813
int4 depthResolution
Number of namespace elements required to resolve symbol in current scope.
Definition: database.hh:170
@ force_hex
Force hexadecimal printing of constant symbol.
Definition: database.hh:179
virtual MapIterator begin(void) const =0
Beginning iterator to mapped SymbolEntrys.
virtual ExternRefSymbol * findExternalRef(const Address &addr) const
Find an external reference at the given address.
Definition: database.cc:2243
An in-memory implementation of the Scope interface.
Definition: database.hh:726
virtual ExternRefSymbol * findExternalRef(const Address &addr) const =0
Find an external reference at the given address.
Scope * resolveScope(const string &name, bool strategy) const
Find a child Scope of this.
Definition: database.cc:1276
bool inRange(const Address &addr, int4 size) const
Check containment an address range.
Definition: address.cc:402
const Scope * depthScope
Scope associated with current depth resolution.
Definition: database.hh:169
uint4 getAllFlags(void) const
Get all Varnode flags for this storage.
Definition: database.hh:239
void setDisplayFormat(uint4 val)
Set the display format for this Symbol.
Definition: database.hh:230
virtual SymbolEntry * findClosestFit(const Address &addr, int4 size, const Address &usepoint) const =0
Find Symbol which is the closest fit to the given memory range.
LabSymbol * queryCodeLabel(const Address &addr) const
Look-up a code label by address.
Definition: database.cc:1262
void setPropertyRange(uint4 flags, const Range &range)
Set boolean properties over a given memory range.
Definition: database.cc:3112
virtual void addRange(AddrSpace *spc, uintb first, uintb last)
Add a memory range to the ownership of this Scope.
Definition: database.cc:1066
virtual list< SymbolEntry >::const_iterator beginDynamic(void) const =0
Beginning iterator to dynamic SymbolEntrys.
void printEntry(ostream &s) const
Dump a description of this to a stream.
Definition: database.cc:155
string getFullName(void) const
Get the full name of this Scope.
Definition: database.cc:1404
void overrideSizeLockType(Symbol *sym, Datatype *ct)
Change the data-type of a Symbol that is sizelocked.
Definition: database.cc:1348
virtual void restoreXml(const Element *el)
Restore this Symbol from an XML stream.
Definition: database.cc:769
void queryByName(const string &name, vector< Symbol * > &res) const
Look-up symbols by name.
Definition: database.cc:1159
Scope * scope
The scope that owns this symbol.
Definition: database.hh:157
virtual void setAttribute(Symbol *sym, uint4 attr)=0
Set boolean Varnode properties on a Symbol.
MapIterator(const MapIterator &op2)
Copy constructor.
Definition: database.hh:349
SymbolEntry * queryContainer(const Address &addr, int4 size, const Address &usepoint) const
Find the smallest containing Symbol.
Definition: database.cc:1207
static const Scope * stackAddr(const Scope *scope1, const Scope *scope2, const Address &addr, const Address &usepoint, SymbolEntry **addrmatch)
Query for Symbols starting at a given address, which match a given usepoint.
Definition: database.cc:870
An interval map container.
Definition: rangemap.hh:64
Scope * inittype
Initialization data for a ScopeMapper.
Definition: database.hh:815
bool isNameUndefined(void) const
Does this have an undefined name.
Definition: database.cc:239
LabSymbol(Scope *sc, const string &nm)
Construct given name.
Definition: database.cc:704
rangemap< ScopeMapper > ScopeResolve
A map from address to the owning Scope.
Definition: database.hh:828
virtual void adjustCaches(void)=0
Let scopes internally adjust any caches.
virtual void printEntries(ostream &s) const
Dump a description of all SymbolEntry objects to a stream.
Definition: database.cc:2690
virtual void clearUnlockedCategory(int4 cat)=0
Clear unlocked symbols of the given category from this scope.
virtual MapIterator end(void) const =0
Ending iterator to mapped SymbolEntrys.
An iterator over SymbolEntry objects in multiple address spaces.
Definition: database.hh:330
bool isSubScope(const Scope *scp) const
Is this a sub-scope of the given Scope.
Definition: database.cc:1393
Datatype * getSizedType(const Address &addr, int4 sz) const
Get the data-type associated with (a piece of) this.
Definition: database.cc:127
EntryInitData inittype
Initialization data for a SymbolEntry in a rangemap.
Definition: database.hh:113
Funcdata * queryExternalRefFunction(const Address &addr) const
Look-up a function thru an external reference.
Definition: database.cc:1377
void restoreXmlBody(List::const_iterator iter)
Restore details of the Symbol from XML.
Definition: database.cc:509
virtual void setCategory(Symbol *sym, int4 cat, int4 ind)=0
Set the category and index for the given Symbol.
void adjustCaches(void)
Let scopes adjust after configuration is finished.
Definition: database.cc:2872
Funcdata * fd
(If non-null) the function which this is the local Scope for
Definition: database.hh:415
void restoreXmlScope(const Element *el, Scope *newScope)
Register and fill out a single Scope from an XML <scope> tag.
Definition: database.cc:3233
A collection of Symbol objects within a single (namespace or functional) scope.
Definition: database.hh:402
SymbolEntry * addMapPoint(Symbol *sym, const Address &addr, const Address &usepoint)
Map a Symbol to a specific address.
Definition: database.cc:1507
list< SymbolEntry > dynamicentry
Dynamic symbol entries.
Definition: database.hh:740
bool isInvalid(void) const
Is the address invalid?
Definition: address.hh:256
uintb getOffset(void) const
Get the address offset.
Definition: address.hh:300
Symbol * addMapSym(const Element *el)
Add a mapped Symbol from a <mapsym> XML tag.
Definition: database.cc:1523
uint4 dispflags
Flags affecting the display of this symbol.
Definition: database.hh:164
uint4 wholeCount
Number of SymbolEntries that map to the whole Symbol.
Definition: database.hh:171
virtual SymbolEntry * addDynamicMapInternal(Symbol *sym, uint4 exfl, uint8 hash, int4 off, int4 sz, const RangeList &uselim)
Create a new SymbolEntry for a Symbol given a dynamic hash.
Definition: database.cc:1787
map< uint8, Scope * > ScopeMap
A map from id to Scope.
Definition: database.hh:379
static const Scope * stackExternalRef(const Scope *scope1, const Scope *scope2, const Address &addr, ExternRefSymbol **addrmatch)
Definition: database.cc:1001
virtual SymbolEntry * findClosestFit(const Address &addr, int4 size, const Address &usepoint) const
Find Symbol which is the closest fit to the given memory range.
Definition: database.cc:2185
An XML element. A node in the DOM tree.
Definition: xml.hh:150
virtual void addSymbolInternal(Symbol *sym)
Put a Symbol into the name map.
Definition: database.cc:1725
void clearUnlocked(Scope *scope)
Clear unlocked Symbols owned by the given Scope.
Definition: database.cc:2917
virtual void removeSymbolMappings(Symbol *symbol)=0
Remove all SymbolEntrys from the given Symbol.
@ typelock
The Dataype of the Varnode is locked.
Definition: varnode.hh:82
Symbol(Scope *sc, const string &nm, Datatype *ct)
Construct given a name and data-type.
Definition: database.hh:886
virtual SymbolEntry * addSymbol(const string &name, Datatype *ct, const Address &addr, const Address &usepoint)
Add a new Symbol to this Scope, given a name, data-type, and a single mapping.
Definition: database.cc:1491
Initialization data for a SymbolEntry to facilitate a rangemap.
Definition: database.hh:67
Manager for all the major decompiler subsystems.
Definition: architecture.hh:119
A storage location for a particular Symbol.
Definition: database.hh:51
@ is_this_ptr
We are the "this" symbol for a class method.
Definition: database.hh:187
@ force_dec
Force decimal printing of constant symbol.
Definition: database.hh:180
uint4 nameDedup
id to distinguish symbols with the same name
Definition: database.hh:160
virtual LabSymbol * findCodeLabel(const Address &addr) const =0
Find a label Symbol at the given address.
virtual SymbolEntry * findOverlap(const Address &addr, int4 size) const
Find first Symbol overlapping the given memory range.
Definition: database.cc:2293
Definitions for high-level variables.
virtual void setDisplayFormat(Symbol *sym, uint4 attr)
Set the display format for a Symbol.
Definition: database.cc:2119
bool operator==(const MapIterator &op2) const
Equality operator.
Definition: database.hh:365
virtual void clear(void)=0
Clear all symbols from this scope.
virtual bool isNameUsed(const string &nm, const Scope *op2) const =0
Check if the given name is occurs within the given scope path.
virtual void restoreXml(const Element *el)
Restore this Scope from a <scope> XML tag.
Definition: database.cc:2639
void getScopePath(vector< const Scope * > &vec) const
Get the ordered list of scopes up to this.
Definition: database.cc:1419
virtual list< SymbolEntry >::const_iterator beginDynamic(void) const
Beginning iterator to dynamic SymbolEntrys.
Definition: database.cc:1834
vector< vector< Symbol * > > category
References to Symbol objects organized by category.
Definition: database.hh:739
virtual void restrictScope(Funcdata *f)
Convert this to a local Scope.
Definition: database.cc:1057
virtual list< SymbolEntry >::const_iterator endDynamic(void) const
Ending iterator to dynamic SymbolEntrys.
Definition: database.cc:1840
virtual void clearCategory(int4 cat)
Clear all symbols of the given category from this scope.
Definition: database.cc:1933
static const Scope * stackCodeLabel(const Scope *scope1, const Scope *scope2, const Address &addr, LabSymbol **addrmatch)
Definition: database.cc:1035
SymbolNameTree multiEntrySet
Set of symbols with multiple entries.
Definition: database.hh:741
virtual string buildUndefinedName(void) const =0
Build a formal undefined name, used internally when a Symbol is not given a name.
A low-level variable or contiguous set of bytes described by an Address and a size.
Definition: varnode.hh:65
A disjoint set of Ranges, possibly across multiple address spaces.
Definition: address.hh:203
Scope(uint8 id, const string &nm, Architecture *g, Scope *own)
Construct an empty scope, given a name and Architecture.
Definition: database.hh:504
Scope * findCreateScopeFromSymbolName(const string &fullname, const string &delim, string &basename, Scope *start)
Find (and if not found create) a specific subscope.
Definition: database.cc:3043
virtual Funcdata * findFunction(const Address &addr) const
Find the function starting at the given address.
Definition: database.cc:2222
virtual SymbolEntry * addMapInternal(Symbol *sym, uint4 exfl, const Address &addr, int4 off, int4 sz, const RangeList &uselim)=0
Create a new SymbolEntry for a Symbol given a memory range.
virtual void findByName(const string &name, vector< Symbol * > &res) const
Find a Symbol by name within this Scope.
Definition: database.cc:2306
virtual int4 getCategorySize(int4 cat) const
Get the number of Symbols in the given category.
Definition: database.cc:2705
@ isolate
Symbol should not speculatively merge automatically.
Definition: database.hh:185
virtual void restoreXml(const Element *el)
Restore this Symbol from an XML stream.
Definition: database.cc:726
subsorttype getSubsort(void) const
Get the sub-sort object.
Definition: database.cc:73
bool isValueClose(uintb op2Value, int4 size) const
Is the given value similar to this equate.
Definition: database.cc:649
Funcdata * queryFunction(const string &name) const
Look-up a function by name.
Definition: database.cc:1173
virtual void saveXml(ostream &s) const
Write out this as a <scope> XML tag.
Definition: database.cc:2517
Architecture * glb
Architecture of this scope.
Definition: database.hh:413
virtual void saveXml(ostream &s) const
Save this Symbol to an XML stream.
Definition: database.cc:601
FunctionSymbol * addFunction(const Address &addr, const string &nm)
Create a function Symbol at the given address in this Scope.
Definition: database.cc:1575
static const Scope * stackClosestFit(const Scope *scope1, const Scope *scope2, const Address &addr, int4 size, const Address &usepoint, SymbolEntry **addrmatch)
Definition: database.cc:938
Address getFirstUseAddress(void) const
Get the first code address where this storage is valid.
Definition: database.cc:98
SymbolEntry * addMap(SymbolEntry &entry)
Integrate a SymbolEntry into the range maps.
Definition: database.cc:1087
A Symbol that holds equate information for a constant.
Definition: database.hh:270
An Address range associated with the symbol Scope that owns it.
Definition: database.hh:802
AddrSpace * getSpace(void) const
Get the address space.
Definition: address.hh:294
List::const_iterator restoreXml(List::const_iterator iter, const AddrSpaceManager *manage)
Restore this from an XML stream.
Definition: database.cc:195
Scope * resolveScope(uint8 id) const
Look-up a Scope by id.
Definition: database.cc:2989
virtual SymbolEntry * findAddr(const Address &addr, const Address &usepoint) const
Find a Symbol at a given address and usepoint.
Definition: database.cc:2125
void printBounds(ostream &s) const
Print a description of this RangeList to stream.
Definition: address.cc:522
set< Symbol *, SymbolCompareName > SymbolNameTree
A set of Symbol objects sorted by name.
Definition: database.hh:324
ExternRefSymbol * addExternalRef(const Address &addr, const Address &refaddr, const string &nm)
Definition: database.cc:1602
A low-level machine address for labelling bytes and data.
Definition: address.hh:46
void addRange(Scope *scope, AddrSpace *spc, uintb first, uintb last)
Add an address range to the ownership of a Scope.
Definition: database.cc:2947
void assignDefaultNames(int4 &base)
Assign a default name (via buildVariableName) to any unnamed symbol.
Definition: database.cc:2747
virtual void restoreXml(const Element *el)
Restore this Symbol from an XML stream.
Definition: database.cc:529
NullSubsort subsorttype
The sub-sort object for a rangemap.
Definition: database.hh:814
EntrySubsort(bool val)
Given a boolean value, construct the earliest/latest possible sub-sort.
Definition: database.hh:95
Container for data structures associated with a single function.
Definition: funcdata.hh:45
The base datatype class for the decompiler.
Definition: type.hh:62
virtual bool inScope(const Address &addr, int4 size, const Address &usepoint) const
Query if the given range is owned by this Scope.
Definition: database.hh:535
vector< EntryMap * > maptable
Rangemaps of SymbolEntry, one map for each address space.
Definition: database.hh:738
virtual void setAttribute(Symbol *sym, uint4 attr)
Set boolean Varnode properties on a Symbol.
Definition: database.cc:2103
@ merge_problems
Set if some SymbolEntrys did not get merged.
Definition: database.hh:186
void saveXmlBody(ostream &s) const
Save details of the Symbol to XML.
Definition: database.cc:502
virtual Scope * buildSubScope(uint8 id, const string &nm)
Build an unattached Scope to be associated as a sub-scope of this.
Definition: database.cc:1719
int4 getIndex(void) const
Get the integer identifier.
Definition: space.hh:319
virtual int4 getCategorySize(int4 cat) const =0
Get the number of Symbols in the given category.
bool operator!=(const MapIterator &op2) const
Inequality operator.
Definition: database.hh:372
virtual string buildVariableName(const Address &addr, const Address &pc, Datatype *ct, int4 &index, uint4 flags) const =0
Given an address and data-type, build a suitable generic symbol name.
@ precishi
Is this Varnode the high part of a double precision value.
Definition: varnode.hh:102
uintb linetype
The linear element for a rangemap of SymbolEntry.
Definition: database.hh:111
virtual ~Scope(void)
Destructor.
Definition: database.cc:1143
A manager for symbol scopes for a whole executable.
Definition: database.hh:844
int2 category
Special category (-1==none 0=parameter 1=equate)
Definition: database.hh:165
virtual SymbolEntry * findOverlap(const Address &addr, int4 size) const =0
Find first Symbol overlapping the given memory range.
void removeRange(Scope *scope, AddrSpace *spc, uintb first, uintb last)
Remove an address range from ownership of a Scope.
Definition: database.cc:2961
FunctionSymbol(Scope *sc, const string &nm, int4 size)
Construct given the name.
Definition: database.cc:570
@ force_oct
Force octal printing of constant symbol.
Definition: database.hh:181
@ precislo
Is this Varnode the low part of a double precision value.
Definition: varnode.hh:101
virtual void retypeSymbol(Symbol *sym, Datatype *ct)
Change the data-type of a Symbol within this Scope.
Definition: database.cc:2071
EntrySubsort subsorttype
The sub-sort object for a rangemap.
Definition: database.hh:112
bool updateType(Varnode *vn) const
Update a Varnode data-type from this.
Definition: database.cc:111
Scope * resolveScopeFromSymbolName(const string &fullname, const string &delim, string &basename, Scope *start) const
Get the Scope (and base name) associated with a qualified Symbol name.
Definition: database.cc:3010
virtual void saveXml(ostream &s) const
Save this Symbol to an XML stream.
Definition: database.cc:759
virtual void addSymbolInternal(Symbol *sym)=0
Put a Symbol into the name map.
void deleteSubScopes(Scope *scope)
Delete all sub-scopes of the given Scope.
Definition: database.cc:2900
void setIsolated(bool val)
Set whether this Symbol should be speculatively merged.
Definition: database.cc:248
Symbol * addDynamicSymbol(const string &nm, Datatype *ct, const Address &caddr, uint8 hash)
Create a dynamically mapped Symbol attached to a specific data-flow.
Definition: database.cc:1650
A Symbol representing an executable function.
Definition: database.hh:251
void restoreXml(const Element *el)
Recover the whole database from XML.
Definition: database.cc:3182
virtual void removeRange(AddrSpace *spc, uintb first, uintb last)
Remove a memory range from the ownership of this Scope.
Definition: database.cc:1075
uint8 symbolId
Unique id, 0=unassigned.
Definition: database.hh:167
virtual void setDisplayFormat(Symbol *sym, uint4 attr)=0
Set the display format for a Symbol.
bool operator<(const EntrySubsort &op2)
Compare this with another sub-sort.
Definition: database.hh:105
@ force_bin
Force binary printing of constant symbol.
Definition: database.hh:182
virtual MapIterator begin(void) const
Beginning iterator to mapped SymbolEntrys.
Definition: database.cc:1802
virtual list< SymbolEntry >::const_iterator endDynamic(void) const =0
Ending iterator to dynamic SymbolEntrys.
A contiguous range of bytes in some address space.
Definition: address.hh:161
A Symbol that labels code internal to a function.
Definition: database.hh:281
virtual void clearCategory(int4 cat)=0
Clear all symbols of the given category from this scope.
int4 getResolutionDepth(const Scope *useScope) const
Get number of scope names needed to resolve this symbol.
Definition: database.cc:316
void saveXmlHeader(ostream &s) const
Save basic Symbol properties as XML attributes.
Definition: database.cc:356
SymbolEntry * getMapEntry(const Address &addr) const
Get first mapping of the symbol that contains the given Address.
Definition: database.cc:273
static uint8 ID_BASE
Base of internal ID's.
Definition: database.hh:225
virtual SymbolEntry * findAddr(const Address &addr, const Address &usepoint) const =0
Find a Symbol at a given address and usepoint.
virtual Funcdata * resolveExternalRefFunction(ExternRefSymbol *sym) const
Convert an external reference to the referenced function.
Definition: database.cc:2263
virtual void printEntries(ostream &s) const =0
Dump a description of all SymbolEntry objects to a stream.
virtual string makeNameUnique(const string &nm) const
Produce a version of the given symbol name that won't collide with other names in this Scope.
Definition: database.cc:2454
bool isAddrTied(void) const
Is this storage address tied.
Definition: database.hh:243
virtual void clearAttribute(Symbol *sym, uint4 attr)
Clear boolean Varnode properties on a Symbol.
Definition: database.cc:2111
string name
Name of this scope.
Definition: database.hh:414
virtual SymbolEntry * addDynamicMapInternal(Symbol *sym, uint4 exfl, uint8 hash, int4 off, int4 sz, const RangeList &uselim)=0
Create a new SymbolEntry for a Symbol given a dynamic hash.
static const Scope * stackFunction(const Scope *scope1, const Scope *scope2, const Address &addr, Funcdata **addrmatch)
Definition: database.cc:970
virtual void removeSymbol(Symbol *symbol)
Remove the given Symbol from this Scope.
Definition: database.cc:2044
void checkSizeTypeLock(void)
Calculate if size_typelock property is on.
Definition: database.cc:219
virtual bool isNameUsed(const string &nm, const Scope *op2) const
Check if the given name is occurs within the given scope path.
Definition: database.cc:2318
void deleteScope(Scope *scope)
Delete the given Scope and all its sub-scopes.
Definition: database.cc:2882
virtual void setCategory(Symbol *sym, int4 cat, int4 ind)
Set the category and index for the given Symbol.
Definition: database.cc:2723
void setThisPointer(bool val)
Toggle whether this is the "this" pointer for a class method.
Definition: database.cc:228
bool operator()(const Symbol *sym1, const Symbol *sym2) const
Compare two Symbol pointers.
Definition: database.hh:317
Class for sub-sorting different SymbolEntry objects at the same address.
Definition: database.hh:83
void saveXmlRecursive(ostream &s, bool onlyGlobal) const
Save all contained scopes as an XML stream.
Definition: database.cc:1332
virtual void removeSymbol(Symbol *symbol)=0
Remove the given Symbol from this Scope.
virtual SymbolEntry * findContainer(const Address &addr, int4 size, const Address &usepoint) const
Find the smallest Symbol containing the given memory range.
Definition: database.cc:2151
virtual void saveXml(ostream &s) const =0
Write out this as a <scope> XML tag.
virtual SymbolEntry * addMapInternal(Symbol *sym, uint4 exfl, const Address &addr, int4 off, int4 sz, const RangeList &uselim)
Create a new SymbolEntry for a Symbol given a memory range.
Definition: database.cc:1756
virtual int4 getBytesConsumed(void) const
Get number of bytes consumed within the address->symbol map.
Definition: database.cc:544
virtual SymbolEntry * findContainer(const Address &addr, int4 size, const Address &usepoint) const =0
Find the smallest Symbol containing the given memory range.
vector< list< SymbolEntry >::iterator > mapentry
List of storage locations labeled with this Symbol.
Definition: database.hh:168
virtual void clear(void)
Clear all symbols from this scope.
Definition: database.cc:1890
SymbolEntry * getFirstWholeMap(void) const
Get the first entire mapping of the symbol.
Definition: database.cc:261
@ size_typelock
Only the size of the symbol is typelocked.
Definition: database.hh:184
uint8 uniqueId
Unique id for the scope, for deduping scope names, assigning symbol ids.
Definition: database.hh:416
virtual string buildVariableName(const Address &addr, const Address &pc, Datatype *ct, int4 &index, uint4 flags) const
Given an address and data-type, build a suitable generic symbol name.
Definition: database.cc:2335
virtual LabSymbol * findCodeLabel(const Address &addr) const
Find a label Symbol at the given address.
Definition: database.cc:2269
virtual void renameSymbol(Symbol *sym, const string &newname)=0
Rename a Symbol within this Scope.
Scope * findCreateScope(uint8, const string &nm, Scope *parent)
Definition: database.cc:2975
void attachScope(Scope *newscope, Scope *parent)
Register a new Scope.
Definition: database.cc:2843
virtual void saveXml(ostream &s) const
Save this Symbol to an XML stream.
Definition: database.cc:718
virtual string buildUndefinedName(void) const
Build a formal undefined name, used internally when a Symbol is not given a name.
Definition: database.cc:2421
A manager for different address spaces.
Definition: translate.hh:218
uint2 catindex
Index within category.
Definition: database.hh:166
virtual void saveXml(ostream &s) const
Save this Symbol to an XML stream.
Definition: database.cc:518
static const Scope * stackContainer(const Scope *scope1, const Scope *scope2, const Address &addr, int4 size, const Address &usepoint, SymbolEntry **addrmatch)
Definition: database.cc:904
virtual void saveXml(ostream &s) const
Save this Symbol to an XML stream.
Definition: database.cc:668
rangemap< SymbolEntry > EntryMap
A rangemap of SymbolEntry.
Definition: database.hh:140
Funcdata * getFunction(void)
Get the underlying Funcdata object.
Definition: database.cc:592
virtual void clearUnlocked(void)
Clear all unlocked symbols from this scope.
Definition: database.cc:1955
void saveXml(ostream &s) const
Save this to an XML stream.
Definition: database.cc:176
virtual void retypeSymbol(Symbol *sym, Datatype *ct)=0
Change the data-type of a Symbol within this Scope.
virtual void clearUnlockedCategory(int4 cat)
Clear unlocked symbols of the given category from this scope.
Definition: database.cc:1977
Datatype * type
The symbol's data-type.
Definition: database.hh:159
virtual void categorySanity(void)
Make sure Symbol categories are sane.
Definition: database.cc:1905
void restoreXmlHeader(const Element *el)
Restore basic Symbol properties from XML.
Definition: database.cc:399
The base class for a symbol in a symbol table or scope.
Definition: database.hh:152
Comparator for sorting Symbol objects by name.
Definition: database.hh:309
int4 getMapEntryPosition(const SymbolEntry *entry) const
Position of given SymbolEntry within this multi-entry Symbol.
Definition: database.cc:294
virtual Funcdata * findFunction(const Address &addr) const =0
Find the function starting at the given address.
virtual Scope * buildSubScope(uint8 id, const string &nm)=0
Build an unattached Scope to be associated as a sub-scope of this.
@ indirectstorage
Is this Varnode storing a pointer to the actual symbol.
Definition: varnode.hh:103
virtual void removeSymbolMappings(Symbol *symbol)
Remove all SymbolEntrys from the given Symbol.
Definition: database.cc:2023
void saveXml(ostream &s) const
Save the whole Database to an XML stream.
Definition: database.cc:3136
virtual void restoreXml(const Element *el)
Restore this Symbol from an XML stream.
Definition: database.cc:615
SymbolEntry * queryProperties(const Address &addr, int4 size, const Address &usepoint, uint4 &flags) const
Find a Symbol or properties at the given address.
Definition: database.cc:1224
Templates to define interval map containers.
MapIterator & operator=(const MapIterator &op2)
Assignment operator.
Definition: database.hh:357
@ addrtied
High-level variable is tied to address.
Definition: varnode.hh:90
void resetSizeLockType(Symbol *sym)
Clear a Symbol's size-locked data-type.
Definition: database.cc:1363