decompiler  1.0.0
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | Friends | List of all members
ghidra::Scope Class Referenceabstract

A collection of Symbol objects within a single (namespace or functional) scope. More...

#include <database.hh>

Inheritance diagram for ghidra::Scope:
ghidra::ScopeGhidra ghidra::ScopeInternal ghidra::ScopeGhidraNamespace ghidra::ScopeLocal

Public Member Functions

 Scope (uint8 id, const string &nm, Architecture *g, Scope *own)
 Construct an empty scope, given a name and Architecture.
 
virtual ~Scope (void)
 Destructor.
 
virtual MapIterator begin (void) const =0
 Beginning iterator to mapped SymbolEntrys.
 
virtual MapIterator end (void) const =0
 Ending iterator to mapped SymbolEntrys.
 
virtual list< SymbolEntry >::const_iterator beginDynamic (void) const =0
 Beginning iterator to dynamic SymbolEntrys.
 
virtual list< SymbolEntry >::const_iterator endDynamic (void) const =0
 Ending iterator to dynamic SymbolEntrys.
 
virtual list< SymbolEntry >::iterator beginDynamic (void)=0
 Beginning iterator to dynamic SymbolEntrys.
 
virtual list< SymbolEntry >::iterator endDynamic (void)=0
 Ending iterator to dynamic SymbolEntrys.
 
virtual void clear (void)=0
 Clear all symbols from this scope.
 
virtual void clearCategory (int4 cat)=0
 Clear all symbols of the given category from this scope.
 
virtual void clearUnlocked (void)=0
 Clear all unlocked symbols from this scope.
 
virtual void clearUnlockedCategory (int4 cat)=0
 Clear unlocked symbols of the given category from this scope.
 
virtual void adjustCaches (void)=0
 Let scopes internally adjust any caches. More...
 
virtual bool inScope (const Address &addr, int4 size, const Address &usepoint) const
 Query if the given range is owned by this Scope. More...
 
virtual void removeSymbolMappings (Symbol *symbol)=0
 Remove all SymbolEntrys from the given Symbol.
 
virtual void removeSymbol (Symbol *symbol)=0
 Remove the given Symbol from this Scope.
 
virtual void renameSymbol (Symbol *sym, const string &newname)=0
 Rename a Symbol within this Scope.
 
virtual void retypeSymbol (Symbol *sym, Datatype *ct)=0
 Change the data-type of a Symbol within this Scope. More...
 
virtual void setAttribute (Symbol *sym, uint4 attr)=0
 Set boolean Varnode properties on a Symbol.
 
virtual void clearAttribute (Symbol *sym, uint4 attr)=0
 Clear boolean Varnode properties on a Symbol.
 
virtual void setDisplayFormat (Symbol *sym, uint4 attr)=0
 Set the display format for a Symbol.
 
virtual SymbolEntryfindAddr (const Address &addr, const Address &usepoint) const =0
 Find a Symbol at a given address and usepoint. More...
 
virtual SymbolEntryfindContainer (const Address &addr, int4 size, const Address &usepoint) const =0
 Find the smallest Symbol containing the given memory range. More...
 
virtual SymbolEntryfindClosestFit (const Address &addr, int4 size, const Address &usepoint) const =0
 Find Symbol which is the closest fit to the given memory range. More...
 
virtual FuncdatafindFunction (const Address &addr) const =0
 Find the function starting at the given address. More...
 
virtual ExternRefSymbolfindExternalRef (const Address &addr) const =0
 Find an external reference at the given address. More...
 
virtual LabSymbolfindCodeLabel (const Address &addr) const =0
 Find a label Symbol at the given address. More...
 
virtual SymbolEntryfindOverlap (const Address &addr, int4 size) const =0
 Find first Symbol overlapping the given memory range. More...
 
virtual void findByName (const string &nm, vector< Symbol *> &res) const =0
 Find a Symbol by name within this Scope. More...
 
virtual bool isNameUsed (const string &nm, const Scope *op2) const =0
 Check if the given name is occurs within the given scope path. More...
 
virtual FuncdataresolveExternalRefFunction (ExternRefSymbol *sym) const =0
 Convert an external reference to the referenced function. More...
 
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. More...
 
virtual string buildUndefinedName (void) const =0
 Build a formal undefined name, used internally when a Symbol is not given a name. More...
 
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. More...
 
virtual void encode (Encoder &encoder) const =0
 Encode this as a <scope> element.
 
virtual void decode (Decoder &decoder)=0
 Decode this Scope from a <scope> element.
 
virtual void decodeWrappingAttributes (Decoder &decoder)
 Restore attributes for this Scope from wrapping element.
 
virtual void printEntries (ostream &s) const =0
 Dump a description of all SymbolEntry objects to a stream.
 
virtual int4 getCategorySize (int4 cat) const =0
 Get the number of Symbols in the given category. More...
 
virtual SymbolgetCategorySymbol (int4 cat, int4 ind) const =0
 Retrieve a Symbol by index within a specific category. More...
 
virtual void setCategory (Symbol *sym, int4 cat, int4 ind)=0
 Set the category and index for the given Symbol. More...
 
virtual SymbolEntryaddSymbol (const string &nm, Datatype *ct, const Address &addr, const Address &usepoint)
 Add a new Symbol to this Scope, given a name, data-type, and a single mapping. More...
 
const string & getName (void) const
 Get the name of the Scope.
 
const string & getDisplayName (void) const
 Get name displayed in output.
 
uint8 getId (void) const
 Get the globally unique id.
 
bool isGlobal (void) const
 Return true if this scope is global.
 
void queryByName (const string &nm, vector< Symbol *> &res) const
 Look-up symbols by name. More...
 
FuncdataqueryFunction (const string &nm) const
 Look-up a function by name. More...
 
SymbolEntryqueryByAddr (const Address &addr, const Address &usepoint) const
 Get Symbol with matching address. More...
 
SymbolEntryqueryContainer (const Address &addr, int4 size, const Address &usepoint) const
 Find the smallest containing Symbol. More...
 
SymbolEntryqueryProperties (const Address &addr, int4 size, const Address &usepoint, uint4 &flags) const
 Find a Symbol or properties at the given address. More...
 
FuncdataqueryFunction (const Address &addr) const
 Look-up a function by address. More...
 
FuncdataqueryExternalRefFunction (const Address &addr) const
 Look-up a function thru an external reference. More...
 
LabSymbolqueryCodeLabel (const Address &addr) const
 Look-up a code label by address. More...
 
ScoperesolveScope (const string &nm, bool strategy) const
 Find a child Scope of this. More...
 
ScopediscoverScope (const Address &addr, int4 sz, const Address &usepoint)
 Find the owning Scope of a given memory range. More...
 
ScopeMap::const_iterator childrenBegin () const
 Beginning iterator of child scopes.
 
ScopeMap::const_iterator childrenEnd () const
 Ending iterator of child scopes.
 
void encodeRecursive (Encoder &encoder, bool onlyGlobal) const
 Encode all contained scopes to a stream. More...
 
void overrideSizeLockType (Symbol *sym, Datatype *ct)
 Change the data-type of a Symbol that is sizelocked. More...
 
void resetSizeLockType (Symbol *sym)
 Clear a Symbol's size-locked data-type. More...
 
void setThisPointer (Symbol *sym, bool val)
 Toggle the given Symbol as the "this" pointer.
 
bool isSubScope (const Scope *scp) const
 Is this a sub-scope of the given Scope. More...
 
string getFullName (void) const
 Get the full name of this Scope.
 
void getScopePath (vector< const Scope *> &vec) const
 Get the ordered list of scopes up to this. More...
 
const ScopefindDistinguishingScope (const Scope *op2) const
 Find first ancestor of this not shared by given scope. More...
 
ArchitecturegetArch (void) const
 Get the Architecture associated with this.
 
ScopegetParent (void) const
 Get the parent Scope (or NULL if this is the global Scope)
 
SymboladdSymbol (const string &nm, Datatype *ct)
 Add a new Symbol without mapping it to an address. More...
 
SymbolEntryaddMapPoint (Symbol *sym, const Address &addr, const Address &usepoint)
 Map a Symbol to a specific address. More...
 
SymboladdMapSym (Decoder &decoder)
 Parse a mapped Symbol from a <mapsym> element. More...
 
FunctionSymboladdFunction (const Address &addr, const string &nm)
 Create a function Symbol at the given address in this Scope. More...
 
ExternRefSymboladdExternalRef (const Address &addr, const Address &refaddr, const string &nm)
 
LabSymboladdCodeLabel (const Address &addr, const string &nm)
 Create a code label at the given address in this Scope. More...
 
SymboladdDynamicSymbol (const string &nm, Datatype *ct, const Address &caddr, uint8 hash)
 Create a dynamically mapped Symbol attached to a specific data-flow. More...
 
SymboladdEquateSymbol (const string &nm, uint4 format, uintb value, const Address &addr, uint8 hash)
 Create a symbol that forces display conversion on a constant. More...
 
SymboladdUnionFacetSymbol (const string &nm, Datatype *dt, int4 fieldNum, const Address &addr, uint8 hash)
 Create a symbol forcing a field interpretation for a specific access to a variable with union data-type. More...
 
string buildDefaultName (Symbol *sym, int4 &base, Varnode *vn) const
 Create a default name for the given Symbol. More...
 
bool isReadOnly (const Address &addr, int4 size, const Address &usepoint) const
 Is the given memory range marked as read-only. More...
 
void printBounds (ostream &s) const
 Print a description of this Scope's owned memory ranges.
 

Protected Member Functions

const RangeListgetRangeTree (void) const
 Access the address ranges owned by this Scope.
 
virtual ScopebuildSubScope (uint8 id, const string &nm)=0
 Build an unattached Scope to be associated as a sub-scope of this. More...
 
virtual void restrictScope (Funcdata *f)
 Convert this to a local Scope. More...
 
virtual void addRange (AddrSpace *spc, uintb first, uintb last)
 Add a memory range to the ownership of this Scope. More...
 
virtual void removeRange (AddrSpace *spc, uintb first, uintb last)
 Remove a memory range from the ownership of this Scope. More...
 
virtual void addSymbolInternal (Symbol *sym)=0
 Put a Symbol into the name map. More...
 
virtual SymbolEntryaddMapInternal (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. More...
 
virtual SymbolEntryaddDynamicMapInternal (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. More...
 
SymbolEntryaddMap (SymbolEntry &entry)
 Integrate a SymbolEntry into the range maps. More...
 
void setSymbolId (Symbol *sym, uint8 id) const
 Adjust the id associated with a symbol.
 
void setDisplayName (const string &nm)
 Change name displayed in output.
 

Static Protected Member Functions

static const ScopestackAddr (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. More...
 
static const ScopestackContainer (const Scope *scope1, const Scope *scope2, const Address &addr, int4 size, const Address &usepoint, SymbolEntry **addrmatch)
 
static const ScopestackClosestFit (const Scope *scope1, const Scope *scope2, const Address &addr, int4 size, const Address &usepoint, SymbolEntry **addrmatch)
 
static const ScopestackFunction (const Scope *scope1, const Scope *scope2, const Address &addr, Funcdata **addrmatch)
 
static const ScopestackExternalRef (const Scope *scope1, const Scope *scope2, const Address &addr, ExternRefSymbol **addrmatch)
 
static const ScopestackCodeLabel (const Scope *scope1, const Scope *scope2, const Address &addr, LabSymbol **addrmatch)
 

Protected Attributes

Architectureglb
 Architecture of this scope.
 
string name
 Name of this scope.
 
string displayName
 Name to display in output.
 
Funcdatafd
 (If non-null) the function which this is the local Scope for
 
uint8 uniqueId
 Unique id for the scope, for deduping scope names, assigning symbol ids.
 

Private Member Functions

void attachScope (Scope *child)
 Attach a new child Scope to this. More...
 
void detachScope (ScopeMap::iterator iter)
 Detach a child Scope from this. More...
 

Static Private Member Functions

static uint8 hashScopeName (uint8 baseId, const string &nm)
 Create a Scope id based on the scope's name and its parent's id. More...
 

Private Attributes

RangeList rangetree
 Range of data addresses owned by this scope.
 
Scopeparent
 The parent scope.
 
Scopeowner
 Scope using this as a cache.
 
ScopeMap children
 Sorted list of child scopes.
 

Friends

class Database
 
class ScopeCompare
 

Detailed Description

A collection of Symbol objects within a single (namespace or functional) scope.

This acts as a traditional Symbol container, allowing them to be accessed by name, but it also keeps track of how a Symbol is mapped into memory. It allows a Symbol to be looked up by its location in memory, which is sensitive to the address of the code accessing the Symbol.

Capabilities include:

A scope also supports the idea of ownership of memory. In theory, for a Symbol in the scope, at the code locations where the Symbol storage is valid, the scope owns the storage memory. In practice, a Scope object knows about memory ranges where a Symbol might be discovered. For instance, the global Scope usually owns all memory in the ram address space.

Member Function Documentation

◆ addCodeLabel()

LabSymbol * ghidra::Scope::addCodeLabel ( const Address addr,
const string &  nm 
)

Create a code label at the given address in this Scope.

A LabSymbol is created and mapped to the given address.

Parameters
addris the given address to map to
nmis the name of the symbol/label
Returns
the new LabSymbol

References ghidra::Symbol::getName(), and ghidra::SymbolEntry::getSymbol().

Referenced by ghidra::IfcMaplabel::execute(), and ghidra::ScopeGhidra::findCodeLabel().

◆ addDynamicMapInternal()

virtual SymbolEntry* ghidra::Scope::addDynamicMapInternal ( Symbol sym,
uint4  exfl,
uint8  hash,
int4  off,
int4  sz,
const RangeList uselim 
)
protectedpure virtual

Create a new SymbolEntry for a Symbol given a dynamic hash.

The SymbolEntry is specified in terms of a hash and usepoint, which describe how to find the temporary Varnode holding the symbol value.

Parameters
symis the given Symbol being mapped
exflare any boolean Varnode properties
hashis the given dynamic hash
offis the byte offset of the new SymbolEntry (relative to the whole Symbol)
szis the number of bytes occupied by the Varnode
uselimis the given usepoint
Returns
the newly created SymbolEntry

Implemented in ghidra::ScopeInternal, and ghidra::ScopeGhidra.

◆ addDynamicSymbol()

Symbol * ghidra::Scope::addDynamicSymbol ( const string &  nm,
Datatype ct,
const Address caddr,
uint8  hash 
)

Create a dynamically mapped Symbol attached to a specific data-flow.

The Symbol is created and mapped to a dynamic hash and a code address where the Symbol is being used.

Parameters
nmis the name of the Symbol
ctis the data-type of the Symbol
caddris the code address where the Symbol is being used
hashis the dynamic hash
Returns
the new Symbol

References ghidra::Address::getOffset(), ghidra::Datatype::getSize(), ghidra::Address::getSpace(), ghidra::RangeList::insertRange(), ghidra::Address::isInvalid(), ghidra::Varnode::mapped, and ghidra::Symbol::Symbol().

Referenced by ghidra::Funcdata::buildDynamicSymbol().

◆ addEquateSymbol()

Symbol * ghidra::Scope::addEquateSymbol ( const string &  nm,
uint4  format,
uintb  value,
const Address addr,
uint8  hash 
)

Create a symbol that forces display conversion on a constant.

Parameters
nmis the equate name to display, which may be empty for an integer conversion
formatis the type of integer conversion (Symbol::force_hex, Symbol::force_dec, etc.)
valueis the constant value being converted
addris the address of the p-code op reading the constant
hashis the dynamic hash identifying the constant
Returns
the new EquateSymbol

References ghidra::Address::getOffset(), ghidra::Address::getSpace(), ghidra::RangeList::insertRange(), ghidra::Address::isInvalid(), and ghidra::Varnode::mapped.

Referenced by ghidra::Funcdata::buildDynamicSymbol().

◆ addExternalRef()

ExternRefSymbol * ghidra::Scope::addExternalRef ( const Address addr,
const Address refaddr,
const string &  nm 
)

Create an external reference at the given address in this Scope

An ExternRefSymbol is created and mapped to the given address and stores a reference address to the actual function.

Parameters
addris the given address to map the Symbol to
refaddris the reference address
nmis the name of the symbol/function
Returns
the new ExternRefSymbol

References ghidra::ExternRefSymbol::ExternRefSymbol(), ghidra::Symbol::flags, ghidra::Varnode::readonly, and ghidra::SymbolEntry::symbol.

◆ addFunction()

FunctionSymbol * ghidra::Scope::addFunction ( const Address addr,
const string &  nm 
)

Create a function Symbol at the given address in this Scope.

The FunctionSymbol is created and mapped to the given address. A Funcdata object is only created once FunctionSymbol::getFunction() is called.

Parameters
addris the entry address of the function
nmis the name of the function, within this Scope
Returns
the new FunctionSymbol object

References ghidra::Symbol::getName(), ghidra::SymbolEntry::getSymbol(), and ghidra::Symbol::name.

Referenced by ghidra::IfcMapfunction::execute(), and ghidra::Architecture::readLoaderSymbols().

◆ addMap()

SymbolEntry * ghidra::Scope::addMap ( SymbolEntry entry)
protected

Integrate a SymbolEntry into the range maps.

The mapping is given as an unintegrated SymbolEntry object. Memory may be specified in terms of join addresses, which this method must unravel. The offset, size, and extraflags fields of the SymbolEntry are not used. In particular, the SymbolEntry is assumed to map the entire Symbol.

Parameters
entryis the given SymbolEntry
Returns
a SymbolEntry which has been fully integrated

References ghidra::SymbolEntry::addr, ghidra::Varnode::addrtied, ghidra::RangeList::clear(), ghidra::RangeList::empty(), ghidra::Symbol::flags, ghidra::Symbol::getBytesConsumed(), ghidra::Address::getOffset(), ghidra::JoinRecord::getPiece(), ghidra::SymbolEntry::hash, inScope(), ghidra::Address::isBigEndian(), ghidra::Address::isInvalid(), ghidra::Address::isJoin(), ghidra::Varnode::mapped, ghidra::JoinRecord::numPieces(), ghidra::Varnode::persist, ghidra::Varnode::precishi, ghidra::Varnode::precislo, ghidra::SymbolEntry::symbol, and ghidra::SymbolEntry::uselimit.

◆ addMapInternal()

virtual SymbolEntry* ghidra::Scope::addMapInternal ( Symbol sym,
uint4  exfl,
const Address addr,
int4  off,
int4  sz,
const RangeList uselim 
)
protectedpure virtual

Create a new SymbolEntry for a Symbol given a memory range.

The SymbolEntry is specified in terms of a memory range and usepoint

Parameters
symis the given Symbol being mapped
exflare any boolean Varnode properties specific to the memory range
addris the starting address of the given memory range
offis the byte offset of the new SymbolEntry (relative to the whole Symbol)
szis the number of bytes in the range
uselimis the given usepoint (which may be invalid)
Returns
the newly created SymbolEntry

Implemented in ghidra::ScopeInternal, ghidra::ScopeGhidraNamespace, and ghidra::ScopeGhidra.

◆ addMapPoint()

SymbolEntry * ghidra::Scope::addMapPoint ( Symbol sym,
const Address addr,
const Address usepoint 
)

Map a Symbol to a specific address.

Create a new SymbolEntry that maps the whole Symbol to the given address

Parameters
symis the Symbol
addris the given address to map to
usepointis a point at which the Symbol is accessed at that address
Returns
the SymbolEntry representing the new mapping

References ghidra::SymbolEntry::addr, ghidra::Address::getOffset(), ghidra::Address::getSpace(), ghidra::RangeList::insertRange(), ghidra::Address::isInvalid(), and ghidra::SymbolEntry::uselimit.

Referenced by ghidra::ScopeInternal::retypeSymbol().

◆ addMapSym()

Symbol * ghidra::Scope::addMapSym ( Decoder decoder)

Parse a mapped Symbol from a <mapsym> element.

A Symbol element is parsed first, followed by sequences of <addr> elements or <hash> and <rangelist> elements which define 1 or more mappings of the Symbol. The new Symbol and SymbolEntry mappings are integrated into this Scope.

Parameters
decoderis the stream decoder
Returns
the new Symbol

References ghidra::Decoder::closeElement(), ghidra::SymbolEntry::decode(), ghidra::Symbol::decode(), ghidra::ExternRefSymbol::ExternRefSymbol(), ghidra::Symbol::getName(), ghidra::SymbolEntry::isInvalid(), ghidra::Decoder::openElement(), ghidra::Decoder::peekElement(), and ghidra::Symbol::Symbol().

Referenced by ghidra::ScopeInternal::decode(), and ghidra::ScopeGhidra::dump2Cache().

◆ addRange()

void ghidra::Scope::addRange ( AddrSpace spc,
uintb  first,
uintb  last 
)
protectedvirtual

Add a memory range to the ownership of this Scope.

Parameters
spcis the address space of the range
firstis the offset of the first byte in the range
lastis the offset of the last byte in the range

Reimplemented in ghidra::ScopeGhidra.

Referenced by ghidra::ScopeGhidra::addRange(), ghidra::Database::addRange(), and ghidra::IfcGlobalAdd::execute().

◆ addSymbol() [1/2]

SymbolEntry * ghidra::Scope::addSymbol ( const string &  nm,
Datatype ct,
const Address addr,
const Address usepoint 
)
virtual

Add a new Symbol to this Scope, given a name, data-type, and a single mapping.

The Symbol object will be created with the given name and data-type. A single mapping (SymbolEntry) will be created for the Symbol based on a given storage address for the symbol and an address for code that accesses the Symbol at that storage location.

Parameters
nmis the new name of the Symbol
ctis the data-type of the new Symbol
addris the starting address of the Symbol storage
usepointis the point accessing that storage (may be invalid)
Returns
the SymbolEntry matching the new mapping

Reimplemented in ghidra::ScopeGhidra.

References ghidra::Datatype::getStripped(), ghidra::Datatype::hasStripped(), and ghidra::Symbol::Symbol().

Referenced by ghidra::ScopeGhidra::addSymbol(), ghidra::Funcdata::coverVarnodes(), ghidra::ScopeLocal::createEntry(), ghidra::ScopeInternal::decodeCollision(), ghidra::IfcMapaddress::execute(), ghidra::IfcNameVarnode::execute(), ghidra::IfcTypeVarnode::execute(), ghidra::IfcGlobalRegisters::execute(), ghidra::Funcdata::linkSymbol(), and ghidra::Funcdata::mapGlobals().

◆ addSymbol() [2/2]

Symbol * ghidra::Scope::addSymbol ( const string &  nm,
Datatype ct 
)

Add a new Symbol without mapping it to an address.

The Symbol is created and added to any name map, but no SymbolEntry objects are created for it.

Parameters
nmis the name of the new Symbol
ctis a data-type to assign to the new Symbol
Returns
the new Symbol object

References ghidra::Symbol::Symbol().

◆ addSymbolInternal()

virtual void ghidra::Scope::addSymbolInternal ( Symbol sym)
protectedpure virtual

Put a Symbol into the name map.

Parameters
symis the preconstructed Symbol

Implemented in ghidra::ScopeInternal, and ghidra::ScopeGhidra.

◆ addUnionFacetSymbol()

Symbol * ghidra::Scope::addUnionFacetSymbol ( const string &  nm,
Datatype dt,
int4  fieldNum,
const Address addr,
uint8  hash 
)

Create a symbol forcing a field interpretation for a specific access to a variable with union data-type.

The symbol is attached to a specific Varnode and a PcodeOp that reads or writes to it. The Varnode, in the context of the PcodeOp, is forced to have the data-type of the selected field, and field's name is used to represent the Varnode in output.

Parameters
nmis the name of the symbol
dtis the union data-type containing the field to force
fieldNumis the index of the desired field, or -1 if the whole union should be forced
addris the address of the p-code op reading/writing the Varnode
hashis the dynamic hash identifying the Varnode
Returns
the new UnionFacetSymbol

References ghidra::Address::getOffset(), ghidra::Address::getSpace(), ghidra::RangeList::insertRange(), ghidra::Address::isInvalid(), and ghidra::Varnode::mapped.

◆ adjustCaches()

virtual void ghidra::Scope::adjustCaches ( void  )
pure virtual

Let scopes internally adjust any caches.

This is called once after Architecture configuration is complete.

Implemented in ghidra::ScopeInternal, and ghidra::ScopeGhidra.

◆ attachScope()

void ghidra::Scope::attachScope ( Scope child)
private

Attach a new child Scope to this.

Attach the child as an immediate sub-scope of this. Take responsibility of the child's memory: the child will be freed when this is freed.

Parameters
childis the Scope to make a child

References parent, and uniqueId.

Referenced by ghidra::Database::attachScope(), ghidra::Database::decodeScope(), and ghidra::Database::findCreateScope().

◆ buildDefaultName()

string ghidra::Scope::buildDefaultName ( Symbol sym,
int4 &  base,
Varnode vn 
) const

Create a default name for the given Symbol.

Create default name given information in the Symbol and possibly a representative Varnode. This method extracts the crucial properties and then uses the buildVariableName method to construct the actual name.

Parameters
symis the given Symbol to name
baseis an index (which may get updated) used to uniquify the name
vnis an optional (may be null) Varnode representative of the Symbol
Returns
the default name

References ghidra::Varnode::addrtied, ghidra::Symbol::flags, ghidra::Symbol::function_parameter, ghidra::SymbolEntry::getAddr(), ghidra::Varnode::getAddr(), ghidra::Symbol::getCategory(), ghidra::Symbol::getCategoryIndex(), ghidra::SymbolEntry::getFirstUseAddress(), ghidra::Varnode::getFlags(), ghidra::Varnode::getHigh(), ghidra::Symbol::getMapEntry(), ghidra::Symbol::getType(), ghidra::Varnode::getUsePoint(), ghidra::Varnode::input, ghidra::Varnode::isAddrTied(), ghidra::Varnode::isConstant(), ghidra::HighVariable::isInput(), ghidra::Address::isInvalid(), and ghidra::Symbol::numEntries().

Referenced by ghidra::ActionNameVars::apply(), and ghidra::ScopeInternal::assignDefaultNames().

◆ buildSubScope()

virtual Scope* ghidra::Scope::buildSubScope ( uint8  id,
const string &  nm 
)
protectedpure virtual

Build an unattached Scope to be associated as a sub-scope of this.

This is a Scope object factory, intended to be called off of the global scope for building global namespace scopes. Function scopes are handled differently.

Parameters
idis the globally unique id associated with the scope
nmis the name of the new scope
Returns
the new Scope object

Implemented in ghidra::ScopeInternal, and ghidra::ScopeGhidra.

Referenced by ghidra::Database::findCreateScope().

◆ buildUndefinedName()

virtual string ghidra::Scope::buildUndefinedName ( void  ) const
pure virtual

Build a formal undefined name, used internally when a Symbol is not given a name.

Returns
a special internal name that won't collide with other names in this Scope

Implemented in ghidra::ScopeInternal, and ghidra::ScopeGhidra.

◆ buildVariableName()

virtual string ghidra::Scope::buildVariableName ( const Address addr,
const Address pc,
Datatype ct,
int4 &  index,
uint4  flags 
) const
pure virtual

Given an address and data-type, build a suitable generic symbol name.

Parameters
addris the given address
pcis the address at which the name is getting used
ctis a data-type used to inform the name
indexis a reference to an index used to make the name unique, which will be updated
flagsare boolean properties of the variable we need the name for
Returns
the new variable name

Implemented in ghidra::ScopeInternal, ghidra::ScopeLocal, and ghidra::ScopeGhidra.

Referenced by ghidra::Funcdata::mapGlobals().

◆ detachScope()

void ghidra::Scope::detachScope ( ScopeMap::iterator  iter)
private

Detach a child Scope from this.

The indicated child Scope is deleted

Parameters
iterpoints to the Scope to delete

Referenced by ghidra::Database::deleteScope(), and ghidra::Database::deleteSubScopes().

◆ discoverScope()

Scope * ghidra::Scope::discoverScope ( const Address addr,
int4  sz,
const Address usepoint 
)

Find the owning Scope of a given memory range.

Discover a sub-scope or containing Scope of this, that owns the given memory range at a specific usepoint. Note that ownership does not necessarily mean there is a known symbol there.

Parameters
addris the starting address of the memory range
szis the number of bytes in the range
usepointis a point at which the memory is getting accesses

References getParent(), inScope(), and ghidra::Address::isConstant().

Referenced by ghidra::IfcNameVarnode::execute(), ghidra::IfcTypeVarnode::execute(), and ghidra::Funcdata::mapGlobals().

◆ encodeRecursive()

void ghidra::Scope::encodeRecursive ( Encoder encoder,
bool  onlyGlobal 
) const

Encode all contained scopes to a stream.

This Scope and all of its sub-scopes are encoded as a sequence of <scope> elements in post order. For each Scope, the encode() method is invoked.

Parameters
encoderis the stream encoder
onlyGlobalis true if only non-local Scopes should be saved

References ghidra::ExternRefSymbol::encode().

Referenced by ghidra::Funcdata::encode().

◆ findAddr()

virtual SymbolEntry* ghidra::Scope::findAddr ( const Address addr,
const Address usepoint 
) const
pure virtual

Find a Symbol at a given address and usepoint.

Parameters
addris the given address
usepointis the point at which the Symbol is accessed (may be invalid)
Returns
the matching SymbolEntry or NULL

Implemented in ghidra::ScopeInternal, and ghidra::ScopeGhidra.

Referenced by stackAddr().

◆ findByName()

virtual void ghidra::Scope::findByName ( const string &  nm,
vector< Symbol *> &  res 
) const
pure virtual

Find a Symbol by name within this Scope.

If there are multiple Symbols with the same name, all are passed back.

Parameters
nmis the name to search for
reswill contain any matching Symbols

Implemented in ghidra::ScopeInternal, and ghidra::ScopeGhidra.

◆ findClosestFit()

virtual SymbolEntry* ghidra::Scope::findClosestFit ( const Address addr,
int4  size,
const Address usepoint 
) const
pure virtual

Find Symbol which is the closest fit to the given memory range.

Parameters
addris the starting address of the given memory range
sizeis the number of bytes in the range
usepointis the point at which the Symbol is accessed (may be invalid)
Returns
the matching SymbolEntry or NULL

Implemented in ghidra::ScopeInternal, and ghidra::ScopeGhidra.

Referenced by stackClosestFit().

◆ findCodeLabel()

virtual LabSymbol* ghidra::Scope::findCodeLabel ( const Address addr) const
pure virtual

Find a label Symbol at the given address.

Parameters
addris the given address
Returns
the matching LabSymbol or NULL

Implemented in ghidra::ScopeInternal, and ghidra::ScopeGhidra.

Referenced by stackCodeLabel().

◆ findContainer()

virtual SymbolEntry* ghidra::Scope::findContainer ( const Address addr,
int4  size,
const Address usepoint 
) const
pure virtual

Find the smallest Symbol containing the given memory range.

Parameters
addris the starting address of the given memory range
sizeis the number of bytes in the range
usepointis the point at which the Symbol is accessed (may be invalid)
Returns
the matching SymbolEntry or NULL

Implemented in ghidra::ScopeInternal, and ghidra::ScopeGhidra.

Referenced by ghidra::Funcdata::coverVarnodes(), and stackContainer().

◆ findDistinguishingScope()

const Scope * ghidra::Scope::findDistinguishingScope ( const Scope op2) const

Find first ancestor of this not shared by given scope.

Any two scopes share at least the global scope as a common ancestor. We find the first scope that is not in common. The scope returned will always be an ancestor of this. If this is an ancestor of the other given scope, then null is returned.

Parameters
op2is the other given Scope
Returns
the first ancestor Scope that is not in common or null

References getScopePath(), and parent.

Referenced by ghidra::Symbol::getResolutionDepth().

◆ findExternalRef()

virtual ExternRefSymbol* ghidra::Scope::findExternalRef ( const Address addr) const
pure virtual

Find an external reference at the given address.

Parameters
addris the given address
Returns
the matching ExternRefSymbol or NULL

Implemented in ghidra::ScopeInternal, and ghidra::ScopeGhidra.

Referenced by stackExternalRef().

◆ findFunction()

virtual Funcdata* ghidra::Scope::findFunction ( const Address addr) const
pure virtual

Find the function starting at the given address.

Parameters
addris the given starting address
Returns
the matching Funcdata object or NULL

Implemented in ghidra::ScopeInternal, and ghidra::ScopeGhidra.

Referenced by stackFunction().

◆ findOverlap()

virtual SymbolEntry* ghidra::Scope::findOverlap ( const Address addr,
int4  size 
) const
pure virtual

Find first Symbol overlapping the given memory range.

Parameters
addris the starting address of the given range
sizeis the number of bytes in the range
Returns
an overlapping SymbolEntry or NULL if none exists

Implemented in ghidra::ScopeInternal, and ghidra::ScopeGhidra.

◆ getCategorySize()

virtual int4 ghidra::Scope::getCategorySize ( int4  cat) const
pure virtual

Get the number of Symbols in the given category.

Parameters
catis the Symbol category
Returns
the number in that category

Implemented in ghidra::ScopeInternal, and ghidra::ScopeGhidra.

Referenced by ghidra::PrintC::emitScopeVarDecls().

◆ getCategorySymbol()

virtual Symbol* ghidra::Scope::getCategorySymbol ( int4  cat,
int4  ind 
) const
pure virtual

Retrieve a Symbol by index within a specific category.

Parameters
catis the Symbol category
indis the index (within the category) of the Symbol
Returns
the indicated Symbol or NULL if no Symbol with that index exists

Implemented in ghidra::ScopeInternal, and ghidra::ScopeGhidra.

Referenced by ghidra::PrintC::emitScopeVarDecls().

◆ getScopePath()

void ghidra::Scope::getScopePath ( vector< const Scope *> &  vec) const

Get the ordered list of scopes up to this.

Put the parent scopes of this into an array in order, starting with the global scope.

Parameters
vecis storage for the array of scopes

References parent.

Referenced by findDistinguishingScope().

◆ hashScopeName()

uint8 ghidra::Scope::hashScopeName ( uint8  baseId,
const string &  nm 
)
staticprivate

Create a Scope id based on the scope's name and its parent's id.

Create a globally unique id for a scope simply from its name.

Parameters
baseIdis the scope id of the parent scope
nmis the name of scope
Returns
the hash of the parent id and name

References ghidra::crc_update().

Referenced by ghidra::Database::findCreateScopeFromSymbolName().

◆ inScope()

virtual bool ghidra::Scope::inScope ( const Address addr,
int4  size,
const Address usepoint 
) const
inlinevirtual

Query if the given range is owned by this Scope.

All bytes in the range must be owned, and ownership can be informed by particular code that is accessing the range.

Parameters
addris the starting address of the range
sizeis the number of bytes in the range
usepointis the code address at which the given range is being accessed (may be invalid)
Returns
true if this Scope owns the memory range

References ghidra::SymbolEntry::decode(), ghidra::SymbolEntry::encode(), ghidra::RangeList::inRange(), ghidra::SymbolEntry::size, and ghidra::SymbolEntry::EntryInitData::symbol.

Referenced by addMap(), discoverScope(), stackAddr(), stackClosestFit(), stackCodeLabel(), stackContainer(), stackFunction(), and ghidra::Funcdata::syncVarnodesWithSymbols().

◆ isNameUsed()

virtual bool ghidra::Scope::isNameUsed ( const string &  nm,
const Scope op2 
) const
pure virtual

Check if the given name is occurs within the given scope path.

Test for the presence of a symbol with the given name in either this scope or an ancestor scope up to but not including the given terminating scope. If the name is used true is returned.

Parameters
nmis the given name to test
op2is the terminating ancestor scope (or null)

Implemented in ghidra::ScopeInternal, ghidra::ScopeGhidraNamespace, and ghidra::ScopeGhidra.

Referenced by ghidra::Symbol::getResolutionDepth(), and ghidra::ScopeInternal::isNameUsed().

◆ isReadOnly()

bool ghidra::Scope::isReadOnly ( const Address addr,
int4  size,
const Address usepoint 
) const

Is the given memory range marked as read-only.

Check for Symbols relative to this Scope that are marked as read-only, and look-up properties of the memory in general.

Parameters
addris the starting address of the given memory range
sizeis the number of bytes in the range
usepointis a point where the range is getting accessed
Returns
true if the memory is marked as read-only

References ghidra::Symbol::flags, and ghidra::Varnode::readonly.

Referenced by ghidra::RulePtrsubCharConstant::applyOp(), and ghidra::PrintC::pushPtrCharConstant().

◆ isSubScope()

bool ghidra::Scope::isSubScope ( const Scope scp) const

Is this a sub-scope of the given Scope.

Does the given Scope contain this as a sub-scope.

Parameters
scpis the given Scope
Returns
true if this is a sub-scope

References parent.

◆ makeNameUnique()

virtual string ghidra::Scope::makeNameUnique ( const string &  nm) const
pure virtual

Produce a version of the given symbol name that won't collide with other names in this Scope.

Parameters
nmis the given name
Returns
return a unique version of the name

Implemented in ghidra::ScopeInternal, and ghidra::ScopeGhidra.

◆ overrideSizeLockType()

void ghidra::Scope::overrideSizeLockType ( Symbol sym,
Datatype ct 
)

Change the data-type of a Symbol that is sizelocked.

Change (override) the data-type of a sizelocked Symbol, while preserving the lock. An exception is thrown if the new data-type doesn't fit the size.

Parameters
symis the locked Symbol
ctis the data-type to change the Symbol to

References ghidra::Datatype::getSize(), ghidra::Symbol::isSizeTypeLocked(), and ghidra::Symbol::type.

Referenced by ghidra::ActionNameVars::linkSymbols().

◆ queryByAddr()

SymbolEntry * ghidra::Scope::queryByAddr ( const Address addr,
const Address usepoint 
) const

Get Symbol with matching address.

Within a sub-scope or containing Scope of this, find a Symbol that is mapped to the given address, where the mapping is valid at a specific usepoint.

Parameters
addris the given address
usepointis the point at which code accesses that address (may be invalid)
Returns
the matching SymbolEntry

◆ queryByName()

void ghidra::Scope::queryByName ( const string &  nm,
vector< Symbol *> &  res 
) const

Look-up symbols by name.

Starting from this Scope, look for a Symbol with the given name. If there are no Symbols in this Scope, recurse into the parent Scope. If there are 1 (or more) Symbols matching in this Scope, add them to the result list

Parameters
nmis the name to search for
resis the result list

Referenced by ghidra::ScopeGhidra::dump2Cache(), ghidra::Funcdata::findHigh(), and ghidra::IfaceDecompData::readSymbol().

◆ queryCodeLabel()

LabSymbol * ghidra::Scope::queryCodeLabel ( const Address addr) const

Look-up a code label by address.

Within a sub-scope or containing Scope of this, find a label Symbol at the given address.

Parameters
addris the given address
Returns
the LabSymbol object, or NULL if it doesn't exist

Referenced by ghidra::PrintC::emitLabel().

◆ queryContainer()

SymbolEntry * ghidra::Scope::queryContainer ( const Address addr,
int4  size,
const Address usepoint 
) const

Find the smallest containing Symbol.

Within a sub-scope or containing Scope of this, find the smallest Symbol that contains a given memory range and can be accessed at a given usepoint.

Parameters
addris the given starting address of the memory range
sizeis the number of bytes in the range
usepointis a point at which the Symbol is accessed (may be invalid)
Returns
the matching SymbolEntry or NULL

Referenced by ghidra::TypeSpacebase::getSubType(), ghidra::ActionConstantPtr::isPointer(), ghidra::Funcdata::linkSymbolReference(), ghidra::TypeSpacebase::nearestArrayedComponentForward(), and ghidra::PrintC::pushAnnotation().

◆ queryExternalRefFunction()

Funcdata * ghidra::Scope::queryExternalRefFunction ( const Address addr) const

Look-up a function thru an external reference.

Given an address, search for an external reference. If no Symbol is found and this Scope does not own the address, recurse searching in the parent Scope. If an external reference is found, try to resolve the function it refers to and return it.

Parameters
addris the given address where an external reference might be
Returns
the referred to Funcdata object or NULL if not found

References resolveExternalRefFunction().

Referenced by ghidra::ActionDeindirect::apply().

◆ queryFunction() [1/2]

Funcdata * ghidra::Scope::queryFunction ( const string &  nm) const

Look-up a function by name.

Starting with this Scope, find a function with the given name. If there are no Symbols with that name in this Scope at all, recurse into the parent Scope.

Parameters
nmif the name to search for
Returns
the Funcdata object of the matching function, or NULL if it doesn't exist

References ghidra::FunctionSymbol::getFunction().

Referenced by ghidra::OptionExtraPop::apply(), ghidra::OptionInline::apply(), ghidra::OptionNoReturn::apply(), ghidra::ActionDeindirect::apply(), ghidra::IfcFuncload::execute(), ghidra::IfcCallGraphLoad::execute(), ghidra::IfcFixupApply::execute(), ghidra::TypeSpacebase::getMap(), ghidra::PrintC::pushPtrCodeConstant(), ghidra::FlowInfo::queryCall(), ghidra::ScopeInternal::resolveExternalRefFunction(), and ghidra::Architecture::setPrototype().

◆ queryFunction() [2/2]

Funcdata * ghidra::Scope::queryFunction ( const Address addr) const

Look-up a function by address.

Within a sub-scope or containing Scope of this, find a function starting at the given address.

Parameters
addris the starting address of the function
Returns
the Funcdata object of the matching function, or NULL if it doesn't exist

◆ queryProperties()

SymbolEntry * ghidra::Scope::queryProperties ( const Address addr,
int4  size,
const Address usepoint,
uint4 &  flags 
) const

Find a Symbol or properties at the given address.

Similarly to queryContainer(), this searches for the smallest containing Symbol, but whether a known Symbol is found or not, boolean properties associated with the memory range are also search for and passed back.

Parameters
addris the starting address of the range
sizeis the number of bytes in the range
usepointis a point at which the memory range is accessed (may be invalid)
flagsis a reference used to pass back the boolean properties of the memory range
Returns
the smallest SymbolEntry containing the range, or NULL

References ghidra::Varnode::addrtied, ghidra::SymbolEntry::getAllFlags(), isGlobal(), ghidra::Varnode::mapped, and ghidra::Varnode::persist.

Referenced by ghidra::IfcGlobalRegisters::execute(), ghidra::TypeOpCallother::getInputLocal(), ghidra::TypeOpCallother::getOutputLocal(), ghidra::Funcdata::linkSymbol(), ghidra::Funcdata::mapGlobals(), ghidra::Funcdata::newVarnode(), ghidra::Funcdata::newVarnodeOut(), and ghidra::Funcdata::setVarnodeProperties().

◆ removeRange()

void ghidra::Scope::removeRange ( AddrSpace spc,
uintb  first,
uintb  last 
)
protectedvirtual

Remove a memory range from the ownership of this Scope.

Parameters
spcis the address space of the range
firstis the offset of the first byte in the range
lastis the offset of the last byte in the range

Reimplemented in ghidra::ScopeGhidra.

Referenced by ghidra::IfcGlobalRemove::execute(), and ghidra::Database::removeRange().

◆ resetSizeLockType()

void ghidra::Scope::resetSizeLockType ( Symbol sym)

Clear a Symbol's size-locked data-type.

Replace any overriding data-type type with the locked UNKNOWN type of the correct size. The data-type is cleared, but the lock is preserved.

Parameters
symis the Symbol to clear

References ghidra::Datatype::getMetatype(), ghidra::Datatype::getSize(), ghidra::Symbol::type, and ghidra::TYPE_UNKNOWN.

Referenced by ghidra::ScopeInternal::clearUnlocked(), and ghidra::ScopeInternal::clearUnlockedCategory().

◆ resolveExternalRefFunction()

virtual Funcdata* ghidra::Scope::resolveExternalRefFunction ( ExternRefSymbol sym) const
pure virtual

Convert an external reference to the referenced function.

Parameters
symis the Symbol marking the external reference
Returns
the underlying Funcdata object or NULL if none exists

Implemented in ghidra::ScopeInternal, and ghidra::ScopeGhidra.

Referenced by queryExternalRefFunction().

◆ resolveScope()

Scope * ghidra::Scope::resolveScope ( const string &  nm,
bool  strategy 
) const

Find a child Scope of this.

Look for the immediate child of this with a given name

Parameters
nmis the child's name
strategyis true if hash of the name determines id
Returns
the child Scope or NULL if there is no child with that name

References name, and ghidra::Symbol::scope.

Referenced by ghidra::Database::findCreateScope(), ghidra::Database::parseParentTag(), and ghidra::Database::resolveScopeFromSymbolName().

◆ restrictScope()

void ghidra::Scope::restrictScope ( Funcdata f)
protectedvirtual

Convert this to a local Scope.

Attach this to the given function, which makes this the local scope for the function

Parameters
fis the given function to attach to

Reimplemented in ghidra::ScopeGhidra.

Referenced by ghidra::ScopeLocal::ScopeLocal().

◆ retypeSymbol()

virtual void ghidra::Scope::retypeSymbol ( Symbol sym,
Datatype ct 
)
pure virtual

Change the data-type of a Symbol within this Scope.

If the size of the Symbol changes, any mapping (SymbolEntry) is adjusted

Parameters
symis the given Symbol
ctis the new data-type

Implemented in ghidra::ScopeInternal, and ghidra::ScopeGhidra.

Referenced by ghidra::IfcRetype::execute().

◆ setCategory()

virtual void ghidra::Scope::setCategory ( Symbol sym,
int4  cat,
int4  ind 
)
pure virtual

Set the category and index for the given Symbol.

Parameters
symis the given Symbol
catis the category to set for the Symbol
indis the index position to set (within the category)

Implemented in ghidra::ScopeInternal, and ghidra::ScopeGhidra.

◆ stackAddr()

const Scope * ghidra::Scope::stackAddr ( const Scope scope1,
const Scope scope2,
const Address addr,
const Address usepoint,
SymbolEntry **  addrmatch 
)
staticprotected

Query for Symbols starting at a given address, which match a given usepoint.

Searching starts at a first scope, continuing thru parents up to a second scope, which is not queried. If a Scope controls the memory at that address, the Scope object is returned. Additionally, if a symbol matching the criterion is found, the matching SymbolEntry is passed back.

Parameters
scope1is the first Scope where searching starts
scope2is the second Scope where searching ends
addris the given address to search for
usepointis the given point at which the memory is being accessed (can be an invalid address)
addrmatchis used to pass-back any matching SymbolEntry
Returns
the Scope owning the address or NULL if none found

References findAddr(), getParent(), inScope(), and ghidra::Address::isConstant().

◆ stackClosestFit()

const Scope * ghidra::Scope::stackClosestFit ( const Scope scope1,
const Scope scope2,
const Address addr,
int4  size,
const Address usepoint,
SymbolEntry **  addrmatch 
)
staticprotected

Query for a Symbol which most closely matches a given range and usepoint

Searching starts at a first scope, continuing thru parents up to a second scope, which is not queried. If a Scope controls the memory in the given range, the Scope object is returned. Among symbols that overlap the given range, the SymbolEntry which most closely matches the starting address and size is passed back.

Parameters
scope1is the first Scope where searching starts
scope2is the second Scope where searching ends
addris the starting address of the given range
sizeis the number of bytes in the given range
usepointis the point at which the memory is being accessed (can be an invalid address)
addrmatchis used to pass-back any matching SymbolEntry
Returns
the Scope owning the address or NULL if none found

References findClosestFit(), getParent(), inScope(), and ghidra::Address::isConstant().

◆ stackCodeLabel()

const Scope * ghidra::Scope::stackCodeLabel ( const Scope scope1,
const Scope scope2,
const Address addr,
LabSymbol **  addrmatch 
)
staticprotected

Query for a label Symbol for a given address.

Searching starts at a first scope, continuing thru parents up to a second scope, which is not queried. If a Scope controls the memory in the given range, the Scope object is returned. If there is a label at that address, pass back the corresponding LabSymbol object

Parameters
scope1is the first Scope where searching starts
scope2is the second Scope where searching ends
addris the given address
addrmatchis used to pass-back any matching Symbol
Returns
the Scope owning the address or NULL if none found

References findCodeLabel(), getParent(), inScope(), and ghidra::Address::isConstant().

◆ stackContainer()

const Scope * ghidra::Scope::stackContainer ( const Scope scope1,
const Scope scope2,
const Address addr,
int4  size,
const Address usepoint,
SymbolEntry **  addrmatch 
)
staticprotected

Query for a Symbol containing a given range which is accessed at a given usepoint

Searching starts at a first scope, continuing thru parents up to a second scope, which is not queried. If a Scope controls the memory in the given range, the Scope object is returned. If a known Symbol contains the range, the matching SymbolEntry is passed back.

Parameters
scope1is the first Scope where searching starts
scope2is the second Scope where searching ends
addris the starting address of the given range
sizeis the number of bytes in the given range
usepointis the point at which the memory is being accessed (can be an invalid address)
addrmatchis used to pass-back any matching SymbolEntry
Returns
the Scope owning the address or NULL if none found

References findContainer(), getParent(), inScope(), and ghidra::Address::isConstant().

◆ stackExternalRef()

const Scope * ghidra::Scope::stackExternalRef ( const Scope scope1,
const Scope scope2,
const Address addr,
ExternRefSymbol **  addrmatch 
)
staticprotected

Query for an external reference Symbol starting at the given address

Searching starts at a first scope, continuing thru parents up to a second scope, which is not queried. If a Scope controls the memory in the given range, the Scope object is returned. If an external reference is found at the address, pass back the matching ExternRefSymbol

Parameters
scope1is the first Scope where searching starts
scope2is the second Scope where searching ends
addris the given address
addrmatchis used to pass-back any matching Symbol
Returns
the Scope owning the address or NULL if none found

References findExternalRef(), getParent(), and ghidra::Address::isConstant().

◆ stackFunction()

const Scope * ghidra::Scope::stackFunction ( const Scope scope1,
const Scope scope2,
const Address addr,
Funcdata **  addrmatch 
)
staticprotected

Query for a function Symbol starting at the given address

Searching starts at a first scope, continuing thru parents up to a second scope, which is not queried. If a Scope controls the memory in the given range, the Scope object is returned. If a FunctionSymbol is found at the given address, the corresponding Funcdata object is passed back.

Parameters
scope1is the first Scope where searching starts
scope2is the second Scope where searching ends
addris the given address where the function should start
addrmatchis used to pass-back any matching function
Returns
the Scope owning the address or NULL if none found

References findFunction(), getParent(), inScope(), and ghidra::Address::isConstant().

Referenced by ghidra::ScopeGhidra::resolveExternalRefFunction().


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