Package ghidra.pcode.exec

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

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `AbstractLongOffsetPcodeExecutorStatePiece.AbstractSpaceMap<S>`
  A map of address spaces to objects which store or cache state for that space
  `static class`
  `AbstractLongOffsetPcodeExecutorStatePiece.CacheingSpaceMap<B,S>`
  Use this when each S is possibly a cache to some other state (backing) object
  `static class`
  `AbstractLongOffsetPcodeExecutorStatePiece.SimpleSpaceMap<S>`
  Use this when each S contains the complete state for the address space

  ## Nested classes/interfaces inherited from interface ghidra.pcode.exec.PcodeExecutorStatePiece

  `PcodeExecutorStatePiece.Reason`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected final PcodeArithmetic<A>`
  `addressArithmetic`
  `protected final PcodeArithmetic<T>`
  `arithmetic`
  `protected final Language`
  `language`
  `protected final AddressSpace`
  `uniqueSpace`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `AbstractLongOffsetPcodeExecutorStatePiece(Language language, PcodeArithmetic<A> addressArithmetic, PcodeArithmetic<T> arithmetic)`
  Construct a state piece for the given language and arithmetic

- ## Method Summary

  Modifier and Type
  Method
  Description
  `PcodeArithmetic<A>`
  `getAddressArithmetic()`
  Get the arithmetic used to manipulate addresses of the type used by this state
  `PcodeArithmetic<T>`
  `getArithmetic()`
  Get the arithmetic used to manipulate values of the type stored by this state
  `protected abstract S`
  `getForSpace(AddressSpace space, boolean toWrite)`
  Get the internal space for the given address space
  `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.
  `protected abstract T`
  `getFromSpace(S space, long offset, int size, PcodeExecutorStatePiece.Reason reason)`
  Get a value from the given space
  `Language`
  `getLanguage()`
  Get the language defining the address spaces of this state piece
  `Map<Register,T>`
  `getRegisterValues()`
  Get all register values known to this state
  `protected abstract Map<Register,T>`
  `getRegisterValuesFromSpace(S s, List<Register> registers)`
  Can the given space for register values, as in `getRegisterValues()`
  `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.
  `T`
  `getVar(AddressSpace space, long offset, int size, boolean quantize, PcodeExecutorStatePiece.Reason reason)`
  Get the value of a variable
  `T`
  `getVar(AddressSpace space, A offset, int size, boolean quantize, PcodeExecutorStatePiece.Reason reason)`
  Get the value of a variable
  `protected abstract void`
  `setInSpace(S space, long offset, int size, T val)`
  Set a value in the given space
  `protected void`
  `setUnique(long offset, int size, T val)`
  Set a value in the unique space
  `void`
  `setVar(AddressSpace space, long offset, int size, boolean quantize, T val)`
  Set the value of a variable
  `void`
  `setVar(AddressSpace space, A offset, int size, boolean quantize, T val)`
  Set the value of a variable

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

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

  ### Methods inherited from interface ghidra.pcode.exec.PcodeExecutorStatePiece

  `checkRange, clear, fork, getConcreteBuffer, getVar, getVar, getVar, quantizeOffset, setVar, setVar, setVar`

- ## Field Details

  - ### language

    protected final Language language

  - ### addressArithmetic

    protected final PcodeArithmetic<A> addressArithmetic

  - ### arithmetic

    protected final PcodeArithmetic<T> arithmetic

  - ### uniqueSpace

    protected final AddressSpace uniqueSpace

- ## 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:
      - `AbstractLongOffsetPcodeExecutorStatePiece.AbstractSpaceMap`

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