Interface PcodeStateCallbacks

All Known Implementing Classes:
PcodeEmulationCallbacks.Wrapper, PcodeStateCallbacks.NoPcodeStateCallbacks

public interface PcodeStateCallbacks
A set of callbacks available for state changes during p-code execution.

When dealing with emulation (as opposed to just p-code execution), consider PcodeEmulationCallbacks instead. See PcodeEmulator for advice regarding extension versus integration. In particular, these callbacks were introduced to avert the need to extend PcodeExecutorStates and/or PcodeExecutorStatePieces just to introduce integration-driven behaviors. E.g., to lazily load state from an external machine-state snapshot, the client should implement the readUninitialized(PcodeExecutorStatePiece, AddressSetView) or PcodeEmulationCallbacks.readUninitialized(PcodeThread, PcodeExecutorStatePiece, AddressSetView) callback rather than extending BytesPcodeExecutorStatePiece.

  • Field Details

  • Method Details

    • rngSet

      static AddressSet rngSet(AddressSpace space, long offset, int length)
      A convenience for constructing an address set from a varnode-like triple
      Parameters:
      space - the address space
      offset - the offset
      length - the size in bytes, at least 1
      Returns:
      the address set
    • checkValueDomain

      static <A, T> PcodeExecutorStatePiece<A,T> checkValueDomain(PcodeExecutorStatePiece<A,?> piece, Class<T> domain)
      Check that the given piece has a required value domain
      Type Parameters:
      A - the piece's address domain
      T - the piece's value domain
      Parameters:
      piece - the piece
      domain - the required value domain
      Returns:
      the piece cast to the required value domain if it matched, or null if the piece has a different value domain.
    • dataWritten

      default <A, T> void dataWritten(PcodeExecutorStatePiece<A,T> piece, AddressSpace space, A offset, int length, T value)
      Data was written into the given state piece (abstract addressing.)
      Type Parameters:
      A - the piece's address domain
      T - the piece's value domain
      Parameters:
      piece - the state piece
      space - the address space of the operand
      offset - the offset of the operand
      length - the size of the operand
      value - the value written
    • delegateDataWritten

      default <A, T> void delegateDataWritten(PcodeExecutorStatePiece<A,T> piece, AddressSpace space, A offset, int length, T value)
      Typically used from within dataWritten(PcodeExecutorStatePiece, AddressSpace, Object, int, Object) to forward the call to the callback for concrete addressing dataWritten(PcodeExecutorStatePiece, Address, int, Object).
      Type Parameters:
      A - the piece's address domain
      T - the piece's value domain
      Parameters:
      piece - the state piece
      space - the address space of the operand
      offset - the offset of the operand
      length - the size of the operand
      value - the value written
    • dataWritten

      default <A, T> void dataWritten(PcodeExecutorStatePiece<A,T> piece, Address address, int length, T value)
      Data was written into the given state piece (concrete addressing).
      Type Parameters:
      A - the piece's address domain
      T - the piece's value domain
      Parameters:
      piece - the state piece
      address - the address of the operand
      length - the size of the operand
      value - the value written
    • delegateDataWritten

      default <A, T> void delegateDataWritten(PcodeExecutorStatePiece<A,T> piece, Address address, int length, T value)
      Typically used from within dataWritten(PcodeExecutorStatePiece, Address, int, Object) to forward the call to the callback for abstract addressing dataWritten(PcodeExecutorStatePiece, AddressSpace, Object, int, Object).
      Type Parameters:
      A - the piece's address domain
      T - the piece's value domain
      Parameters:
      piece - the state piece
      address - the address of the operand
      length - the size of the operand
      value - the value written
    • readUninitialized

      default <A, T> int readUninitialized(PcodeExecutorStatePiece<A,T> piece, AddressSpace space, A offset, int length)
      The executor is preparing to read from uninitialized portions of the given state piece (abstract addressing).

      This callback provides an opportunity for something to initialize the required portion lazily. In most cases, this should either return 0 indicating the requested portion remains uninitialized, or the full length indicating the full requested portion is now initialized. If, for some reason, the requested portion could only be partially initialized, this can return a smaller length. Partial initializations are only recognized from the starting offset. Other parts could be initialized; however, there is no mechanism for communicating that result to the executor.

      Type Parameters:
      A - the piece's address domain
      T - the piece's value domain
      Parameters:
      piece - the state piece
      space - the address space of the operand
      offset - the offset of the operand
      length - the size of the operand
      Returns:
      the length of the operand just initialized, typically 0 or length
    • delegateReadUninitialized

      default <A, T> int delegateReadUninitialized(PcodeExecutorStatePiece<A,T> piece, AddressSpace space, A offset, int length)
      Type Parameters:
      A - the piece's address domain
      T - the piece's value domain
      Parameters:
      piece - the state piece
      space - the address space of the operand
      offset - the offset of the operand
      length - the size of the operand
      Returns:
      the length of the operand just initialized, typically 0 or length
    • readUninitialized

      default <A, T> AddressSetView readUninitialized(PcodeExecutorStatePiece<A,T> piece, AddressSetView set)
      The executor is preparing to read from uninitialized portions of the given state piece (concrete addressing).

      This callback provides an opportunity for something to initialize the required portion lazily. This method must return the address set that remains uninitialized. If no part of the required portion was initialized, this should return set identically, so that the caller can quickly recognize that nothing has changed. Otherwise, this should copy set, remove those parts it was able to initialize, and return the copy. DO NOT modify the given set.

      Type Parameters:
      A - the piece's address domain
      T - the piece's value domain
      Parameters:
      piece - the state piece
      set - the uninitialized portion required
      Returns:
      the addresses in set that remain uninitialized
    • delegateReadUninitialized

      default <A, T> AddressSetView delegateReadUninitialized(PcodeExecutorStatePiece<A,T> piece, AddressSetView set)
      Type Parameters:
      A - the piece's address domain
      T - the piece's value domain
      Parameters:
      piece - the state piece
      set - the uninitialized portion required
      Returns:
      the addresses in set that remain uninitialized