decompiler
1.0.0
|
The base class for a symbol in a symbol table or scope. More...
#include <database.hh>
Public Types | |
enum | { force_hex = 1, force_dec = 2, force_oct = 3, force_bin = 4, force_char = 5, size_typelock = 8, isolate = 16, merge_problems = 32, is_this_ptr = 64 } |
Possible display (dispflag) properties for a Symbol. More... | |
enum | { no_category = -1, function_parameter = 0, equate = 1, union_facet = 2 } |
The possible specialize Symbol categories. More... | |
Public Member Functions | |
Symbol (Scope *sc, const string &nm, Datatype *ct) | |
Construct given a name and data-type. More... | |
Symbol (Scope *sc) | |
Construct for use with decode() More... | |
const string & | getName (void) const |
Get the local name of the symbol. | |
const string & | getDisplayName (void) const |
Get the name to display in output. | |
Datatype * | getType (void) const |
Get the data-type. | |
uint8 | getId (void) const |
Get a unique id for the symbol. | |
uint4 | getFlags (void) const |
Get the boolean properties of the Symbol. | |
uint4 | getDisplayFormat (void) const |
Get the format to display the Symbol in. | |
int2 | getCategory (void) const |
Get the Symbol category. | |
uint2 | getCategoryIndex (void) const |
Get the position of the Symbol within its category. | |
bool | isTypeLocked (void) const |
Is the Symbol type-locked. | |
bool | isNameLocked (void) const |
Is the Symbol name-locked. | |
bool | isSizeTypeLocked (void) const |
Is the Symbol size type-locked. | |
bool | isVolatile (void) const |
Is the Symbol volatile. | |
bool | isThisPointer (void) const |
Is this the "this" pointer. | |
bool | isIndirectStorage (void) const |
Is storage really a pointer to the true Symbol. | |
bool | isHiddenReturn (void) const |
Is this a reference to the function return value. | |
bool | isNameUndefined (void) const |
Does this have an undefined name. More... | |
bool | isMultiEntry (void) const |
Does this have more than one entire mapping. | |
bool | hasMergeProblems (void) const |
Were some SymbolEntrys not merged. | |
void | setMergeProblems (void) |
Mark that some SymbolEntrys could not be merged. | |
bool | isIsolated (void) const |
Return true if this is isolated from speculative merging. | |
void | setIsolated (bool val) |
Set whether this Symbol should be speculatively merged. More... | |
Scope * | getScope (void) const |
Get the scope owning this Symbol. | |
SymbolEntry * | getFirstWholeMap (void) const |
Get the first entire mapping of the symbol. More... | |
SymbolEntry * | getMapEntry (const Address &addr) const |
Get first mapping of the symbol that contains the given Address. More... | |
int4 | numEntries (void) const |
Return the number of SymbolEntrys. | |
SymbolEntry * | getMapEntry (int4 i) const |
Return the i-th SymbolEntry for this Symbol. | |
int4 | getMapEntryPosition (const SymbolEntry *entry) const |
Position of given SymbolEntry within this multi-entry Symbol. More... | |
int4 | getResolutionDepth (const Scope *useScope) const |
Get number of scope names needed to resolve this symbol. More... | |
void | encodeHeader (Encoder &encoder) const |
Encode basic Symbol properties as attributes. More... | |
void | decodeHeader (Decoder &decoder) |
Decode basic Symbol properties from a <symbol> element. More... | |
void | encodeBody (Encoder &encoder) const |
Encode details of the Symbol to a stream. More... | |
void | decodeBody (Decoder &decoder) |
Decode details of the Symbol from a <symbol> element. More... | |
virtual void | encode (Encoder &encoder) const |
Encode this Symbol to a stream. More... | |
virtual void | decode (Decoder &decoder) |
Decode this Symbol from a stream. More... | |
virtual int4 | getBytesConsumed (void) const |
Get number of bytes consumed within the address->symbol map. More... | |
Static Public Attributes | |
static uint8 | ID_BASE = 0x4000000000000000L |
Base of internal ID's. | |
Protected Member Functions | |
virtual | ~Symbol (void) |
Destructor. | |
void | setDisplayFormat (uint4 val) |
Set the display format for this Symbol. More... | |
void | checkSizeTypeLock (void) |
Calculate if size_typelock property is on. More... | |
void | setThisPointer (bool val) |
Toggle whether this is the "this" pointer for a class method. More... | |
Protected Attributes | |
Scope * | scope |
The scope that owns this symbol. | |
string | name |
The local name of the symbol. | |
string | displayName |
Name to use when displaying symbol in output. | |
Datatype * | type |
The symbol's data-type. | |
uint4 | nameDedup |
id to distinguish symbols with the same name | |
uint4 | flags |
Varnode-like properties of the symbol. | |
uint4 | dispflags |
Flags affecting the display of this symbol. | |
int2 | category |
Special category (function_parameter, equate, etc.) | |
uint2 | catindex |
Index within category. | |
uint8 | symbolId |
Unique id, 0=unassigned. | |
vector< list< SymbolEntry >::iterator > | mapentry |
List of storage locations labeled with this Symbol. | |
const Scope * | depthScope |
Scope associated with current depth resolution. | |
int4 | depthResolution |
Number of namespace elements required to resolve symbol in current scope. | |
uint4 | wholeCount |
Number of SymbolEntries that map to the whole Symbol. | |
Friends | |
class | Scope |
class | ScopeInternal |
class | SymbolCompareName |
The base class for a symbol in a symbol table or scope.
At its most basic, a Symbol is a name and a data-type. Practically a Symbol knows what Scope its in, how it should be displayed, and the symbols category. A category is a subset of symbols that are stored together for quick access.
anonymous enum |
Possible display (dispflag) properties for a Symbol.
Enumerator | |
---|---|
force_hex | Force hexadecimal printing of constant symbol. |
force_dec | Force decimal printing of constant symbol. |
force_oct | Force octal printing of constant symbol. |
force_bin | Force binary printing of constant symbol. |
force_char | Force integer to be printed as a character constant. |
size_typelock | Only the size of the symbol is typelocked. |
isolate | Symbol should not speculatively merge automatically. |
merge_problems | Set if some SymbolEntrys did not get merged. |
is_this_ptr | We are the "this" symbol for a class method. |
anonymous enum |
Construct given a name and data-type.
sc | is the scope containing the new symbol |
nm | is the local name of the symbol |
ct | is the data-type of the symbol |
Referenced by ghidra::Scope::addDynamicSymbol(), ghidra::Scope::addMapSym(), and ghidra::Scope::addSymbol().
|
inline |
Construct for use with decode()
sc | is the scope containing the new symbol |
|
protected |
Calculate if size_typelock property is on.
Examine the data-type to decide if the Symbol has the special property called size_typelock, which indicates the size of the Symbol is locked, but the data-type is not locked (and can float)
References ghidra::TYPE_UNKNOWN.
Referenced by ghidra::ScopeInternal::clearAttribute(), ghidra::ScopeInternal::retypeSymbol(), and ghidra::ScopeInternal::setAttribute().
|
virtual |
Decode this Symbol from a stream.
Parse a Symbol from the next element in the stream
decoder | is the stream decoder |
Reimplemented in ghidra::ExternRefSymbol, ghidra::LabSymbol, ghidra::UnionFacetSymbol, ghidra::EquateSymbol, and ghidra::FunctionSymbol.
References ghidra::Decoder::closeElement(), and ghidra::Decoder::openElement().
Referenced by ghidra::Scope::addMapSym().
void ghidra::Symbol::decodeBody | ( | Decoder & | decoder | ) |
Decode details of the Symbol from a <symbol> element.
decoder | is the stream decoder |
Referenced by ghidra::UnionFacetSymbol::decode().
void ghidra::Symbol::decodeHeader | ( | Decoder & | decoder | ) |
Decode basic Symbol properties from a <symbol> element.
decoder | is the stream decoder |
References ghidra::Datatype::encodeIntegerFormat(), ghidra::Decoder::getNextAttributeId(), ghidra::Varnode::hiddenretparm, ghidra::Varnode::indirectstorage, ghidra::Varnode::namelock, ghidra::Decoder::readBool(), ghidra::Varnode::readonly, ghidra::Decoder::readSignedInteger(), ghidra::Decoder::readString(), ghidra::Decoder::readUnsignedInteger(), ghidra::Varnode::typelock, and ghidra::Varnode::volatil.
Referenced by ghidra::EquateSymbol::decode(), ghidra::UnionFacetSymbol::decode(), and ghidra::LabSymbol::decode().
|
virtual |
Encode this Symbol to a stream.
encoder | is the stream encoder |
Reimplemented in ghidra::ExternRefSymbol, ghidra::LabSymbol, ghidra::UnionFacetSymbol, ghidra::EquateSymbol, and ghidra::FunctionSymbol.
References ghidra::Encoder::closeElement(), and ghidra::Encoder::openElement().
Referenced by ghidra::ScopeInternal::encode().
void ghidra::Symbol::encodeBody | ( | Encoder & | encoder | ) | const |
Encode details of the Symbol to a stream.
Encode the data-type for the Symbol
encoder | is the stream encoder |
Referenced by ghidra::UnionFacetSymbol::encode().
void ghidra::Symbol::encodeHeader | ( | Encoder & | encoder | ) | const |
Encode basic Symbol properties as attributes.
encoder | is the stream encoder |
References ghidra::Datatype::decodeIntegerFormat(), ghidra::Varnode::hiddenretparm, ghidra::Varnode::indirectstorage, ghidra::Varnode::namelock, ghidra::Varnode::readonly, ghidra::Varnode::typelock, ghidra::Varnode::volatil, ghidra::Encoder::writeBool(), ghidra::Encoder::writeSignedInteger(), ghidra::Encoder::writeString(), and ghidra::Encoder::writeUnsignedInteger().
Referenced by ghidra::EquateSymbol::encode(), ghidra::UnionFacetSymbol::encode(), and ghidra::LabSymbol::encode().
|
virtual |
Get number of bytes consumed within the address->symbol map.
Get the number of bytes consumed by a SymbolEntry representing this Symbol. By default, this is the number of bytes consumed by the Symbol's data-type. This gives the amount of leeway a search has when the address queried does not match the exact address of the Symbol. With functions, the bytes consumed by a SymbolEntry may not match the data-type size.
Reimplemented in ghidra::FunctionSymbol.
Referenced by ghidra::Scope::addMap().
SymbolEntry * ghidra::Symbol::getFirstWholeMap | ( | void | ) | const |
Get the first entire mapping of the symbol.
Referenced by ghidra::ScopeLocal::addRecommendName(), ghidra::Funcdata::buildDynamicSymbol(), ghidra::ScopeLocal::collectNameRecs(), ghidra::ScopeInternal::decode(), ghidra::ScopeGhidra::dump2Cache(), ghidra::PrintC::emitScopeVarDecls(), ghidra::IfcMapaddress::execute(), ghidra::Funcdata::findHigh(), ghidra::FunctionSymbol::getFunction(), ghidra::Funcdata::linkProtoPartial(), ghidra::PrintC::pushPartialSymbol(), ghidra::ScopeLocal::recoverNameRecommendationsForSymbols(), ghidra::ScopeLocal::remapSymbol(), ghidra::ScopeLocal::remapSymbolDynamic(), ghidra::ScopeGhidra::resolveExternalRefFunction(), and ghidra::ProtoStoreSymbol::setInput().
SymbolEntry * ghidra::Symbol::getMapEntry | ( | const Address & | addr | ) | const |
Get first mapping of the symbol that contains the given Address.
This method may return a partial entry, where the SymbolEntry is only holding part of the whole Symbol.
addr | is an address within the desired storage location of the Symbol |
References ghidra::SymbolEntry::getAddr(), ghidra::Address::getOffset(), ghidra::SymbolEntry::getSize(), and ghidra::Address::getSpace().
Referenced by ghidra::Scope::buildDefaultName(), ghidra::ScopeGhidra::findAddr(), ghidra::ScopeGhidra::findContainer(), and ghidra::Merge::mergeMultiEntry().
int4 ghidra::Symbol::getMapEntryPosition | ( | const SymbolEntry * | entry | ) | const |
Position of given SymbolEntry within this multi-entry Symbol.
Among all the SymbolEntrys that map this entire Symbol, calculate the position of the given SymbolEntry within the list.
entry | is the given SymbolEntry |
References ghidra::SymbolEntry::getSize().
Referenced by ghidra::PrintC::pushSymbol().
int4 ghidra::Symbol::getResolutionDepth | ( | const Scope * | useScope | ) | const |
Get number of scope names needed to resolve this symbol.
For a given context scope where this Symbol is used, determine how many elements of the full namespace path need to be printed to correctly distinguish it. A value of 0 means the base symbol name is visible and not overridden in the context scope. A value of 1 means the base name may be overridden, but the parent scope name is not. The minimal number of names that distinguishes the symbol name uniquely within the use scope is returned.
useScope | is the given scope where the symbol is being used |
References ghidra::Scope::findDistinguishingScope(), ghidra::Scope::getName(), ghidra::Scope::getParent(), and ghidra::Scope::isNameUsed().
Referenced by ghidra::PrintC::emitSymbolScope(), and ghidra::PrintC::pushSymbolScope().
bool ghidra::Symbol::isNameUndefined | ( | void | ) | const |
Does this have an undefined name.
The name for a Symbol can be unspecified. See ScopeInternal::buildUndefinedName
Referenced by ghidra::ActionNameVars::apply(), ghidra::ScopeInternal::assignDefaultNames(), ghidra::Funcdata::attemptDynamicMappingLate(), ghidra::ScopeInternal::clearUnlocked(), ghidra::ScopeInternal::clearUnlockedCategory(), ghidra::PrintC::emitScopeVarDecls(), ghidra::ActionNameVars::linkSpacebaseSymbol(), ghidra::ActionNameVars::linkSymbols(), ghidra::ActionNameVars::lookForFuncParamNames(), and ghidra::ScopeLocal::recoverNameRecommendationsForSymbols().
|
inlineprotected |
Set the display format for this Symbol.
Force a specific display format for constant symbols
val | is the format: force_hex, force_dec, force_oct, etc. |
Referenced by ghidra::ScopeInternal::setDisplayFormat().
void ghidra::Symbol::setIsolated | ( | bool | val | ) |
Set whether this Symbol should be speculatively merged.
If the given value is true, any Varnodes that map directly to this Symbol, will not be speculatively merged with other Varnodes. (Required merges will still happen).
val | is the given boolean value |
References ghidra::Varnode::typelock.
Referenced by ghidra::IfcIsolate::execute(), and ghidra::IfcTypeVarnode::execute().
|
protected |
Toggle whether this is the "this" pointer for a class method.
val | is true if we are the "this" pointer |
Referenced by ghidra::Scope::setThisPointer().