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

An implementation of the Scope interface by querying a Ghidra client for Symbol information. More...

#include <database_ghidra.hh>

Inheritance diagram for ghidra::ScopeGhidra:
ghidra::Scope

Public Member Functions

 ScopeGhidra (ArchitectureGhidra *g)
 Constructor. More...
 
void lockDefaultProperties (void)
 Lock in the default state of the boolean property map. More...
 
virtual void clear (void)
 Clear all symbols from this scope.
 
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...
 
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. More...
 
virtual string buildUndefinedName (void) const
 Build a formal undefined name, used internally when a Symbol is not given a name. More...
 
virtual void setAttribute (Symbol *sym, uint4 attr)
 Set boolean Varnode properties on a Symbol.
 
virtual void clearAttribute (Symbol *sym, uint4 attr)
 Clear boolean Varnode properties on a Symbol.
 
virtual void setDisplayFormat (Symbol *sym, uint4 attr)
 Set the display format for a Symbol.
 
virtual void adjustCaches (void)
 Let scopes internally adjust any caches. More...
 
virtual SymbolEntryfindAddr (const Address &addr, const Address &usepoint) const
 Find a Symbol at a given address and usepoint. More...
 
virtual SymbolEntryfindContainer (const Address &addr, int4 size, const Address &usepoint) const
 Find the smallest Symbol containing the given memory range. More...
 
virtual SymbolEntryfindClosestFit (const Address &addr, int4 size, const Address &usepoint) const
 Find Symbol which is the closest fit to the given memory range. More...
 
virtual FuncdatafindFunction (const Address &addr) const
 Find the function starting at the given address. More...
 
virtual ExternRefSymbolfindExternalRef (const Address &addr) const
 Find an external reference at the given address. More...
 
virtual LabSymbolfindCodeLabel (const Address &addr) const
 Find a label Symbol at the given address. More...
 
virtual FuncdataresolveExternalRefFunction (ExternRefSymbol *sym) const
 Convert an external reference to the referenced function. More...
 
virtual SymbolEntryfindOverlap (const Address &addr, int4 size) const
 Find first Symbol overlapping the given memory range. More...
 
virtual void findByName (const string &nm, vector< Symbol *> &res) const
 Find a Symbol by name within this Scope. More...
 
virtual bool isNameUsed (const string &nm, const Scope *op2) const
 Check if the given name is occurs within the given scope path. More...
 
virtual MapIterator begin (void) const
 Beginning iterator to mapped SymbolEntrys.
 
virtual MapIterator end (void) const
 Ending iterator to mapped SymbolEntrys.
 
virtual list< SymbolEntry >::const_iterator beginDynamic (void) const
 Beginning iterator to dynamic SymbolEntrys.
 
virtual list< SymbolEntry >::const_iterator endDynamic (void) const
 Ending iterator to dynamic SymbolEntrys.
 
virtual list< SymbolEntry >::iterator beginDynamic (void)
 Beginning iterator to dynamic SymbolEntrys.
 
virtual list< SymbolEntry >::iterator endDynamic (void)
 Ending iterator to dynamic SymbolEntrys.
 
virtual void clearCategory (int4 cat)
 Clear all symbols of the given category from this scope.
 
virtual void clearUnlockedCategory (int4 cat)
 Clear unlocked symbols of the given category from this scope.
 
virtual void clearUnlocked (void)
 Clear all unlocked symbols from this scope.
 
virtual void restrictScope (Funcdata *f)
 Convert this to a local Scope. More...
 
virtual void removeSymbolMappings (Symbol *symbol)
 Remove all SymbolEntrys from the given Symbol.
 
virtual void removeSymbol (Symbol *symbol)
 Remove the given Symbol from this Scope.
 
virtual void renameSymbol (Symbol *sym, const string &newname)
 Rename a Symbol within this Scope.
 
virtual void retypeSymbol (Symbol *sym, Datatype *ct)
 Change the data-type of a Symbol within this Scope. More...
 
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. More...
 
virtual void encode (Encoder &encoder) const
 Encode this as a <scope> element.
 
virtual void decode (Decoder &decoder)
 Decode this Scope from a <scope> element.
 
virtual void printEntries (ostream &s) const
 Dump a description of all SymbolEntry objects to a stream.
 
virtual int4 getCategorySize (int4 cat) const
 Get the number of Symbols in the given category. More...
 
virtual SymbolgetCategorySymbol (int4 cat, int4 ind) const
 Retrieve a Symbol by index within a specific category. More...
 
virtual void setCategory (Symbol *sym, int4 cat, int4 ind)
 Set the category and index for the given Symbol. More...
 
- Public Member Functions inherited from ghidra::Scope
 Scope (uint8 id, const string &nm, Architecture *g, Scope *own)
 Construct an empty scope, given a name and Architecture.
 
virtual ~Scope (void)
 Destructor.
 
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 decodeWrappingAttributes (Decoder &decoder)
 Restore attributes for this Scope from wrapping element.
 
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.
 

Private Member Functions

Symboldump2Cache (Decoder &decoder) const
 Parse a response into the cache. More...
 
SymbolremoveQuery (const Address &addr) const
 Process a query that missed the cache. More...
 
void decodeHole (Decoder &decoder) const
 Process a <hole> response element. More...
 
ScopereresolveScope (uint8 id) const
 Find the Scope that will contain a result Symbol. 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 ScopebuildSubScope (uint8 id, const string &nm)
 Build an unattached Scope to be associated as a sub-scope of this. More...
 
virtual void addSymbolInternal (Symbol *sym)
 Put a Symbol into the name map. More...
 
virtual SymbolEntryaddMapInternal (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. More...
 
virtual SymbolEntryaddDynamicMapInternal (Symbol *sym, uint4 exfl, uint8 hash, int4 off, int4 sz, const RangeList &uselim)
 Create a new SymbolEntry for a Symbol given a dynamic hash. More...
 

Private Attributes

ArchitectureGhidraghidra
 Architecture and connection to the Ghidra client.
 
ScopeInternalcache
 An internal cache of previously fetched Symbol objects.
 
RangeList holes
 List of (queried) memory ranges with no Symbol in them.
 
vector< int4 > spacerange
 List of address spaces that are in the global range.
 
partmap< Address, uint4 > flagbaseDefault
 Default boolean properties on memory.
 
bool cacheDirty
 Is flagbaseDefault different from cache.
 

Additional Inherited Members

- Protected Member Functions inherited from ghidra::Scope
const RangeListgetRangeTree (void) const
 Access the address ranges owned by this Scope.
 
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 inherited from ghidra::Scope
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 inherited from ghidra::Scope
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.
 

Detailed Description

An implementation of the Scope interface by querying a Ghidra client for Symbol information.

This object is generally instantiated once for an executable and acts as the global scope for the decompiler. Queries for symbol information are forwarded to the Ghidra client and the response is cached. This object fields queries for all scopes above functions. Responses may be for Symbol objects that are not global but belong to sub-scopes, like namespace and function Scopes. This object will build any new Scope or Funcdata, object as necessary and stick the Symbol in, returning as if the new Scope had caught the query in the first place.

Constructor & Destructor Documentation

◆ ScopeGhidra()

ghidra::ScopeGhidra::ScopeGhidra ( ArchitectureGhidra g)

Constructor.

Parameters
gis the Architecture and connection to the Ghidra client

References cache, and cacheDirty.

Referenced by addDynamicMapInternal().

Member Function Documentation

◆ addDynamicMapInternal()

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

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

Implements ghidra::Scope.

References ScopeGhidra().

◆ addMapInternal()

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

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

Implements ghidra::Scope.

◆ addRange()

void ghidra::ScopeGhidra::addRange ( AddrSpace spc,
uintb  first,
uintb  last 
)
privatevirtual

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 from ghidra::Scope.

References ghidra::Scope::addRange(), ghidra::AddrSpace::getIndex(), and spacerange.

◆ addSymbol()

SymbolEntry * ghidra::ScopeGhidra::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 from ghidra::Scope.

References ghidra::Scope::addSymbol(), and cache.

Referenced by lockDefaultProperties().

◆ addSymbolInternal()

virtual void ghidra::ScopeGhidra::addSymbolInternal ( Symbol sym)
inlineprivatevirtual

Put a Symbol into the name map.

Parameters
symis the preconstructed Symbol

Implements ghidra::Scope.

◆ adjustCaches()

virtual void ghidra::ScopeGhidra::adjustCaches ( void  )
inlinevirtual

Let scopes internally adjust any caches.

This is called once after Architecture configuration is complete.

Implements ghidra::Scope.

References ghidra::ScopeInternal::adjustCaches(), findAddr(), and findContainer().

◆ buildSubScope()

Scope * ghidra::ScopeGhidra::buildSubScope ( uint8  id,
const string &  nm 
)
privatevirtual

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

Implements ghidra::Scope.

Referenced by removeRange().

◆ buildUndefinedName()

virtual string ghidra::ScopeGhidra::buildUndefinedName ( void  ) const
inlinevirtual

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

Implements ghidra::Scope.

References ghidra::ScopeInternal::buildUndefinedName().

◆ buildVariableName()

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

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

Implements ghidra::Scope.

References ghidra::ScopeInternal::buildVariableName().

◆ decodeHole()

void ghidra::ScopeGhidra::decodeHole ( Decoder decoder) const
private

Process a <hole> response element.

The Ghidra client can respond to a query negatively by sending a <hole> element, which describes the (largest) range of addresses containing the query address that do not have any Symbol mapped to them. This object stores this information in the holes map, which it consults to avoid sending queries for the same unmapped address repeatedly. The tag may also contain boolean property information about the memory range, which also gets stored.

Parameters
decoderis the stream decoder

References cacheDirty, ghidra::Decoder::closeElement(), ghidra::Range::decodeFromAttributes(), ghidra::Range::getFirst(), ghidra::Range::getLast(), ghidra::Decoder::getNextAttributeId(), ghidra::Range::getSpace(), holes, ghidra::RangeList::insertRange(), ghidra::Decoder::openElement(), ghidra::Decoder::readBool(), ghidra::Varnode::readonly, ghidra::Decoder::rewindAttributes(), and ghidra::Varnode::volatil.

Referenced by dump2Cache().

◆ dump2Cache()

Symbol * ghidra::ScopeGhidra::dump2Cache ( Decoder decoder) const
private

◆ findAddr()

SymbolEntry * ghidra::ScopeGhidra::findAddr ( const Address addr,
const Address usepoint 
) const
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

Implements ghidra::Scope.

References cache, ghidra::ScopeInternal::findAddr(), ghidra::ScopeInternal::findContainer(), ghidra::SymbolEntry::getAddr(), ghidra::Symbol::getMapEntry(), and removeQuery().

Referenced by adjustCaches().

◆ findByName()

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

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

Implements ghidra::Scope.

◆ findClosestFit()

virtual SymbolEntry* ghidra::ScopeGhidra::findClosestFit ( const Address addr,
int4  size,
const Address usepoint 
) const
inlinevirtual

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

Implements ghidra::Scope.

References findCodeLabel(), findExternalRef(), findFunction(), and resolveExternalRefFunction().

◆ findCodeLabel()

LabSymbol * ghidra::ScopeGhidra::findCodeLabel ( const Address addr) const
virtual

Find a label Symbol at the given address.

Parameters
addris the given address
Returns
the matching LabSymbol or NULL

Implements ghidra::Scope.

References ghidra::Scope::addCodeLabel(), cache, ghidra::ScopeInternal::findAddr(), and ghidra::ScopeInternal::findCodeLabel().

Referenced by findClosestFit().

◆ findContainer()

SymbolEntry * ghidra::ScopeGhidra::findContainer ( const Address addr,
int4  size,
const Address usepoint 
) const
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

Implements ghidra::Scope.

References cache, ghidra::ScopeInternal::findClosestFit(), ghidra::SymbolEntry::getAddr(), ghidra::Symbol::getMapEntry(), ghidra::Address::getOffset(), ghidra::SymbolEntry::getSize(), and removeQuery().

Referenced by adjustCaches().

◆ findExternalRef()

ExternRefSymbol * ghidra::ScopeGhidra::findExternalRef ( const Address addr) const
virtual

Find an external reference at the given address.

Parameters
addris the given address
Returns
the matching ExternRefSymbol or NULL

Implements ghidra::Scope.

References cache, ghidra::ScopeInternal::findContainer(), ghidra::ScopeInternal::findExternalRef(), and removeQuery().

Referenced by findClosestFit().

◆ findFunction()

Funcdata * ghidra::ScopeGhidra::findFunction ( const Address addr) const
virtual

Find the function starting at the given address.

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

Implements ghidra::Scope.

References cache, ghidra::ScopeInternal::findContainer(), ghidra::ScopeInternal::findFunction(), ghidra::FunctionSymbol::getFunction(), and removeQuery().

Referenced by findClosestFit().

◆ findOverlap()

virtual SymbolEntry* ghidra::ScopeGhidra::findOverlap ( const Address addr,
int4  size 
) const
inlinevirtual

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

Implements ghidra::Scope.

◆ getCategorySize()

virtual int4 ghidra::ScopeGhidra::getCategorySize ( int4  cat) const
inlinevirtual

Get the number of Symbols in the given category.

Parameters
catis the Symbol category
Returns
the number in that category

Implements ghidra::Scope.

◆ getCategorySymbol()

virtual Symbol* ghidra::ScopeGhidra::getCategorySymbol ( int4  cat,
int4  ind 
) const
inlinevirtual

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

Implements ghidra::Scope.

◆ isNameUsed()

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

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)

Implements ghidra::Scope.

Referenced by ghidra::ScopeGhidraNamespace::ScopeGhidraNamespace().

◆ lockDefaultProperties()

void ghidra::ScopeGhidra::lockDefaultProperties ( void  )
inline

Lock in the default state of the boolean property map.

When this Scope gets created, parsing of .pspec and .cspec files may lay down property information about memory before any the load-image is consulted. This method locks creates a copy of this state of memory, so the decompiler can reset to it before decompiling a new function.

References addSymbol(), clear(), ghidra::Database::getProperties(), and ghidra::Architecture::symboltab.

Referenced by ghidra::ArchitectureGhidra::postSpecFile().

◆ makeNameUnique()

virtual string ghidra::ScopeGhidra::makeNameUnique ( const string &  nm) const
inlinevirtual

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

Implements ghidra::Scope.

◆ removeQuery()

Symbol * ghidra::ScopeGhidra::removeQuery ( const Address addr) const
private

Process a query that missed the cache.

Determine if the given address should be sent to the Ghidra client at all, by checking the hole map and other factors. If it passes, send the query to the client, process the result, and update the cache. If a Symbol is ultimately recovered, return it.

Parameters
addris the address to potentially query
Returns
the matching Symbol or NULL if there is hole

References dump2Cache(), ghidra::AddrSpace::getIndex(), ghidra::Address::getSpace(), holes, ghidra::RangeList::inRange(), and spacerange.

Referenced by findAddr(), findContainer(), findExternalRef(), and findFunction().

◆ removeRange()

virtual void ghidra::ScopeGhidra::removeRange ( AddrSpace spc,
uintb  first,
uintb  last 
)
inlineprivatevirtual

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 from ghidra::Scope.

References buildSubScope().

◆ reresolveScope()

Scope * ghidra::ScopeGhidra::reresolveScope ( uint8  id) const
private

Find the Scope that will contain a result Symbol.

The Ghidra client reports a namespace id associated with Symbol. Determine if a matching namespace Scope already exists in the cache and build it if it isn't. This may mean creating the namespace Scope and its ancestors.

Parameters
idis the ID associated with the Ghidra namespace
Returns
the Scope matching the id.

References cache, ghidra::Database::decodeScopePath(), and ghidra::Database::resolveScope().

Referenced by dump2Cache().

◆ resolveExternalRefFunction()

Funcdata * ghidra::ScopeGhidra::resolveExternalRefFunction ( ExternRefSymbol sym) const
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

Implements ghidra::Scope.

References cache, dump2Cache(), ghidra::ScopeInternal::findFunction(), ghidra::SymbolEntry::getAddr(), ghidra::Symbol::getFirstWholeMap(), ghidra::FunctionSymbol::getFunction(), ghidra::ExternRefSymbol::getRefAddr(), and ghidra::Scope::stackFunction().

Referenced by findClosestFit().

◆ restrictScope()

virtual void ghidra::ScopeGhidra::restrictScope ( Funcdata f)
inlinevirtual

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 from ghidra::Scope.

◆ retypeSymbol()

virtual void ghidra::ScopeGhidra::retypeSymbol ( Symbol sym,
Datatype ct 
)
inlinevirtual

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

Implements ghidra::Scope.

◆ setCategory()

virtual void ghidra::ScopeGhidra::setCategory ( Symbol sym,
int4  cat,
int4  ind 
)
inlinevirtual

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)

Implements ghidra::Scope.


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