Package ghidra.program.database.symbol

# Class VariableSymbolDB

java.lang.Object
ghidra.program.database.DatabaseObject
ghidra.program.database.symbol.SymbolDB
ghidra.program.database.symbol.VariableSymbolDB

All Implemented Interfaces:
  `Symbol`

Direct Known Subclasses:
  `GlobalVariableSymbolDB`

public class VariableSymbolDB extends SymbolDB
Symbol class for function variables. Symbol Data Usage: String stringData - variable comment

- ## Field Summary

  ### Fields inherited from class ghidra.program.database.symbol.SymbolDB

  `address, lock, record, symbolMgr`

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

  `key`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `VariableSymbolDB(SymbolManager symbolMgr, DBObjectCache<SymbolDB> cache, SymbolType type, VariableStorageManagerDB variableMgr, Address address, DBRecord record)`
  Constructs a new VariableSymbol

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `delete()`
  Delete the symbol and its associated resources.
  `protected String`
  `doGetName()`
  The code for creating the name content for this symbol.
  `boolean`
  `equals(Object obj)`
  `DataType`
  `getDataType()`
  `int`
  `getFirstUseOffset()`
  `FunctionDB`
  `getFunction()`
  `Variable`
  `getObject()`
  `int`
  `getOrdinal()`
  `ProgramLocation`
  `getProgramLocation()`
  Returns a program location for this symbol; may be null.
  `int`
  `getReferenceCount()`
  Get the number of References to this symbol or its address.
  `Reference[]`
  `getReferences(TaskMonitor monitor)`
  Returns all memory references to the address of this symbol.
  `String`
  `getSymbolComment()`
  Returns variable symbol comment.
  `SymbolType`
  `getSymbolType()`
  Returns this symbol's type
  `protected int`
  `getVariableOffset()`
  gets the generic symbol data 2 data.
  `VariableStorage`
  `getVariableStorage()`
  `boolean`
  `hasReferences()`
  `boolean`
  `isExternal()`
  Returns true if this an external symbol.
  `boolean`
  `isPrimary()`
  `boolean`
  `isValidParent(Namespace parent)`
  Determines if the given parent is valid for this Symbol.
  `protected boolean`
  `refresh(DBRecord rec)`
  Tells the object to refresh its state from the database using the specified record if not null.
  `void`
  `setFirstUseOffset(int firstUseOffset)`
  `void`
  `setInvalid()`
  Invalidate this object.
  `void`
  `setOrdinal(int ordinal)`
  `void`
  `setStorageAndDataType(VariableStorage newStorage, DataType dt)`
  Change the storage address and data-type associated with this variable symbol.
  `void`
  `setSymbolComment(String comment)`
  Update variable symbol comment (no change event is issued)
  `void`
  `setVariableOffset(int offset)`
  Sets the symbol's variable offset.
  `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.symbol.SymbolDB

  `checkDeleted, doCheckIsPrimary, doGetParentNamespace, doSetNameAndNamespace, doSetPrimary, getAddress, getDataTypeId, getID, getName, getName, getParentNamespace, getParentSymbol, getPath, getProgram, getSource, getSymbolsDynamicallyRenamedByMyRename, hashCode, isDeleted, isDeleting, isDescendant, isDynamic, isGlobal, refresh, setAddress, setDataTypeId, setName, setNameAndNamespace, setNamespace, setPrimary, setSource, setSourceFlagBits, toString, updateRecord`

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

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

  `getReferences, isExternalEntryPoint, isPinned, setPinned`

- ## Constructor Details

  - ### VariableSymbolDB

    public VariableSymbolDB(SymbolManager symbolMgr, DBObjectCache<SymbolDB> cache, SymbolType type, VariableStorageManagerDB variableMgr, Address address, DBRecord record)
    Constructs a new VariableSymbol
    Parameters:
      `symbolMgr` - the symbol manager
      `cache` - symbol object cache
      `type` - the symbol type.
      `variableMgr` - variable storage manager
      `address` - the address of the symbol (stack address)
      `record` - the record for the symbol

- ## Method Details

  - ### setInvalid

    public void setInvalid()
    Description copied from class: `DatabaseObject`
    Invalidate this object. This does not necessarily mean that this object can never be used again. If the object can refresh itself, it may still be useable.
    Overrides:
      `setInvalid` in class `DatabaseObject`

  - ### getVariableStorage

    public VariableStorage getVariableStorage()

  - ### getSymbolType

    public SymbolType getSymbolType()
    Description copied from interface: `Symbol`
    Returns this symbol's type
    Returns:
      symbol type

  - ### 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 `SymbolDB`
    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.

  - ### equals

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

  - ### 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`
    Overrides:
      `delete` in class `SymbolDB`
    Returns:
      true if successful

  - ### getObject

    public Variable getObject()
    Returns:
      object associated with this symbol or null if symbol has been deleted

  - ### isPrimary

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

  - ### isExternal

    public boolean isExternal()
    Description copied from interface: `Symbol`
    Returns true if this an external symbol.
    Returns:
      true if this an external symbol.
    See Also:
      - `Address.isExternalAddress()`

  - ### getFunction

    public FunctionDB getFunction()

  - ### getProgramLocation

    public ProgramLocation getProgramLocation()
    Description copied from interface: `Symbol`
    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

  - ### 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`
    Overrides:
      `isValidParent` in class `SymbolDB`
    Parameters:
      `parent` - prospective parent namespace for this symbol
    Returns:
      true if parent is valid

  - ### doGetName

    protected String doGetName()
    Description copied from class: `SymbolDB`
    The code for creating the name content for this symbol. This code will be called with the symbol's lock.
    Overrides:
      `doGetName` in class `SymbolDB`
    Returns:
      the name

  - ### validateNameSource

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

  - ### getDataType

    public DataType getDataType()

  - ### setStorageAndDataType

    public void setStorageAndDataType(VariableStorage newStorage, DataType dt)
    Change the storage address and data-type associated with this variable symbol.
    Parameters:
      `newStorage` - the new storage
      `dt` - data-type

  - ### getFirstUseOffset

    public int getFirstUseOffset()

  - ### setFirstUseOffset

    public void setFirstUseOffset(int firstUseOffset)

  - ### getOrdinal

    public int getOrdinal()

  - ### setOrdinal

    public void setOrdinal(int ordinal)

  - ### getReferenceCount

    public int getReferenceCount()
    Description copied from interface: `Symbol`
    Get 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 return `ReferenceManager.getReferenceCountTo(Address)` if this is the only symbol at its address.

    Returns:
      the number of References to this symbol or its address.

  - ### 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 a `TaskMonitor` instance, then you can pass `TaskMonitor.DUMMY` or `null`.
    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.

  - ### hasReferences

    public 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).

  - ### getVariableOffset

    protected int getVariableOffset()
    gets the generic symbol data 2 data.
    Returns:
      the symbol data

  - ### setVariableOffset

    public void setVariableOffset(int offset)
    Sets the symbol's variable offset. For parameters, this is the ordinal, for locals, it is the first use offset
    Parameters:
      `offset` - the value to set as the symbols variable offset.

  - ### getSymbolComment

    public String getSymbolComment()
    Returns variable symbol comment.
    Returns:
      variable symbol comment

  - ### setSymbolComment

    public void setSymbolComment(String comment)
    Update variable symbol comment (no change event is issued)
    Parameters:
      `comment` - variable comment