Package ghidra.program.database.register

# Class ProgramRegisterContextDB

java.lang.Object
ghidra.program.util.AbstractProgramContext
ghidra.program.util.AbstractStoredProgramContext
ghidra.program.database.register.ProgramRegisterContextDB

All Implemented Interfaces:
  `ManagerDB`, `DefaultProgramContext`, `ProgramContext`

public class ProgramRegisterContextDB extends AbstractStoredProgramContext implements ManagerDB

- ## Field Summary

  ### Fields inherited from class ghidra.program.util.AbstractStoredProgramContext

  `defaultRegisterValueMap, registerValueMap`

  ### Fields inherited from class ghidra.program.util.AbstractProgramContext

  `baseContextRegister, defaultDisassemblyContext, language`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ProgramRegisterContextDB(DBHandle dbHandle, ErrorHandler errHandler, Language lang, CompilerSpec compilerSpec, AddressMap addrMap, Lock lock, int openMode, CodeManager codeMgr, TaskMonitor monitor)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected RangeMapAdapter`
  `createNewRangeMapAdapter(Register baseRegister)`
  `void`
  `deleteAddressRange(Address start, Address end, TaskMonitor monitor)`
  Delete all objects which have been applied to the address range startAddr to endAddr and update the database accordingly.
  `void`
  `flushProcessorContextWriteCache()`
  Flush any cached context not yet written to database
  `AddressRangeIterator`
  `getDefaultRegisterValueAddressRanges(Register register)`
  Returns an AddressRangeIterator over all addresses that have an associated default value for the given register.
  `AddressRangeIterator`
  `getDefaultRegisterValueAddressRanges(Register register, Address start, Address end)`
  Returns an AddressRangeIterator over all addresses that have an associated default value within the given range for the given register.
  `RegisterValue`
  `getDefaultValue(Register register, Address address)`
  Returns the default value of a register at a given address.
  `RegisterValue`
  `getNonDefaultValue(Register register, Address address)`
  Returns the (non-default)value assigned to a register at a given address.
  `Register[]`
  `getRegistersWithValues()`
  Returns an array of all registers that at least one value associated with an address.
  `AddressRangeIterator`
  `getRegisterValueAddressRanges(Register register)`
  Returns an AddressRangeIterator over all addresses that have an associated value for the given register.
  `AddressRangeIterator`
  `getRegisterValueAddressRanges(Register register, Address start, Address end)`
  Returns an AddressRangeIterator over all addresses that have an associated value within the given range for the given register.
  `AddressRange`
  `getRegisterValueRangeContaining(Register register, Address addr)`
  Returns the bounding address-range containing addr and the the same RegisterValue throughout.
  `boolean`
  `hasValueOverRange(Register reg, BigInteger value, AddressSetView addrSet)`
  Returns true if the given register has the value over the addressSet
  `void`
  `initializeDefaultValues(Language lang, CompilerSpec compilerSpec)`
  Intialize context with default values defined by pspec and cspec.
  `void`
  `invalidateCache(boolean all)`
  Clears all data caches.
  `void`
  `invalidateProcessorContextWriteCache()`
  Flush any cached context not yet written to database
  `void`
  `moveAddressRange(Address fromAddr, Address toAddr, long length, TaskMonitor monitor)`
  Move all objects within an address range to a new location.
  `void`
  `programReady(int openMode, int currentRevision, TaskMonitor monitor)`
  Callback from program made to each manager after the program has completed initialization.
  `void`
  `remove(Address start, Address end, Register register)`
  Remove (unset) the register values for a given address range.
  `void`
  `setDefaultValue(RegisterValue registerValue, Address start, Address end)`
  Associates a default value with the given register over the given range.
  `void`
  `setLanguage(LanguageTranslator translator, CompilerSpec newCompilerSpec, AddressSetView programMemory, TaskMonitor monitor)`
  Perform context upgrade due to a language change
  `void`
  `setProgram(ProgramDB program)`
  Callback from program used to indicate all manager have been created.
  `void`
  `setRegisterValue(Address start, Address end, RegisterValue value)`
  Sets the register context over the given range to the given value.
  `void`
  `setValue(Register register, Address start, Address end, BigInteger value)`
  Associates a value with a register over a given address range.

  ### Methods inherited from class ghidra.program.util.AbstractStoredProgramContext

  `createRegisterValueStore, getDisassemblyContext, getRegisterValue, getValue, invalidateReadCache, invalidateWriteCache`

  ### Methods inherited from class ghidra.program.util.AbstractProgramContext

  `getBaseContextRegister, getContextRegisters, getDefaultDisassemblyContext, getFlowValue, getLanguage, getNonFlowValue, getRegister, getRegisterNames, getRegisters, hasNonFlowingContext, init, setDefaultDisassemblyContext`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface ghidra.program.database.ManagerDB

  `dispose`

- ## Constructor Details

  - ### ProgramRegisterContextDB

    public ProgramRegisterContextDB(DBHandle dbHandle, ErrorHandler errHandler, Language lang, CompilerSpec compilerSpec, AddressMap addrMap, Lock lock, int openMode, CodeManager codeMgr, TaskMonitor monitor) throws VersionException, CancelledException
    Throws:
      `VersionException`
      `CancelledException`

- ## Method Details

  - ### initializeDefaultValues

    public void initializeDefaultValues(Language lang, CompilerSpec compilerSpec)
    Intialize context with default values defined by pspec and cspec. NOTE: cspec values take precedence
    Parameters:
      `lang` - processor language
      `compilerSpec` - compiler specification

  - ### invalidateCache

    public void invalidateCache(boolean all) throws IOException
    Description copied from interface: `ManagerDB`
    Clears all data caches.
    Specified by:
      `invalidateCache` in interface `ManagerDB`
    Parameters:
      `all` - if false, some managers may not need to update their cache if they can tell that its not necessary. If this flag is true, then all managers should clear their cache no matter what.
    Throws:
      `IOException` - if a database io error occurs.

  - ### moveAddressRange

    public void moveAddressRange(Address fromAddr, Address toAddr, long length, TaskMonitor monitor) throws CancelledException
    Description copied from interface: `ManagerDB`
    Move all objects within an address range to a new location.
    Specified by:
      `moveAddressRange` in interface `ManagerDB`
    Overrides:
      `moveAddressRange` in class `AbstractStoredProgramContext`
    Parameters:
      `fromAddr` - the first address of the range to be moved.
      `toAddr` - the address where to the range is to be moved.
      `length` - the number of addresses to move.
      `monitor` - the task monitor to use in any upgrade operations.
    Throws:
      `CancelledException` - if the user cancelled the operation via the task monitor.

  - ### programReady

    public void programReady(int openMode, int currentRevision, TaskMonitor monitor) throws IOException, CancelledException
    Description copied from interface: `ManagerDB`
    Callback from program made to each manager after the program has completed initialization. This method may be used by managers to perform additional upgrading which may have been deferred.
    Specified by:
      `programReady` in interface `ManagerDB`
    Parameters:
      `openMode` - the mode that the program is being opened.
      `currentRevision` - current program revision. If openMode is UPGRADE, this value reflects the pre-upgrade value.
      `monitor` - the task monitor to use in any upgrade operations.
    Throws:
      `IOException` - if a database io error occurs.
      `CancelledException` - if the user cancelled the operation via the task monitor.

  - ### setProgram

    public void setProgram(ProgramDB program)
    Description copied from interface: `ManagerDB`
    Callback from program used to indicate all manager have been created. When this method is invoked, all managers have been instantiated but may not be fully initialized.
    Specified by:
      `setProgram` in interface `ManagerDB`
    Parameters:
      `program` - the program is set when all the initializations have been completed.

  - ### createNewRangeMapAdapter

    protected RangeMapAdapter createNewRangeMapAdapter(Register baseRegister)
    Specified by:
      `createNewRangeMapAdapter` in class `AbstractStoredProgramContext`

  - ### deleteAddressRange

    public void deleteAddressRange(Address start, Address end, TaskMonitor monitor)
    Description copied from interface: `ManagerDB`
    Delete all objects which have been applied to the address range startAddr to endAddr and update the database accordingly.
    Specified by:
      `deleteAddressRange` in interface `ManagerDB`
    Overrides:
      `deleteAddressRange` in class `AbstractStoredProgramContext`
    Parameters:
      `start` - the first address in the range.
      `end` - the last address in the range.
      `monitor` - the task monitor to use in any upgrade operations.

  - ### remove

    public void remove(Address start, Address end, Register register) throws ContextChangeException
    Description copied from interface: `ProgramContext`
    Remove (unset) the register values for a given address range.
    Specified by:
      `remove` in interface `ProgramContext`
    Overrides:
      `remove` in class `AbstractStoredProgramContext`
    Parameters:
      `start` - starting address.
      `end` - ending adddress.
      `register` - handle to the register to be set.
    Throws:
      `ContextChangeException` - thrown if context change not permitted over specified range (e.g., instructions exist)

  - ### setValue

    public void setValue(Register register, Address start, Address end, BigInteger value) throws ContextChangeException
    Description copied from interface: `ProgramContext`
    Associates a value with a register over a given address range. Any previous values will be overwritten.
    Specified by:
      `setValue` in interface `ProgramContext`
    Overrides:
      `setValue` in class `AbstractStoredProgramContext`
    Parameters:
      `register` - the register for which to assign a value.
      `start` - the start address.
      `end` - the end address (inclusive).
      `value` - the value to assign. A value of null will effective clear any existing values.
    Throws:
      `ContextChangeException` - if failed to modifiy context across specified range (e.g., instruction exists).

  - ### setRegisterValue

    public void setRegisterValue(Address start, Address end, RegisterValue value) throws ContextChangeException
    Description copied from interface: `ProgramContext`
    Sets the register context over the given range to the given value.
    Specified by:
      `setRegisterValue` in interface `ProgramContext`
    Overrides:
      `setRegisterValue` in class `AbstractStoredProgramContext`
    Parameters:
      `start` - the start address to set values
      `end` - the end address to set values
      `value` - the actual values to store at address
    Throws:
      `ContextChangeException` - if failed to modifiy context across specified range (e.g., instruction exists).

  - ### setLanguage

    public void setLanguage(LanguageTranslator translator, CompilerSpec newCompilerSpec, AddressSetView programMemory, TaskMonitor monitor) throws CancelledException
    Perform context upgrade due to a language change
    Parameters:
      `translator` - language translator required by major upgrades (may be null)
      `newCompilerSpec` - new compiler specification
      `programMemory` - program memory
      `monitor` - task monitor
    Throws:
      `CancelledException` - thrown if monitor cancelled

  - ### flushProcessorContextWriteCache

    public void flushProcessorContextWriteCache()
    Description copied from class: `AbstractStoredProgramContext`
    Flush any cached context not yet written to database
    Overrides:
      `flushProcessorContextWriteCache` in class `AbstractStoredProgramContext`

  - ### invalidateProcessorContextWriteCache

    public void invalidateProcessorContextWriteCache()
    Description copied from class: `AbstractStoredProgramContext`
    Flush any cached context not yet written to database
    Overrides:
      `invalidateProcessorContextWriteCache` in class `AbstractStoredProgramContext`

  - ### getRegisterValueAddressRanges

    public AddressRangeIterator getRegisterValueAddressRanges(Register register)
    Description copied from interface: `ProgramContext`
    Returns an AddressRangeIterator over all addresses that have an associated value for the given register. Each range returned will have the same value associated with the register for all addresses in that range.
    Specified by:
      `getRegisterValueAddressRanges` in interface `ProgramContext`
    Overrides:
      `getRegisterValueAddressRanges` in class `AbstractStoredProgramContext`
    Parameters:
      `register` - the register for which to get set value ranges.
    Returns:
      An AddressRangeIterator over all address that have values for the given register.

  - ### getRegisterValueRangeContaining

    public AddressRange getRegisterValueRangeContaining(Register register, Address addr)
    Description copied from interface: `ProgramContext`
    Returns the bounding address-range containing addr and the the same RegisterValue throughout. The range returned may be limited by other value changes associated with register's base-register.
    Specified by:
      `getRegisterValueRangeContaining` in interface `ProgramContext`
    Overrides:
      `getRegisterValueRangeContaining` in class `AbstractStoredProgramContext`
    Parameters:
      `register` - program register
      `addr` - program address
    Returns:
      single register-value address-range containing addr

  - ### getRegisterValueAddressRanges

    public AddressRangeIterator getRegisterValueAddressRanges(Register register, Address start, Address end)
    Description copied from interface: `ProgramContext`
    Returns an AddressRangeIterator over all addresses that have an associated value within the given range for the given register. Each range returned will have the same value associated with the register for all addresses in that range.
    Specified by:
      `getRegisterValueAddressRanges` in interface `ProgramContext`
    Overrides:
      `getRegisterValueAddressRanges` in class `AbstractStoredProgramContext`
    Parameters:
      `register` - the register for which to get set value ranges.
      `start` - start of address range to search
      `end` - end of address range to search
    Returns:
      An AddressRangeIterator over all address within the given range that have values for the given register.

  - ### getDefaultRegisterValueAddressRanges

    public AddressRangeIterator getDefaultRegisterValueAddressRanges(Register register)
    Description copied from interface: `ProgramContext`
    Returns an AddressRangeIterator over all addresses that have an associated default value for the given register. Each range returned will have the same default value associated with the register for all addresses in that range.
    Specified by:
      `getDefaultRegisterValueAddressRanges` in interface `ProgramContext`
    Overrides:
      `getDefaultRegisterValueAddressRanges` in class `AbstractStoredProgramContext`
    Parameters:
      `register` - the register for which to get set default value ranges.
    Returns:
      An AddressRangeIterator over all address that have default values for the given register.

  - ### getDefaultRegisterValueAddressRanges

    public AddressRangeIterator getDefaultRegisterValueAddressRanges(Register register, Address start, Address end)
    Description copied from interface: `ProgramContext`
    Returns an AddressRangeIterator over all addresses that have an associated default value within the given range for the given register. Each range returned will have the same default value associated with the register for all addresses in that range.
    Specified by:
      `getDefaultRegisterValueAddressRanges` in interface `ProgramContext`
    Overrides:
      `getDefaultRegisterValueAddressRanges` in class `AbstractStoredProgramContext`
    Parameters:
      `register` - the register for which to get default value ranges.
      `start` - start of address range to search
      `end` - end of address range to search
    Returns:
      An AddressRangeIterator over all address within the given range that have default values for the given register.

  - ### getRegistersWithValues

    public Register[] getRegistersWithValues()
    Description copied from interface: `ProgramContext`
    Returns an array of all registers that at least one value associated with an address.
    Specified by:
      `getRegistersWithValues` in interface `ProgramContext`
    Overrides:
      `getRegistersWithValues` in class `AbstractStoredProgramContext`
    Returns:
      a array of all registers that at least one value associated with an address.

  - ### hasValueOverRange

    public boolean hasValueOverRange(Register reg, BigInteger value, AddressSetView addrSet)
    Description copied from interface: `ProgramContext`
    Returns true if the given register has the value over the addressSet
    Specified by:
      `hasValueOverRange` in interface `ProgramContext`
    Overrides:
      `hasValueOverRange` in class `AbstractStoredProgramContext`
    Parameters:
      `reg` - the register whose value is to be tested.
      `value` - the value to test for.
      `addrSet` - the set of addresses to test
    Returns:
      true if every address in the addrSet has the value.

  - ### setDefaultValue

    public void setDefaultValue(RegisterValue registerValue, Address start, Address end)
    Description copied from interface: `DefaultProgramContext`
    Associates a default value with the given register over the given range.
    Specified by:
      `setDefaultValue` in interface `DefaultProgramContext`
    Overrides:
      `setDefaultValue` in class `AbstractStoredProgramContext`
    Parameters:
      `registerValue` - the register for which to associate a default value.
      `start` - the start address.
      `end` - the end address (inclusive)

  - ### getDefaultValue

    public RegisterValue getDefaultValue(Register register, Address address)
    Description copied from interface: `ProgramContext`
    Returns the default value of a register at a given address.
    Specified by:
      `getDefaultValue` in interface `DefaultProgramContext`
    Specified by:
      `getDefaultValue` in interface `ProgramContext`
    Overrides:
      `getDefaultValue` in class `AbstractStoredProgramContext`
    Parameters:
      `register` - the register for which to get a default value.
      `address` - the address at which to get a default value.
    Returns:
      the default value of the register at the given address or null if no default value has been assigned.

  - ### getNonDefaultValue

    public RegisterValue getNonDefaultValue(Register register, Address address)
    Description copied from interface: `ProgramContext`
    Returns the (non-default)value assigned to a register at a given address.
    Specified by:
      `getNonDefaultValue` in interface `ProgramContext`
    Overrides:
      `getNonDefaultValue` in class `AbstractStoredProgramContext`
    Parameters:
      `register` - the register for which to get its value.
      `address` - the address at which to get a value.
    Returns:
      a RegisterValue object containing the value of the register at the given address or possibly null if no value has been assigned.