Class OldProgramContextDB

java.lang.Object
ghidra.program.database.register.OldProgramContextDB
All Implemented Interfaces:
ManagerDB, DefaultProgramContext, ProgramContext

public class OldProgramContextDB extends Object implements ProgramContext, DefaultProgramContext, ManagerDB
ProgramContextDB defines a processor context over an address space using database range maps for storage.
  • Field Details

  • Constructor Details

    • OldProgramContextDB

      public OldProgramContextDB(DBHandle dbHandle, ErrorHandler errHandler, Language language, AddressMap addrMap, Lock lock)
      Constructs a new ProgramContextDB object
      Parameters:
      dbHandle - the handle to the database.
      errHandler - the error handler
      language - the processor language
      addrMap - the address map.
      lock - the program synchronization lock
  • Method Details

    • deleteAddressRange

      public void deleteAddressRange(Address start, Address end, TaskMonitor monitor) throws CancelledException
      Description copied from interface: ManagerDB
      Delete all objects which have been applied to the address range startAddr to endAddr and update the database accordingly. The specified start and end addresses must form a valid range within a single AddressSpace.
      Specified by:
      deleteAddressRange in interface ManagerDB
      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.
      Throws:
      CancelledException - if the user cancelled the operation via the task monitor.
    • get

      public long get(Address addr, Register reg)
    • getBaseContextRegister

      public Register getBaseContextRegister()
      Description copied from interface: ProgramContext
      Returns the base context register.
      Specified by:
      getBaseContextRegister in interface ProgramContext
      Returns:
      the base context 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
      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
      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.
    • 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
      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
      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.
    • getContextRegisters

      public List<Register> getContextRegisters()
      Description copied from interface: ProgramContext
      Gets the registers for this context that are used for processor context states.
      Specified by:
      getContextRegisters in interface ProgramContext
      Returns:
      all processor context registers
    • getRegister

      public Register getRegister(String name)
      Description copied from interface: ProgramContext
      Get a Register object given the name of a register
      Specified by:
      getRegister in interface ProgramContext
      Parameters:
      name - the name of the register.
      Returns:
      The register with the given name or null if no register has that name.
    • getRegisterNames

      public List<String> getRegisterNames()
      Description copied from interface: ProgramContext
      Get an alphabetical sorted unmodifiable list of original register names (including context registers). Names correspond to orignal register name and not aliases which may be defined.
      Specified by:
      getRegisterNames in interface ProgramContext
      Returns:
      alphabetical sorted unmodifiable list of original register names.
    • 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
      Parameters:
      register - the register for which to get set value ranges.
      Returns:
      An AddressRangeIterator over all address that have values for the given register.
    • 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
      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.
    • getRegisterValues

      public ghidra.program.database.register.RegisterValueRange[] getRegisterValues(Register reg, Address start, Address end)
    • getRegisters

      public List<Register> getRegisters()
      Description copied from interface: ProgramContext
      Get all the register descriptions defined for this program context.
      Specified by:
      getRegisters in interface ProgramContext
      Returns:
      unmodifiable list of defined register descriptions
    • getSigned

      public long getSigned(Address addr, Register reg) throws UnsupportedOperationException
      Throws:
      UnsupportedOperationException
    • getRegisterValue

      public RegisterValue getRegisterValue(Register register, Address address)
      Description copied from interface: ProgramContext
      Returns a register value and mask for the given register.
      Specified by:
      getRegisterValue in interface ProgramContext
      Parameters:
      register - the register
      address - the address of the value
      Returns:
      a register value and mask for the given register
    • getValue

      public BigInteger getValue(Register register, Address address, boolean signed)
      Description copied from interface: ProgramContext
      Returns the value assigned to a register at a given address. This method will return any default value assigned to the register at the given address if no explicit value has been set at that address.
      Specified by:
      getValue in interface ProgramContext
      Parameters:
      register - the register for which to get its value.
      address - the address at which to get a value.
      signed - if true, interprets the fix-bit size register value as a signed value.
      Returns:
      a BigInteger object containing the value of the registe at the given address or null if no value has been assigned.
    • 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
      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.
    • remove

      public void remove(Address start, Address end, Register register)
      Description copied from interface: ProgramContext
      Remove (unset) the register values for a given address range.
      Specified by:
      remove in interface ProgramContext
      Parameters:
      start - starting address.
      end - ending adddress.
      register - handle to the register to be set.
    • set

      public void set(Address start, Address end, Register reg, long 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
      Parameters:
      registerValue - the register for which to associate a default value.
      start - the start address.
      end - the end address (inclusive)
    • setValue

      public void setValue(Register register, Address start, Address end, BigInteger value)
      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
      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.
    • setRegisterValue

      public void setRegisterValue(Address start, Address end, RegisterValue value)
      Description copied from interface: ProgramContext
      Sets the register context over the given range to the given value.
      Specified by:
      setRegisterValue in interface ProgramContext
      Parameters:
      start - the start address to set values
      end - the end address to set values
      value - the actual values to store at address
    • 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
      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(OpenMode 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.
    • getDefaultDisassemblyContext

      public RegisterValue getDefaultDisassemblyContext()
      Specified by:
      getDefaultDisassemblyContext in interface ProgramContext
      Returns:
      Get the current default disassembly context to be used when initiating disassmbly
    • setDefaultDisassemblyContext

      public void setDefaultDisassemblyContext(RegisterValue newContext)
      Description copied from interface: ProgramContext
      Set the initial disassembly context to be used when initiating disassmbly
      Specified by:
      setDefaultDisassemblyContext in interface ProgramContext
      Parameters:
      newContext - context register value
    • 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
      Returns:
      a array of all registers that at least one value associated with an address.
    • getDisassemblyContext

      public RegisterValue getDisassemblyContext(Address address)
      Description copied from interface: ProgramContext
      Get the disassembly context for a specified address. This context is formed from the default disassembly context and the context register value stored at the specified address. Those bits specified by the stored context value take precedence.
      Specified by:
      getDisassemblyContext in interface ProgramContext
      Parameters:
      address - program address
      Returns:
      disassembly context register value
    • 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
      Parameters:
      register - program register
      addr - program address
      Returns:
      single register-value address-range containing addr
    • hasNonFlowingContext

      public boolean hasNonFlowingContext()
      Specified by:
      hasNonFlowingContext in interface ProgramContext
      Returns:
      true if one or more non-flowing context registers fields have been defined within the base processor context register.
    • getFlowValue

      public RegisterValue getFlowValue(RegisterValue value)
      Description copied from interface: ProgramContext
      Modify register value to eliminate non-flowing bits
      Specified by:
      getFlowValue in interface ProgramContext
      Parameters:
      value - register value to be modified
      Returns:
      value suitable for flowing
    • getNonFlowValue

      public RegisterValue getNonFlowValue(RegisterValue value)
      Description copied from interface: ProgramContext
      Modify register value to only include non-flowing bits
      Specified by:
      getNonFlowValue in interface ProgramContext
      Parameters:
      value - register value to be modified
      Returns:
      new value or null