Class AbstractDBTraceSymbol
- All Implemented Interfaces:
Symbol,DBTraceOverlaySpaceAdapter.DecodesAddresses,TraceSymbol
- Direct Known Subclasses:
DBTraceLabelSymbol,DBTraceNamespaceSymbol
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final DBTraceSymbolManagerprotected DBTraceNamespaceSymbolFields inherited from class ghidra.program.database.DatabaseObject
key -
Constructor Summary
ConstructorsConstructorDescriptionAbstractDBTraceSymbol(DBTraceSymbolManager manager, DBCachedObjectStore<?> store, DBRecord record) -
Method Summary
Modifier and TypeMethodDescriptionprotected DBTraceNamespaceSymbolprotected voidprotected DBTraceNamespaceSymbolcheckCircular(DBTraceNamespaceSymbol newParent) booleandelete()Delete the symbol and its associated resources.protected voidprotected booleandoDelete()protected TraceChangeRecord<?, ?> doSetNameWithEvent(String newName) protected TraceChangeRecord<?, ?> doSetParent(DBTraceNamespaceSymbol newParent) Checks and sets the parent The caller must still callDBAnnotatedObject.update(DBObjectColumn...)forPARENT_COLUMN.protected voiddoSetSource(SourceType newSource) protected TraceChangeRecord<?, ?> doSetSourceWithEvent(SourceType newSource) Sets the flags for the given source.booleanprotected voidfresh(boolean created) Extension point: Called when the object's fields are populated.protected AddressSpacelonggetID()getName()getName(boolean includeNamespace) Returns the symbol name, optionally prepended with the namespace path.Get the space adapter for the trace containing the objectReturn 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 symbolReturns a program location for this symbol; may be null.protected Iterable<? extends TraceAddressSnapRange> Collection<? extends DBTraceReference> Get all memory references to the address of this symbol.intGet the number of References to this symbol or its address.Returns all memory references to the address of this symbol.getReferences(TaskMonitor monitor) Returns all memory references to the address of this symbol.Gets the source of this symbol.If in register space, get the thread associated with this symbol.getTrace()Get the trace to which this symbol belongs.inthashCode()booleanbooleanisDescendant(Namespace namespace) Returns true if the given namespace symbol is a descendant of this symbol.booleanbooleanReturns true if this an external symbol.booleanisGlobal()booleanisPinned()Returns true if the symbol is pinned to its current address.booleanDetermines if the given parent is valid for this Symbol.protected voidset(String name, DBTraceNamespaceSymbol parent, SourceType source) voidsetName(String newName, SourceType newSource) Sets the name this symbol.voidsetNameAndNamespace(String newName, Namespace newNamespace, SourceType newSource) Sets the symbols name and namespace.voidsetNamespace(Namespace newNamespace) Sets the symbols namespacevoidsetPinned(boolean pinned) Sets whether or not this symbol is pinned to its associated address.voidsetSource(SourceType newSource) Sets the source of this symbol.toString()protected voidvalidateNameAndParent(String newName, DBTraceNamespaceSymbol newParent) protected org.apache.commons.lang3.tuple.Pair<String, SourceType> validateNameAndSource(String newName, SourceType newSource) Methods inherited from class ghidra.util.database.DBAnnotatedObject
doRefresh, doUpdateAll, doUpdated, doWrite, getObjectKey, getTableName, isDeleted, refresh, refresh, update, update, update, updateMethods inherited from class ghidra.program.database.DatabaseObject
checkDeleted, 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, getSymbolType, isDeleted, isExternalEntryPoint, isPrimary, setPrimary
-
Field Details
-
parent
-
manager
-
-
Constructor Details
-
AbstractDBTraceSymbol
public AbstractDBTraceSymbol(DBTraceSymbolManager manager, DBCachedObjectStore<?> store, DBRecord record)
-
-
Method Details
-
equals
NOTE: If the IDs match, then the symbols are considered equal, regardless of their other attributes. This mechanic seems required to support the whole "placeholder" idea. TODO: The "placeholder" thing may no longer be applicable.
-
hashCode
public int hashCode() -
toString
-
assertNotGlobal
protected void assertNotGlobal() -
assertIsNamespace
-
fresh
Description copied from class:DBAnnotatedObjectExtension point: Called when the object's fields are populated.This provides an opportunity for the object to initialize any non-database-backed fields that depend on the database-backed fields. Note that its use may indicate a situation better solved by a custom
DBCachedObjectStoreFactory.DBFieldCodec. If both the database-backed and non-database-backed fields are used frequently, then a codec may not be indicated. If the database-backed fields are only used in this method or to encode another frequently-used field, then a codec is likely better.For a new object, the database-backed fields remain at their initial values. They will be saved after this method returns, so they may be further initialized with custom logic.
For an object loaded from the database, the database-backed fields are already populated from the record when this method is called. They are not automatically saved after this method returns. This method should not further initialize database-backed fields in this case.
- Overrides:
freshin classDBAnnotatedObject- Parameters:
created-truewhen object is being created, orfalsewhen it is being loaded.- Throws:
IOException- if further initialization fails.
-
getOverlaySpaceAdapter
Description copied from interface:DBTraceOverlaySpaceAdapter.DecodesAddressesGet the space adapter for the trace containing the object- Specified by:
getOverlaySpaceAdapterin interfaceDBTraceOverlaySpaceAdapter.DecodesAddresses- Returns:
- the adapter
-
getTrace
Description copied from interface:TraceSymbolGet the trace to which this symbol belongs.- Specified by:
getTracein interfaceTraceSymbol- Returns:
- the trace
-
getThread
Description copied from interface:TraceSymbolIf in register space, get the thread associated with this symbol.- Specified by:
getThreadin interfaceTraceSymbol- Returns:
- the thread
-
getAddressSpace
-
getID
public long getID() -
getName
-
getAddress
- Specified by:
getAddressin interfaceSymbol- Returns:
- the address for the symbol.
-
getRanges
-
getLifespan
-
doCollectAddressSet
-
getAddressSet
-
getPath
Description copied from interface:SymbolGets the full path name for this symbol as an ordered array of strings ending with the symbol name. -
getName
Description copied from interface:SymbolReturns the symbol name, optionally prepended with the namespace path. -
getParentNamespace
Description copied from interface:SymbolReturn the parent namespace for this symbol.- Specified by:
getParentNamespacein interfaceSymbol- Specified by:
getParentNamespacein interfaceTraceSymbol- Returns:
- the namespace that contains this symbol.
-
getParentSymbol
Description copied from interface:SymbolReturns namespace symbol of the namespace containing this symbol- Specified by:
getParentSymbolin interfaceSymbol- Specified by:
getParentSymbolin interfaceTraceSymbol- Returns:
- parent namespace symbol
-
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
-
getReferenceCollection
Description copied from interface:TraceSymbolGet all memory references to the address of this symbol.- Specified by:
getReferenceCollectionin interfaceTraceSymbol- Returns:
- the references
-
getReferenceCount
public int getReferenceCount()Description copied from interface:SymbolGet the number of References to this symbol or its address.NOTE: this method differ from
Symbol.hasReferences()behavior for memory symbols since this method will returnReferenceManager.getReferenceCountTo(Address)if this is the only symbol at its address.- Specified by:
getReferenceCountin interfaceSymbol- Returns:
- the number of References to this symbol or its address.
-
hasReferences
public boolean hasReferences()- Specified by:
hasReferencesin interfaceSymbol- 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
Description copied from interface:TraceSymbolReturns all memory references to the address of this symbol. If you do not have aTaskMonitorinstance, then you can passTaskMonitor.DUMMYornull. For traces,TraceSymbol.getReferenceCollection()is preferred, as it will retrieve the references lazily.- Specified by:
getReferencesin interfaceSymbol- Specified by:
getReferencesin interfaceTraceSymbol- 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
Description copied from interface:TraceSymbolReturns all memory references to the address of this symbol. For traces,TraceSymbol.getReferenceCollection()is preferred, as it will retrieve the references lazily.- Specified by:
getReferencesin interfaceSymbol- Specified by:
getReferencesin interfaceTraceSymbol- Returns:
- all memory references to the address of this symbol
- See Also:
-
set
-
doSetNameWithEvent
- Throws:
InvalidInputException
-
doSetParent
protected TraceChangeRecord<?,?> doSetParent(DBTraceNamespaceSymbol newParent) throws CircularDependencyException Checks and sets the parent The caller must still callDBAnnotatedObject.update(DBObjectColumn...)forPARENT_COLUMN.- Parameters:
newParent- the parent namespace- Throws:
CircularDependencyException
-
doSetSource
-
doSetSourceWithEvent
Sets the flags for the given source. The caller must still callDBAnnotatedObject.update(DBObjectColumn...)forFLAGS_COLUMN. The update should be called before the returned event, if applicable, is fired.- Parameters:
newSource- the source type- Returns:
- the appropriate change event, if a change was actually made
-
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:
ns- prospective parent namespace for this symbol- Returns:
- true if parent is valid
-
checkCircular
protected DBTraceNamespaceSymbol checkCircular(DBTraceNamespaceSymbol newParent) throws CircularDependencyException - Throws:
CircularDependencyException
-
validateNameAndSource
protected org.apache.commons.lang3.tuple.Pair<String,SourceType> validateNameAndSource(String newName, SourceType newSource) throws InvalidInputException - Throws:
InvalidInputException
-
setName
public void setName(String newName, SourceType newSource) 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.newSource- 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)).
-
validateNameAndParent
protected void validateNameAndParent(String newName, DBTraceNamespaceSymbol newParent) throws DuplicateNameException - Throws:
DuplicateNameException
-
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
-
setNameAndNamespace
public void setNameAndNamespace(String newName, Namespace newNamespace, SourceType newSource) 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 namespacenewSource- 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
-
setSource
Description copied from interface:SymbolSets the source of this symbol.SourceType -
getSource
Description copied from interface:SymbolGets the source of this symbol.SourceType -
delete
public boolean delete()Description copied from interface:SymbolDelete the symbol and its associated resources. Any references symbol associations will be discarded. -
doDelete
protected boolean doDelete() -
isDynamic
public boolean isDynamic() -
isGlobal
public boolean isGlobal() -
getProgram
Description copied from interface:SymbolGet the program associated with this symbol- Specified by:
getProgramin interfaceSymbol- Returns:
- the program associated with this symbol.
-
getProgramLocation
Description copied from interface:SymbolReturns 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.- Specified by:
getProgramLocationin interfaceSymbol- Returns:
- the location
-
isPinned
public 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. Traces do not support moving memory, so pinning is meaningless and unsupported. Since blocks cannot be relocated as they can in aProgram, it's tempting to say all symbols are pinned; however, this presents in the UI and is a bit confusing and/or distracting.- Specified by:
isPinnedin interfaceSymbol- Specified by:
isPinnedin interfaceTraceSymbol- Returns:
- true if the symbol is pinned to its current address.
-
setPinned
public void setPinned(boolean pinned) Description copied from interface:TraceSymbolSets 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.
Traces do not support moving memory, so pinning is meaningless and unsupported.- Specified by:
setPinnedin interfaceSymbol- Specified by:
setPinnedin interfaceTraceSymbol- Parameters:
pinned- true indicates this symbol is anchored to its address. false indicates this symbol is not anchored to its address.
-
isExternal
public boolean isExternal()Description copied from interface:SymbolReturns true if this an external symbol.- Specified by:
isExternalin interfaceSymbol- Returns:
- true if this an external symbol.
- See Also:
-