Package ghidra.program.model.symbol
Interface Symbol
- All Known Subinterfaces:
TraceClassSymbol,TraceLabelSymbol,TraceNamespaceSymbol,TraceSymbol,TraceSymbolWithLifespan
- All Known Implementing Classes:
AbstractDBTraceSymbol,ClassSymbol,CodeSymbol,DBTraceClassSymbol,DBTraceLabelSymbol,DBTraceNamespaceSymbol,FunctionSymbol,GlobalSymbol,GlobalVariableSymbolDB,LibrarySymbol,MemorySymbol,NamespaceSymbol,SymbolDB,VariableSymbolDB
public interface Symbol
Interface for a symbol, which associates a string value with
an address.
-
Method Summary
Modifier and TypeMethodDescriptionbooleandelete()Delete the symbol and its associated resources.longgetID()getName()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 symboldefault ProgramLocationReturns a program location for this symbol; may be null.default intGet the number of References to this symbol or its address.default Reference[]Returns all memory references to the address of this symbol.default Reference[]getReferences(TaskMonitor monitor) Returns all memory references to the address of this symbol.Gets the source of this symbol.Returns this symbol's typedefault booleanbooleanDetermine if this symbol object has been deleted.booleanisDescendant(Namespace namespace) Returns true if the given namespace symbol is a descendant of this symbol.booleanbooleanReturns true if this an external symbol.default booleanbooleanisGlobal()default booleanisPinned()Returns true if the symbol is pinned to its current address.booleanbooleanisValidParent(Namespace parent) Determines if the given parent is valid for this Symbol.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 namespacedefault voidsetPinned(boolean pinned) Sets whether or not this symbol is pinned to its associated address.booleanSets this symbol to be primary.voidsetSource(SourceType source) Sets the source of this symbol.
-
Method Details
-
getAddress
Address getAddress()- Returns:
- the address for the symbol.
-
getName
String getName()- Returns:
- the name of this symbol.
-
getPath
String[] getPath()Gets the full path name for this symbol as an ordered array of strings ending with the symbol name.- Returns:
- the array indicating the full path name for this symbol.
-
getProgram
Program getProgram()Get the program associated with this symbol- Returns:
- the program associated with this symbol.
-
getName
Returns the symbol name, optionally prepended with the namespace path.- Parameters:
includeNamespace- if true, the namespace path is prepended to the name.- Returns:
- formatted name
-
getParentNamespace
Namespace getParentNamespace()Return the parent namespace for this symbol.- Returns:
- the namespace that contains this symbol.
-
getParentSymbol
Symbol getParentSymbol()Returns namespace symbol of the namespace containing this symbol- Returns:
- parent namespace symbol
-
isDescendant
Returns true if the given namespace symbol is a descendant of this symbol.- Parameters:
namespace- to test as descendant symbol of this Symbol- Returns:
- true if this symbol is an ancestor of the given namespace symbol
-
isValidParent
Determines if the given parent is valid for this Symbol. Specified namespace must belong to the same symbol table as this symbol.- Parameters:
parent- prospective parent namespace for this symbol- Returns:
- true if parent is valid
-
getSymbolType
SymbolType getSymbolType()Returns this symbol's type- Returns:
- symbol type
-
getReferenceCount
default int getReferenceCount()Get the number of References to this symbol or its address.NOTE: this method differ from
hasReferences()behavior for memory symbols since this method will returnReferenceManager.getReferenceCountTo(Address)if this is the only symbol at its address.- Returns:
- the number of References to this symbol or its address.
-
hasReferences
default boolean hasReferences()- Returns:
- true if this symbol has at least one reference to it.
Explicit references to other symbols at the same address are not considered
(see
Reference.getSymbolID()which indicates a specific symbol reference).
-
getReferences
Returns all memory references to the address of this symbol. If you do not have aTaskMonitorinstance, then you can passTaskMonitor.DUMMYornull.- Parameters:
monitor- the monitor that is used to report progress and to cancel this potentially long-running call- Returns:
- all memory references to the address of this symbol.
-
getReferences
Returns all memory references to the address of this symbol.- Returns:
- all memory references to the address of this symbol
- See Also:
-
getProgramLocation
Returns a program location for this symbol; may be null. This allows implementations to return a more specific program location than what is typically used by the system.- Returns:
- the location
-
setName
void setName(String newName, SourceType source) throws DuplicateNameException, InvalidInputException Sets the name this symbol. If this symbol is dynamic, then the name is set and the symbol is no longer dynamic.- 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)).IllegalArgumentException- if you try to set the source to DEFAULT for a symbol type that doesn't allow it.
-
setNamespace
void setNamespace(Namespace newNamespace) throws DuplicateNameException, InvalidInputException, CircularDependencyException Sets the symbols namespace- 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
-
setNameAndNamespace
void setNameAndNamespace(String newName, Namespace newNamespace, SourceType source) throws DuplicateNameException, InvalidInputException, CircularDependencyException Sets the symbols name and namespace. This is provided to allow the caller to avoid a name conflict by creating an autonomous action.- 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
-
delete
boolean delete()Delete the symbol and its associated resources. Any references symbol associations will be discarded.- Returns:
- true if successful
-
isPinned
default boolean isPinned()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.- Returns:
- true if the symbol is pinned to its current address.
-
setPinned
default void setPinned(boolean pinned) 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.
- Parameters:
pinned- true indicates this symbol is anchored to its address. false indicates this symbol is not anchored to its address.
-
isDynamic
boolean isDynamic()- Returns:
- true if this symbol is a dynamic symbol (not actually defined in the database).
-
isExternal
boolean isExternal()Returns true if this an external symbol.- Returns:
- true if this an external symbol.
- See Also:
-
isPrimary
boolean isPrimary()- Returns:
- true if this symbol is primary
-
setPrimary
boolean setPrimary()Sets this symbol to be primary. All other symbols at the same address will be set to !primary. Only applies to non-function symbols.- Returns:
- returns true if the symbol was not primary and now it is, otherwise false
-
isExternalEntryPoint
default boolean isExternalEntryPoint()- Returns:
- true if the symbol is at an address set as a external entry point.
-
getID
long getID()- Returns:
- this symbol's ID.
-
getObject
Object getObject()- Returns:
- object associated with this symbol or null if symbol has been deleted
-
isGlobal
boolean isGlobal()- Returns:
- true if the symbol is contained within the global namespace
-
setSource
Sets the source of this symbol.SourceType- Parameters:
source- the new source of this symbol
-
getSource
SourceType getSource()Gets the source of this symbol.SourceType- Returns:
- the source of this symbol
-
isDeleted
boolean isDeleted()Determine if this symbol object has been deleted. NOTE: the symbol could be deleted at anytime due to asynchronous activity.- Returns:
- true if symbol has been deleted, false if not.
-