Package ghidra.program.database.symbol
Class SymbolDB
java.lang.Object
ghidra.program.database.DatabaseObject
ghidra.program.database.symbol.SymbolDB
- All Implemented Interfaces:
Symbol
- Direct Known Subclasses:
ClassSymbol,LibrarySymbol,MemorySymbol,NamespaceSymbol,VariableSymbolDB
Base class for symbols
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Addressprotected Lockprotected DBRecordprotected SymbolManagerFields inherited from class ghidra.program.database.DatabaseObject
key -
Method Summary
Modifier and TypeMethodDescriptionprotected voidChecks if this object has been deleted, in which case any use of the object is not allowed.booleandelete()Delete the symbol and its associated resources.protected booleanprotected StringThe code for creating the name content for this symbol.protected NamespacevoiddoSetNameAndNamespace(String newName, Namespace newNamespace, SourceType source, boolean checkForDuplicates) protected voiddoSetPrimary(boolean primary) booleanlonglonggetID()final StringgetName()getName(boolean includeNamespace) Returns the symbol name, optionally prepended with the namespace path.Return the parent namespace for this symbol.Returns namespace symbol of the namespace containing this symbolString[]getPath()Gets the full path name for this symbol as an ordered array of strings ending with the symbol name.Get the program associated with this symbolGets the source of this symbol.inthashCode()booleanDetermine if this symbol object has been deleted.booleanbooleanisDescendant(Namespace namespace) Returns true if the given namespace symbol is a descendant of this symbol.booleanbooleanisGlobal()abstract booleanbooleanisValidParent(Namespace parent) Determines if the given parent is valid for this Symbol.protected booleanrefresh()Tells the object to refresh its state from the database.protected booleanTells the object to refresh its state from the database using the specified record if not null.protected voidsetAddress(Address addr) voidsetDataTypeId(long value) Sets the generic symbol data 1.voidsetName(String newName, SourceType source) Sets the name this symbol.voidsetNameAndNamespace(String newName, Namespace newNamespace, SourceType source) Sets the symbols name and namespace.voidsetNamespace(Namespace newNamespace) Sets the symbols namespacebooleanSets this symbol to be primary.voidsetSource(SourceType newSource) Sets this symbol's source as specified.protected voidsetSourceFlagBits(SourceType newSource) toString()protected voidprotected SourceTypevalidateNameSource(String newName, SourceType source) Allow symbol implementations to validate the source when setting the name of this symbolMethods inherited from class ghidra.program.database.DatabaseObject
checkIsValid, checkIsValid, getKey, isDeleted, isInvalid, keyChanged, setDeleted, setInvalid, validateMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface ghidra.program.model.symbol.Symbol
getObject, getProgramLocation, getReferenceCount, getReferences, getReferences, getSymbolType, hasReferences, isExternal, isExternalEntryPoint, isPinned, setPinned
-
Field Details
-
record
-
address
-
symbolMgr
-
lock
-
-
Method Details
-
isDeleted
public boolean isDeleted()Description copied from interface:SymbolDetermine if this symbol object has been deleted. NOTE: the symbol could be deleted at anytime due to asynchronous activity. -
checkDeleted
protected void checkDeleted()Description copied from class:DatabaseObjectChecks if this object has been deleted, in which case any use of the object is not allowed. This method should be invoked before any modifications to the object are performed to ensure it still exists and is in a valid state.- Overrides:
checkDeletedin classDatabaseObject
-
toString
-
refresh
protected boolean refresh()Description copied from class:DatabaseObjectTells the object to refresh its state from the database.- Specified by:
refreshin classDatabaseObject- Returns:
- true if the object was able to refresh itself. Return false if the object was deleted. Objects that extend this class must implement a refresh method. If an object can never refresh itself, then it should always return false.
-
refresh
Description copied from class:DatabaseObjectTells the object to refresh its state from the database using the specified record if not null. NOTE: The default implementation ignores the record and invokes refresh(). Implementations of this method must take care if multiple database tables are used since the record supplied could correspond to another object. In some cases it may be best not to override this method or ignore the record provided.- Overrides:
refreshin classDatabaseObject- Parameters:
rec- valid record associated with object's key (optional, may be null to force record lookup or other refresh technique)- Returns:
- true if the object was able to refresh itself. Return false if record is null and object was deleted. Objects that extend this class must implement a refresh method. If an object can never refresh itself, then it should always return false.
-
getAddress
- Specified by:
getAddressin interfaceSymbol- Returns:
- the address for the symbol.
-
setAddress
-
getName
-
doGetName
The code for creating the name content for this symbol. This code will be called with the symbol's lock.- Returns:
- the name
-
getProgram
Description copied from interface:SymbolGet the program associated with this symbol- Specified by:
getProgramin interfaceSymbol- Returns:
- the program associated with this symbol.
-
getName
Description copied from interface:SymbolReturns the symbol name, optionally prepended with the namespace path. -
getPath
Description copied from interface:SymbolGets the full path name for this symbol as an ordered array of strings ending with the symbol name. -
isDynamic
public boolean isDynamic() -
isPrimary
public abstract boolean isPrimary() -
setSource
Sets this symbol's source as specified.- Specified by:
setSourcein interfaceSymbol- Parameters:
newSource- the new source type (IMPORTED, ANALYSIS, USER_DEFINED)- Throws:
IllegalArgumentException- if you try to change the source from default or to default
-
setSourceFlagBits
-
getSource
Description copied from interface:SymbolGets the source of this symbol.SourceType -
setName
public void setName(String newName, SourceType source) throws DuplicateNameException, InvalidInputException Description copied from interface:SymbolSets the name this symbol. If this symbol is dynamic, then the name is set and the symbol is no longer dynamic.- Specified by:
setNamein interfaceSymbol- Parameters:
newName- the new name for this symbol.source- the source of this symbol
Some symbol types, such as function symbols, can set the source to Symbol.DEFAULT.- Throws:
DuplicateNameException- if name conflicts with another symbol.InvalidInputException- if an invalid or null name specified (seeSymbolUtilities.validateName(java.lang.String)).
-
setNamespace
public void setNamespace(Namespace newNamespace) throws DuplicateNameException, InvalidInputException, CircularDependencyException Description copied from interface:SymbolSets the symbols namespace- Specified by:
setNamespacein interfaceSymbol- Parameters:
newNamespace- new parent namespace- Throws:
DuplicateNameException- if newNamespace already contains a symbol with this symbol's nameInvalidInputException- is newNamespace is not a valid parent for this symbolCircularDependencyException- if this symbol is an ancestor of newNamespace
-
validateNameSource
Allow symbol implementations to validate the source when setting the name of this symbol- Parameters:
newName- the new namesource- the source type- Returns:
- the validated source type
-
doSetNameAndNamespace
public void doSetNameAndNamespace(String newName, Namespace newNamespace, SourceType source, boolean checkForDuplicates) throws DuplicateNameException, InvalidInputException, CircularDependencyException -
setNameAndNamespace
public void setNameAndNamespace(String newName, Namespace newNamespace, SourceType source) throws DuplicateNameException, InvalidInputException, CircularDependencyException Description copied from interface:SymbolSets the symbols name and namespace. This is provided to allow the caller to avoid a name conflict by creating an autonomous action.- Specified by:
setNameAndNamespacein interfaceSymbol- Parameters:
newName- new symbol namenewNamespace- new parent namespacesource- the source of this symbol
Some symbol types, such as function symbols, can set the source to Symbol.DEFAULT.- Throws:
DuplicateNameException- if newNamespace already contains a symbol with this symbol's nameInvalidInputException- is newNamespace is not a valid parent for this symbolCircularDependencyException- if this symbol is an ancestor of newNamespace
-
getSymbolsDynamicallyRenamedByMyRename
-
setPrimary
public boolean setPrimary()Description copied from interface:SymbolSets this symbol to be primary. All other symbols at the same address will be set to !primary. Only applies to non-function symbols.- Specified by:
setPrimaryin interfaceSymbol- Returns:
- returns true if the symbol was not primary and now it is, otherwise false
- See Also:
-
getID
public long getID() -
equals
-
hashCode
public int hashCode() -
updateRecord
protected void updateRecord() -
getParentNamespace
Description copied from interface:SymbolReturn the parent namespace for this symbol.- Specified by:
getParentNamespacein interfaceSymbol- Returns:
- the namespace that contains this symbol.
-
doGetParentNamespace
-
getParentSymbol
Description copied from interface:SymbolReturns namespace symbol of the namespace containing this symbol- Specified by:
getParentSymbolin interfaceSymbol- Returns:
- parent namespace symbol
-
isGlobal
public boolean isGlobal() -
getDataTypeId
public long getDataTypeId() -
setDataTypeId
public void setDataTypeId(long value) Sets the generic symbol data 1.- Parameters:
value- the value to set as symbol data 1.
-
doSetPrimary
protected void doSetPrimary(boolean primary) -
doCheckIsPrimary
protected boolean doCheckIsPrimary() -
delete
public boolean delete()Description copied from interface:SymbolDelete the symbol and its associated resources. Any references symbol associations will be discarded. -
isDeleting
public boolean isDeleting() -
isDescendant
Description copied from interface:SymbolReturns true if the given namespace symbol is a descendant of this symbol.- Specified by:
isDescendantin interfaceSymbol- Parameters:
namespace- to test as descendant symbol of this Symbol- Returns:
- true if this symbol is an ancestor of the given namespace symbol
-
isValidParent
Description copied from interface:SymbolDetermines if the given parent is valid for this Symbol. Specified namespace must belong to the same symbol table as this symbol.- Specified by:
isValidParentin interfaceSymbol- Parameters:
parent- prospective parent namespace for this symbol- Returns:
- true if parent is valid
-