decompiler  1.0.0
Public Member Functions | Private Attributes | List of all members
ghidra::EquateSymbol Class Reference

A Symbol that holds equate information for a constant. More...

#include <database.hh>

Inheritance diagram for ghidra::EquateSymbol:
ghidra::Symbol

Public Member Functions

 EquateSymbol (Scope *sc, const string &nm, uint4 format, uintb val)
 Constructor. More...
 
 EquateSymbol (Scope *sc)
 Constructor for use with decode.
 
uintb getValue (void) const
 Get the constant value.
 
bool isValueClose (uintb op2Value, int4 size) const
 Is the given value similar to this equate. 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...
 
- Public Member Functions inherited from ghidra::Symbol
 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.
 
DatatypegetType (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...
 
ScopegetScope (void) const
 Get the scope owning this Symbol.
 
SymbolEntrygetFirstWholeMap (void) const
 Get the first entire mapping of the symbol. More...
 
SymbolEntrygetMapEntry (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.
 
SymbolEntrygetMapEntry (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 int4 getBytesConsumed (void) const
 Get number of bytes consumed within the address->symbol map. More...
 

Private Attributes

uintb value
 Value of the constant being equated.
 

Additional Inherited Members

- Public Types inherited from ghidra::Symbol
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...
 
- Static Public Attributes inherited from ghidra::Symbol
static uint8 ID_BASE = 0x4000000000000000L
 Base of internal ID's.
 
- Protected Member Functions inherited from ghidra::Symbol
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 inherited from ghidra::Symbol
Scopescope
 The scope that owns this symbol.
 
string name
 The local name of the symbol.
 
string displayName
 Name to use when displaying symbol in output.
 
Datatypetype
 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 ScopedepthScope
 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.
 

Detailed Description

A Symbol that holds equate information for a constant.

This is a symbol that labels a constant. It can either replace the constant's token with the symbol name, or it can force a conversion in the emitted format of the constant.

Constructor & Destructor Documentation

◆ EquateSymbol()

ghidra::EquateSymbol::EquateSymbol ( Scope sc,
const string &  nm,
uint4  format,
uintb  val 
)

Constructor.

Create a symbol either to associate a name with a constant or to force a display conversion

Parameters
scis the scope owning the new symbol
nmis the name of the equate (an empty string can be used for a convert)
formatis the desired display conversion (0 for no conversion)
valis the constant value whose display is being altered

References ghidra::Symbol::category, ghidra::Symbol::dispflags, ghidra::Symbol::equate, ghidra::Scope::getArch(), ghidra::TypeFactory::getBase(), ghidra::Symbol::type, ghidra::TYPE_UNKNOWN, ghidra::Architecture::types, and value.

Member Function Documentation

◆ decode()

void ghidra::EquateSymbol::decode ( Decoder decoder)
virtual

◆ encode()

void ghidra::EquateSymbol::encode ( Encoder encoder) const
virtual

Encode this Symbol to a stream.

Parameters
encoderis the stream encoder

Reimplemented from ghidra::Symbol.

References ghidra::Encoder::closeElement(), ghidra::Symbol::encodeHeader(), ghidra::Encoder::openElement(), value, and ghidra::Encoder::writeUnsignedInteger().

◆ isValueClose()

bool ghidra::EquateSymbol::isValueClose ( uintb  op2Value,
int4  size 
) const

Is the given value similar to this equate.

An EquateSymbol should survive certain kinds of transforms during decompilation, such as negation, twos-complementing, adding or subtracting 1. Return true if the given value looks like a transform of this type relative to the underlying value of this equate.

Parameters
op2Valueis the given value
sizeis the number of bytes of precision
Returns
true if it is a transformed form

References ghidra::calc_mask(), and value.

Referenced by ghidra::Varnode::copySymbolIfValid().


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