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`

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 DBRecord`
  `record`
  `protected SymbolManager`
  `symbolMgr`

  ### Fields inherited from class ghidra.program.database.DatabaseObject

  `key`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected void`
  `checkDeleted()`
  Checks if this object has been deleted, in which case any use of the object is not allowed.
  `boolean`
  `delete()`
  Delete the symbol and its associated resources.
  `protected boolean`
  `doCheckIsPrimary()`
  `protected String`
  `doGetName()`
  The code for creating the name content for this symbol.
  `protected Namespace`
  `doGetParentNamespace()`
  `void`
  `doSetNameAndNamespace(String newName, Namespace newNamespace, SourceType source, boolean checkForDuplicates)`
  `protected void`
  `doSetPrimary(boolean primary)`
  `boolean`
  `equals(Object obj)`
  `Address`
  `getAddress()`
  `long`
  `getDataTypeId()`
  `long`
  `getID()`
  `final String`
  `getName()`
  `String`
  `getName(boolean includeNamespace)`
  Returns the symbol name, optionally prepended with the namespace path.
  `Namespace`
  `getParentNamespace()`
  Return the parent namespace for this symbol.
  `Symbol`
  `getParentSymbol()`
  Returns namespace symbol of the namespace containing this symbol
  `String[]`
  `getPath()`
  Gets the full path name for this symbol as an ordered array of strings ending with the symbol name.
  `Program`
  `getProgram()`
  Get the program associated with this symbol
  `SourceType`
  `getSource()`
  Gets the source of this symbol.
  `protected List<SymbolDB>`
  `getSymbolsDynamicallyRenamedByMyRename()`
  `int`
  `hashCode()`
  `boolean`
  `isDeleted()`
  Determine if this symbol object has been deleted.
  `boolean`
  `isDeleting()`
  `boolean`
  `isDescendant(Namespace namespace)`
  Returns true if the given namespace symbol is a descendant of this symbol.
  `boolean`
  `isDynamic()`
  `boolean`
  `isGlobal()`
  `abstract boolean`
  `isPrimary()`
  `boolean`
  `isValidParent(Namespace parent)`
  Determines if the given parent is valid for this Symbol.
  `protected boolean`
  `refresh()`
  Tells the object to refresh its state from the database.
  `protected boolean`
  `refresh(DBRecord rec)`
  Tells the object to refresh its state from the database using the specified record if not null.
  `protected void`
  `setAddress(Address addr)`
  `void`
  `setDataTypeId(long value)`
  Sets the generic symbol data 1.
  `void`
  `setName(String newName, SourceType source)`
  Sets the name this symbol.
  `void`
  `setNameAndNamespace(String newName, Namespace newNamespace, SourceType source)`
  Sets the symbols name and namespace.
  `void`
  `setNamespace(Namespace newNamespace)`
  Sets the symbols namespace
  `boolean`
  `setPrimary()`
  Sets this symbol to be primary.
  `void`
  `setSource(SourceType newSource)`
  Sets this symbol's source as specified.
  `protected void`
  `setSourceFlagBits(SourceType newSource)`
  `String`
  `toString()`
  `protected void`
  `updateRecord()`
  `protected SourceType`
  `validateNameSource(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

  `checkIsValid, checkIsValid, getKey, isDeleted, isInvalid, keyChanged, setDeleted, 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

  `getObject, getProgramLocation, getReferenceCount, getReferences, getReferences, getSymbolType, hasReferences, isExternal, isExternalEntryPoint, isPinned, setPinned`

- ## Field Details

  - ### record

    protected DBRecord record

  - ### address

    protected Address address

  - ### symbolMgr

    protected SymbolManager symbolMgr

  - ### lock

    protected Lock lock

- ## Method Details

  - ### isDeleted

    public boolean isDeleted()
    Description copied from interface: `Symbol`
    Determine if this symbol object has been deleted. NOTE: the symbol could be deleted at anytime due to asynchronous activity.
    Specified by:
      `isDeleted` in interface `Symbol`
    Returns:
      true if symbol has been deleted, false if not.

  - ### checkDeleted

    protected void checkDeleted()
    Description copied from class: `DatabaseObject`
    Checks 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:
      `checkDeleted` in class `DatabaseObject`

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`

  - ### refresh

    protected boolean refresh()
    Description copied from class: `DatabaseObject`
    Tells the object to refresh its state from the database.
    Specified by:
      `refresh` in class `DatabaseObject`
    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(DBRecord 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 class `DatabaseObject`
    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 interface `Symbol`
    Returns:
      the address for the symbol.

  - ### setAddress

    protected void setAddress(Address addr)

  - ### getName

    public final String getName()
    Specified by:
      `getName` in interface `Symbol`
    Returns:
      the name of this symbol.

  - ### doGetName

    protected String 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

    public Program getProgram()
    Description copied from interface: `Symbol`
    Get the program associated with this symbol
    Specified by:
      `getProgram` in interface `Symbol`
    Returns:
      the program associated with this symbol.

  - ### getName

    public String getName(boolean includeNamespace)
    Description copied from interface: `Symbol`
    Returns the symbol name, optionally prepended with the namespace path.
    Specified by:
      `getName` in interface `Symbol`
    Parameters:
      `includeNamespace` - if true, the namespace path is prepended to the name.
    Returns:
      formatted name

  - ### getPath

    public 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.
    Specified by:
      `getPath` in interface `Symbol`
    Returns:
      the array indicating the full path name for this symbol.

  - ### isDynamic

    public boolean isDynamic()
    Specified by:
      `isDynamic` in interface `Symbol`
    Returns:
      true if this symbol is a dynamic symbol (not actually defined in the database).

  - ### isPrimary

    public abstract boolean isPrimary()
    Specified by:
      `isPrimary` in interface `Symbol`
    Returns:
      true if this symbol is primary

  - ### setSource

    public void setSource(SourceType newSource)
    Sets this symbol's source as specified.
    Specified by:
      `setSource` in interface `Symbol`
    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

    protected void setSourceFlagBits(SourceType newSource)

  - ### getSource

    public SourceType getSource()
    Description copied from interface: `Symbol`
    Gets the source of this symbol. `SourceType`
    Specified by:
      `getSource` in interface `Symbol`
    Returns:
      the source of this symbol

  - ### setName

    public void setName(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 interface `Symbol`
    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 (see `SymbolUtilities.validateName(java.lang.String)`).

  - ### setNamespace

    public void setNamespace(Namespace newNamespace) throws DuplicateNameException, InvalidInputException, CircularDependencyException
    Description copied from interface: `Symbol`
    Sets the symbols namespace
    Specified by:
      `setNamespace` in interface `Symbol`
    Parameters:
      `newNamespace` - new parent namespace
    Throws:
      `DuplicateNameException` - if newNamespace already contains a symbol with this symbol's name
      `InvalidInputException` - is newNamespace is not a valid parent for this symbol
      `CircularDependencyException` - if this symbol is an ancestor of newNamespace

  - ### validateNameSource

    protected SourceType validateNameSource(String newName, SourceType source)
    Allow symbol implementations to validate the source when setting the name of this symbol
    Parameters:
      `newName` - the new name
      `source` - the source type
    Returns:
      the validated source type

  - ### doSetNameAndNamespace

    public void doSetNameAndNamespace(String newName, Namespace newNamespace, SourceType source, boolean checkForDuplicates) throws DuplicateNameException, InvalidInputException, CircularDependencyException
    Throws:
      `DuplicateNameException`
      `InvalidInputException`
      `CircularDependencyException`

  - ### setNameAndNamespace

    public void setNameAndNamespace(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 interface `Symbol`
    Parameters:
      `newName` - new symbol name
      `newNamespace` - new parent namespace
      `source` - 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 name
      `InvalidInputException` - is newNamespace is not a valid parent for this symbol
      `CircularDependencyException` - if this symbol is an ancestor of newNamespace

  - ### getSymbolsDynamicallyRenamedByMyRename

    protected 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 interface `Symbol`
    Returns:
      returns true if the symbol was not primary and now it is, otherwise false
    See Also:
      - `Symbol.setPrimary()`

  - ### getID

    public long getID()
    Specified by:
      `getID` in interface `Symbol`
    Returns:
      this symbol's ID.

  - ### equals

    public boolean equals(Object obj)
    Overrides:
      `equals` in class `Object`

  - ### hashCode

    public int hashCode()
    Overrides:
      `hashCode` in class `Object`

  - ### updateRecord

    protected void updateRecord()

  - ### getParentNamespace

    public Namespace getParentNamespace()
    Description copied from interface: `Symbol`
    Return the parent namespace for this symbol.
    Specified by:
      `getParentNamespace` in interface `Symbol`
    Returns:
      the namespace that contains this symbol.

  - ### doGetParentNamespace

    protected Namespace doGetParentNamespace()

  - ### getParentSymbol

    public Symbol getParentSymbol()
    Description copied from interface: `Symbol`
    Returns namespace symbol of the namespace containing this symbol
    Specified by:
      `getParentSymbol` in interface `Symbol`
    Returns:
      parent namespace symbol

  - ### isGlobal

    public boolean isGlobal()
    Specified by:
      `isGlobal` in interface `Symbol`
    Returns:
      true if the symbol is contained within the global namespace

  - ### 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: `Symbol`
    Delete the symbol and its associated resources. Any references symbol associations will be discarded.
    Specified by:
      `delete` in interface `Symbol`
    Returns:
      true if successful

  - ### 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 interface `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

    public boolean isValidParent(Namespace parent)
    Description copied from interface: `Symbol`
    Determines if the given parent is valid for this Symbol. Specified namespace must belong to the same symbol table as this symbol.
    Specified by:
      `isValidParent` in interface `Symbol`
    Parameters:
      `parent` - prospective parent namespace for this symbol
    Returns:
      true if parent is valid