Class AbstractLongOffsetPcodeExecutorStatePiece<A,T,S>

java.lang.Object
ghidra.pcode.exec.AbstractLongOffsetPcodeExecutorStatePiece<A,T,S>
Type Parameters:
A - the type used to address contents, convertible to and from long
T - the type of values stored
S - the type of an execute state space, internally associated with an address space
All Implemented Interfaces:
PcodeExecutorStatePiece<A,T>
Direct Known Subclasses:
AbstractBytesPcodeExecutorStatePiece

public abstract class AbstractLongOffsetPcodeExecutorStatePiece<A,T,S> extends Object implements PcodeExecutorStatePiece<A,T>
An abstract executor state piece which internally uses long to address contents

This also provides an internal mechanism for breaking the piece down into the spaces defined by a language. It also provides for the special treatment of the unique space.

  • Field Details

  • Constructor Details

    • AbstractLongOffsetPcodeExecutorStatePiece

      public AbstractLongOffsetPcodeExecutorStatePiece(Language language, PcodeArithmetic<A> addressArithmetic, PcodeArithmetic<T> arithmetic)
      Construct a state piece for the given language and arithmetic
      Parameters:
      language - the language (used for its memory model)
      arithmetic - an arithmetic used to generate default values of T
  • Method Details

    • getLanguage

      public Language getLanguage()
      Description copied from interface: PcodeExecutorStatePiece
      Get the language defining the address spaces of this state piece
      Specified by:
      getLanguage in interface PcodeExecutorStatePiece<A,T>
      Returns:
      the language
    • getAddressArithmetic

      public PcodeArithmetic<A> getAddressArithmetic()
      Description copied from interface: PcodeExecutorStatePiece
      Get the arithmetic used to manipulate addresses of the type used by this state
      Specified by:
      getAddressArithmetic in interface PcodeExecutorStatePiece<A,T>
      Returns:
      the address (or offset) arithmetic
    • getArithmetic

      public PcodeArithmetic<T> getArithmetic()
      Description copied from interface: PcodeExecutorStatePiece
      Get the arithmetic used to manipulate values of the type stored by this state
      Specified by:
      getArithmetic in interface PcodeExecutorStatePiece<A,T>
      Returns:
      the arithmetic
    • setUnique

      protected void setUnique(long offset, int size, T val)
      Set a value in the unique space

      Some state pieces treat unique values in a way that merits a separate implementation. This permits the standard path to be overridden.

      Parameters:
      offset - the offset in unique space to store the value
      size - the number of bytes to write (the size of the value)
      val - the value to store
    • getUnique

      protected T getUnique(long offset, int size, PcodeExecutorStatePiece.Reason reason)
      Get a value from the unique space Some state pieces treat unique values in a way that merits a separate implementation. This permits the standard path to be overridden.
      Parameters:
      offset - the offset in unique space to get the value
      size - the number of bytes to read (the size of the value)
      reason - the reason for reading state
      Returns:
      the read value
    • getForSpace

      protected abstract S getForSpace(AddressSpace space, boolean toWrite)
      Get the internal space for the given address space
      Parameters:
      space - the address space
      toWrite - in case internal spaces are generated lazily, this indicates the space must be present, because it is going to be written to.
      Returns:
      the space, or null
      See Also:
    • setInSpace

      protected abstract void setInSpace(S space, long offset, int size, T val)
      Set a value in the given space
      Parameters:
      space - the address space
      offset - the offset within the space
      size - the number of bytes to write (the size of the value)
      val - the value to store
    • getFromSpace

      protected abstract T getFromSpace(S space, long offset, int size, PcodeExecutorStatePiece.Reason reason)
      Get a value from the given space
      Parameters:
      space - the address space
      offset - the offset within the space
      size - the number of bytes to read (the size of the value)
      reason - the reason for reading state
      Returns:
      the read value
    • getFromNullSpace

      protected T getFromNullSpace(int size, PcodeExecutorStatePiece.Reason reason)
      In case spaces are generated lazily, and we're reading from a space that doesn't yet exist, "read" a default value.

      By default, the returned value is 0, which should be reasonable for all implementations.

      Parameters:
      size - the number of bytes to read (the size of the value)
      reason - the reason for reading state
      Returns:
      the default value
    • setVar

      public void setVar(AddressSpace space, A offset, int size, boolean quantize, T val)
      Description copied from interface: PcodeExecutorStatePiece
      Set the value of a variable
      Specified by:
      setVar in interface PcodeExecutorStatePiece<A,T>
      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

      public void setVar(AddressSpace space, long offset, int size, boolean quantize, T val)
      Description copied from interface: PcodeExecutorStatePiece
      Set the value of a variable
      Specified by:
      setVar in interface PcodeExecutorStatePiece<A,T>
      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
    • getVar

      public T getVar(AddressSpace space, A offset, int size, boolean quantize, PcodeExecutorStatePiece.Reason reason)
      Description copied from interface: PcodeExecutorStatePiece
      Get the value of a variable
      Specified by:
      getVar in interface PcodeExecutorStatePiece<A,T>
      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

      public T getVar(AddressSpace space, long offset, int size, boolean quantize, PcodeExecutorStatePiece.Reason reason)
      Description copied from interface: PcodeExecutorStatePiece
      Get the value of a variable

      This method is typically used for reading memory variables.

      Specified by:
      getVar in interface PcodeExecutorStatePiece<A,T>
      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
    • getRegisterValuesFromSpace

      protected abstract Map<Register,T> getRegisterValuesFromSpace(S s, List<Register> registers)
      Can the given space for register values, as in getRegisterValues()
      Parameters:
      s - the space to scan
      registers - the registers known to be in the corresponding address space
      Returns:
      the map of registers to values
    • getRegisterValues

      public Map<Register,T> getRegisterValues()
      Description copied from interface: PcodeExecutorStatePiece
      Get all register values known to this state

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

      Specified by:
      getRegisterValues in interface PcodeExecutorStatePiece<A,T>
      Returns:
      a map of registers and their values