Interface PcodeExecutorStatePiece<A,T>

Type Parameters:
A - the type of address offsets
T - the type of values
All Known Subinterfaces:
PcodeExecutorState<T>
All Known Implementing Classes:
AbstractBytesPcodeExecutorStatePiece, AbstractLongOffsetPcodeExecutorStatePiece, BytesPcodeExecutorState, BytesPcodeExecutorStatePiece, DefaultPcodeExecutorState, LocationPcodeExecutorStatePiece, PairedPcodeExecutorState, PairedPcodeExecutorStatePiece, ThreadPcodeExecutorState

public interface PcodeExecutorStatePiece<A,T>
An interface that provides storage for values of type T, addressed by offsets of type A

The typical pattern for implementing a state is to compose it from one or more state pieces. Each piece must use the same address type and arithmetic. If more than one piece is needed, they are composed using PairedPcodeExecutorStatePiece. Once all the pieces are composed, the root piece can be wrapped to make a state using DefaultPcodeExecutorState or PairedPcodeExecutorState. The latter corrects the address type to be a pair so it matches the type of values.

  • Method Details

    • checkRange

      default void checkRange(AddressSpace space, long offset, int size)
      Construct a range, if only to verify the range is valid
      Parameters:
      space - the address space
      offset - the starting offset
      size - the length (in bytes) of the range
    • getLanguage

      Language getLanguage()
      Get the language defining the address spaces of this state piece
      Returns:
      the language
    • getAddressArithmetic

      PcodeArithmetic<A> getAddressArithmetic()
      Get the arithmetic used to manipulate addresses of the type used by this state
      Returns:
      the address (or offset) arithmetic
    • getArithmetic

      PcodeArithmetic<T> getArithmetic()
      Get the arithmetic used to manipulate values of the type stored by this state
      Returns:
      the arithmetic
    • fork

      default PcodeExecutorStatePiece<A,T> fork()
      Create a deep copy of this state
      Returns:
      the copy
    • setVar

      default void setVar(Register reg, T val)
      Set the value of a register variable
      Parameters:
      reg - the register
      val - the value
    • setVar

      default void setVar(Varnode var, T val)
      Set the value of a variable
      Parameters:
      var - the variable
      val - the value
    • setVar

      void setVar(AddressSpace space, A offset, int size, boolean quantize, T val)
      Set the value of a variable
      Parameters:
      space - the address space
      offset - the offset within the space
      size - the size of the variable
      quantize - true to quantize to the language's "addressable unit"
      val - the value
    • setVar

      default void setVar(AddressSpace space, long offset, int size, boolean quantize, T val)
      Set the value of a variable
      Parameters:
      space - the address space
      offset - the offset within the space
      size - the size of the variable
      quantize - true to quantize to the language's "addressable unit"
      val - the value
    • setVar

      default void setVar(Address address, int size, boolean quantize, T val)
      Set the value of a variable
      Parameters:
      address - the address in memory
      size - the size of the variable
      quantize - true to quantize to the language's "addressable unit"
      val - the value
    • getVar

      default T getVar(Register reg, PcodeExecutorStatePiece.Reason reason)
      Get the value of a register variable
      Parameters:
      reg - the register
      reason - the reason for reading the register
      Returns:
      the value
    • getVar

      default T getVar(Varnode var, PcodeExecutorStatePiece.Reason reason)
      Get the value of a variable
      Parameters:
      var - the variable
      reason - the reason for reading the variable
      Returns:
      the value
    • getVar

      T getVar(AddressSpace space, A offset, int size, boolean quantize, PcodeExecutorStatePiece.Reason reason)
      Get the value of a variable
      Parameters:
      space - the address space
      offset - the offset within the space
      size - the size of the variable
      quantize - true to quantize to the language's "addressable unit"
      reason - the reason for reading the variable
      Returns:
      the value
    • getVar

      default T getVar(AddressSpace space, long offset, int size, boolean quantize, PcodeExecutorStatePiece.Reason reason)
      Get the value of a variable

      This method is typically used for reading memory variables.

      Parameters:
      space - the address space
      offset - the offset within the space
      size - the size of the variable
      quantize - true to quantize to the language's "addressable unit"
      reason - the reason for reading the variable
      Returns:
      the value
    • getVar

      default T getVar(Address address, int size, boolean quantize, PcodeExecutorStatePiece.Reason reason)
      Get the value of a variable

      This method is typically used for reading memory variables.

      Parameters:
      address - the address of the variable
      size - the size of the variable
      quantize - true to quantize to the language's "addressable unit"
      reason - the reason for reading the variable
      Returns:
      the value
    • getRegisterValues

      Map<Register,T> getRegisterValues()
      Get all register values known to this state

      When the state acts as a cache, it should only return those cached.

      Returns:
      a map of registers and their values
    • getConcreteBuffer

      MemBuffer getConcreteBuffer(Address address, PcodeArithmetic.Purpose purpose)
      Bind a buffer of concrete bytes at the given start address
      Parameters:
      address - the start address
      purpose - the reason why the emulator needs a concrete value
      Returns:
      a buffer
    • quantizeOffset

      default long quantizeOffset(AddressSpace space, long offset)
      Quantize the given offset to the language's "addressable unit"
      Parameters:
      space - the space where the offset applies
      offset - the offset
      Returns:
      the quantized offset
    • clear

      void clear()
      Erase the entire state or piece

      This is generally only useful when the state is itself a cache to another object. This will ensure the state is reading from that object rather than a stale cache. If this is not a cache, this could in fact clear the whole state, and the machine using it will be left in the dark.