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
,CodeSymbol
,FunctionSymbol
,GlobalRegisterSymbol
,LibrarySymbol
,NamespaceSymbol
,VariableSymbolDB
public abstract class SymbolDB extends DatabaseObject implements Symbol
Base class for symbols
-
-
Field Summary
Fields Modifier and Type Field Description protected Address
address
protected Lock
lock
protected SymbolManager
symbolMgr
-
Fields inherited from class ghidra.program.database.DatabaseObject
key
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
delete()
Delete the symbol and its associated resources.protected boolean
doIsPinned()
protected void
doSetPinned(boolean pinned)
boolean
equals(java.lang.Object obj)
Address
getAddress()
long
getID()
java.lang.String
getName()
java.lang.String
getName(boolean includeNamespace)
Returns the symbol name, optionally prepended with the namespace path.Namespace
getParentNamespace()
Symbol
getParentSymbol()
Returns namespace symbol of the namespace containing this symboljava.lang.String[]
getPath()
Gets the full path name for this symbol as an ordered array of strings ending with the symbol name.Program
getProgram()
int
getReferenceCount()
Reference[]
getReferences()
Returns all memory references to the address of this symbol.Reference[]
getReferences(TaskMonitor monitor)
Returns all memory references to the address of this symbol.SourceType
getSource()
Gets the source of this symbol.long
getSymbolData1()
int
getSymbolData2()
gets the generic symbol data 2 data.java.lang.String
getSymbolData3()
protected java.util.List<SymbolDB>
getSymbolsDynamicallyRenamedByMyRename()
int
hashCode()
boolean
hasMultipleReferences()
boolean
hasReferences()
boolean
isDeleting()
boolean
isDescendant(Namespace namespace)
Returns true if the given namespace symbol is a descendant of this symbol.boolean
isDynamic()
boolean
isExternalEntryPoint()
boolean
isGlobal()
boolean
isPinned()
Returns true if the symbol is pinned to its current address.abstract boolean
isPrimary()
abstract boolean
isValidParent(Namespace parent)
Returns whether the given parent is valid for this Symbol.protected void
move(Address oldBase, Address newBase)
protected boolean
refresh()
Tells the object to refresh its state from the database.protected boolean
refresh(Record rec)
Tells the object to refresh its state from the database using the specified record if not null.protected void
removeAllReferencesTo()
protected void
setAddress(Address addr)
void
setName(java.lang.String newName, SourceType source)
Sets the name this symbol.void
setNameAndNamespace(java.lang.String newName, Namespace newNamespace, SourceType source)
Sets the symbols name and namespace.void
setNamespace(Namespace newNamespace)
Sets the symbols namespacevoid
setPinned(boolean pinned)
Sets whether or not this symbol is pinned to its associated address.boolean
setPrimary()
Sets this symbol to be primary.void
setSource(SourceType newSource)
Sets this symbol's source as specified.void
setSymbolData1(long value)
Sets the generic symbol data 1.void
setSymbolData2(int value)
Sets the generic symbol data 2 datavoid
setSymbolData3(java.lang.String data3)
java.lang.String
toString()
protected SourceType
validateNameSource(java.lang.String newName, SourceType source)
Allow symbol implementations to validate the source when setting the name of this symbol.-
Methods inherited from class ghidra.program.database.DatabaseObject
checkDeleted, checkIsValid, checkIsValid, getKey, isDeleted, isInvalid, keyChanged, setInvalid, validate
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ghidra.program.model.symbol.Symbol
checkIsValid, getObject, getProgramLocation, getSymbolType, isExternal
-
-
-
-
Field Detail
-
address
protected Address address
-
symbolMgr
protected SymbolManager symbolMgr
-
lock
protected Lock lock
-
-
Method Detail
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
refresh
protected boolean refresh()
Description copied from class:DatabaseObject
Tells the object to refresh its state from the database.- Specified by:
refresh
in 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
protected boolean refresh(Record rec)
Description copied from class:DatabaseObject
Tells 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:
refresh
in 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
public Address getAddress()
- Specified by:
getAddress
in interfaceSymbol
-
setAddress
protected void setAddress(Address addr)
-
getProgram
public Program getProgram()
- Specified by:
getProgram
in interfaceSymbol
-
getName
public java.lang.String getName(boolean includeNamespace)
Description copied from interface:Symbol
Returns the symbol name, optionally prepended with the namespace path.
-
getPath
public java.lang.String[] getPath()
Description copied from interface:Symbol
Gets the full path name for this symbol as an ordered array of strings ending with the symbol name. The global symbol will return an empty array.
-
getReferenceCount
public int getReferenceCount()
- Specified by:
getReferenceCount
in interfaceSymbol
-
getReferences
public Reference[] getReferences(TaskMonitor monitor)
Description copied from interface:Symbol
Returns all memory references to the address of this symbol. If you do not have aTaskMonitor
instance, then you can passTaskMonitorAdapter.DUMMY_MONITOR
or null.- Specified by:
getReferences
in interfaceSymbol
- Parameters:
monitor
- the monitor that is used to report progress and to cancel this potentially long-running call
-
getReferences
public Reference[] getReferences()
Description copied from interface:Symbol
Returns all memory references to the address of this symbol.- Specified by:
getReferences
in interfaceSymbol
- See Also:
Symbol.getReferences(TaskMonitor)
-
hasMultipleReferences
public boolean hasMultipleReferences()
- Specified by:
hasMultipleReferences
in interfaceSymbol
-
hasReferences
public boolean hasReferences()
- Specified by:
hasReferences
in interfaceSymbol
-
isExternalEntryPoint
public boolean isExternalEntryPoint()
- Specified by:
isExternalEntryPoint
in interfaceSymbol
-
setSource
public void setSource(SourceType newSource)
Sets this symbol's source as specified.
-
getSource
public SourceType getSource()
Description copied from interface:Symbol
Gets the source of this symbol.SourceTypes
-
isPinned
public boolean isPinned()
Description copied from interface:Symbol
Returns true if the symbol is pinned to its current address. If it is pinned, then moving or removing the memory associated with that address will not affect this symbol.
-
doIsPinned
protected boolean doIsPinned()
-
setPinned
public void setPinned(boolean pinned)
Description copied from interface:Symbol
Sets whether or not this symbol is pinned to its associated address.
If the symbol is pinned then moving or removing the memory associated with its address will not cause this symbol to be removed and will not cause its address to change. If the symbol is not pinned, then removing the memory at its address will also remove this symbol.
Likewise, moving a memory block containing a symbol that is not anchored will change the address for that symbol to keep it associated with the same byte in the memory block.
-
doSetPinned
protected void doSetPinned(boolean pinned)
-
setName
public void setName(java.lang.String newName, SourceType source) throws DuplicateNameException, InvalidInputException
Description copied from interface:Symbol
Sets the name this symbol. If this symbol is dynamic, then the name is set and the symbol is no longer dynamic.- Specified by:
setName
in 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 already exists as the name of another symbol or alias.InvalidInputException
- if alias contains blank characters, is zero length, or is null
-
setNamespace
public void setNamespace(Namespace newNamespace) throws DuplicateNameException, InvalidInputException, CircularDependencyException
Description copied from interface:Symbol
Sets the symbols namespace- Specified by:
setNamespace
in 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
protected SourceType validateNameSource(java.lang.String newName, SourceType source)
Allow symbol implementations to validate the source when setting the name of this symbol.
-
setNameAndNamespace
public void setNameAndNamespace(java.lang.String newName, Namespace newNamespace, SourceType source) throws DuplicateNameException, InvalidInputException, CircularDependencyException
Description copied from interface:Symbol
Sets the symbols name and namespace. This is provided to allow the caller to avoid a name conflict by creating an autonomous action.- Specified by:
setNameAndNamespace
in 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
protected java.util.List<SymbolDB> getSymbolsDynamicallyRenamedByMyRename()
-
setPrimary
public boolean setPrimary()
Description copied from interface:Symbol
Sets 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:
setPrimary
in interfaceSymbol
- Returns:
- returns true if the symbol was not primary and now it is, otherwise false
- See Also:
Symbol.setPrimary()
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
getParentNamespace
public Namespace getParentNamespace()
- Specified by:
getParentNamespace
in interfaceSymbol
-
getParentSymbol
public Symbol getParentSymbol()
Description copied from interface:Symbol
Returns namespace symbol of the namespace containing this symbol- Specified by:
getParentSymbol
in interfaceSymbol
-
getSymbolData3
public java.lang.String getSymbolData3()
-
setSymbolData3
public void setSymbolData3(java.lang.String data3)
-
removeAllReferencesTo
protected void removeAllReferencesTo()
-
getSymbolData1
public long getSymbolData1()
-
setSymbolData1
public void setSymbolData1(long value)
Sets the generic symbol data 1.- Parameters:
value
- the value to set as symbol data 1.
-
getSymbolData2
public int getSymbolData2()
gets the generic symbol data 2 data.
-
setSymbolData2
public void setSymbolData2(int value)
Sets the generic symbol data 2 data- Parameters:
value
- the value to set as the symbols data 2 value.
-
delete
public boolean delete()
Description copied from interface:Symbol
Delete the symbol and its associated resources.
-
isDeleting
public boolean isDeleting()
-
isDescendant
public boolean isDescendant(Namespace namespace)
Description copied from interface:Symbol
Returns true if the given namespace symbol is a descendant of this symbol.- Specified by:
isDescendant
in 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
public abstract boolean isValidParent(Namespace parent)
Description copied from interface:Symbol
Returns whether the given parent is valid for this Symbol.- Specified by:
isValidParent
in interfaceSymbol
-
-