Package ghidra.program.disassemble

# Class Disassembler.DisassemblerProgramContext

java.lang.Object
ghidra.program.util.AbstractProgramContext
ghidra.program.disassemble.Disassembler.DisassemblerProgramContext

All Implemented Interfaces:
  `DefaultProgramContext`, `ProgramContext`

Enclosing class:
  `Disassembler`

protected class Disassembler.DisassemblerProgramContext extends AbstractProgramContext
`DisassemblerProgramContext` is used as a proxy program context due to the delayed nature of laying down instructions and their associated context state. This is used to track context not yet committed for use by the DisassemblerContext in place of the true program context.

- ## Field Summary

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

  `baseContextRegister, defaultDisassemblyContext, language`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `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`
  `getDisassemblyContext(Address address)`
  Get the disassembly context for a specified address.
  `protected ProcessorContext`
  `getInstructionContext(RegisterValue value, Address instrAddr, int instrLength)`
  Following the parse of a new instruction prototype, get a immutable processor context for minting a new instruction.
  `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.
  `RegisterValue`
  `getRegisterValue(Register register, Address address)`
  Returns a register value and mask for the given register.
  `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 same RegisterValue throughout.
  `BigInteger`
  `getValue(Register register, Address address, boolean signed)`
  Returns the value assigned to a register at a given address.
  `boolean`
  `hasValueOverRange(Register reg, BigInteger value, AddressSetView addrSet)`
  Returns true if the given register has the value over the addressSet
  `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`
  `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.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`

- ## Method Details

  - ### getInstructionContext

    protected ProcessorContext getInstructionContext(RegisterValue value, Address instrAddr, int instrLength)
    Following the parse of a new instruction prototype, get a immutable processor context for minting a new instruction. If value is not null, the temporary context is expanded to include the context-register value. The temporary context should be cleared after in-memory instructions (i.e., InstructionSet) have been written to the program.
    Parameters:
      `value` - to add to instruction context if different
      `instrAddr` - address of instruction that should have context
      `instrLength` - length of instruction to set context
    Returns:
      instruction context with possible added 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.
    Returns:
      a array of all registers that at least one value associated with an address.

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

  - ### getRegisterValue

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

  - ### 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.
    Parameters:
      `start` - the start address to set values
      `end` - the end address to set values
      `value` - the actual values to store at address

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

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

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

  - ### getRegisterValueRangeContaining

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

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

  - ### 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.
    Parameters:
      `registerValue` - the register for which to associate a default value.
      `start` - the start address.
      `end` - the end address (inclusive)

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

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

  - ### getDefaultValue

    public RegisterValue getDefaultValue(Register register, Address address)
    Description copied from interface: `ProgramContext`
    Returns the default value of a register at a given address.
    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.

  - ### 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.
    Parameters:
      `address` - program address
    Returns:
      disassembly context register value