Package ghidra.pcode.exec.trace

# Interface TraceEmulationIntegration.Writer

All Superinterfaces:
  `PcodeEmulationCallbacks<Object>`

All Known Implementing Classes:
  `TraceEmulationIntegration.TraceWriter`

Enclosing class:
  `TraceEmulationIntegration`

public static interface TraceEmulationIntegration.Writer extends PcodeEmulationCallbacks<Object>
The primary mechanism for integrating emulators and traces

This implements callbacks for the emulator and provides a method for recording logged writes after some number of emulation steps. The client must pass this writer in as the callbacks and then later invoke `writeDown(PcodeTraceAccess)`. This also permits the addition of state piece handlers via `putHandler(PieceHandler)`, should the emulator be operating on other value domains.

- ## Nested Class Summary

  ## Nested classes/interfaces inherited from interface ghidra.pcode.emu.PcodeEmulationCallbacks

  `PcodeEmulationCallbacks.NoPcodeEmulationCallbacks, PcodeEmulationCallbacks.Wrapper<T>`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `default <T> PcodeEmulationCallbacks<T>`
  `callbacks()`
  Cast this writer to fit the emulator's value domain
  `void`
  `putHandler(TraceEmulationIntegration.PieceHandler<?,?> handler)`
  Add or replace a handler
  `void`
  `writeDown(long snap)`
  Record state changes into the trace at the given snapshot.
  `void`
  `writeDown(PcodeTraceAccess into)`
  Record state changes into the trace via the given access shim

  ### Methods inherited from interface ghidra.pcode.emu.PcodeEmulationCallbacks

  `afterBranch, afterExecuteInject, afterExecuteInstruction, afterLoad, afterStepOp, afterStore, beforeDecodeInstruction, beforeExecuteInject, beforeExecuteInstruction, beforeLoad, beforeStepOp, beforeStore, dataWritten, dataWritten, delegateDataWritten, delegateDataWritten, delegateReadUninitialized, delegateReadUninitialized, emulatorCreated, getInject, handleMissingUserop, readUninitialized, readUninitialized, sharedStateCreated, threadCreated, wrapFor`

- ## Method Details

  - ### writeDown

    void writeDown(PcodeTraceAccess into)
    Record state changes into the trace via the given access shim
    Parameters:
      `into` - the access shim

  - ### writeDown

    void writeDown(long snap)
    Record state changes into the trace at the given snapshot.

    The destination trace is the same as from the source access shim.

    Parameters:
      `snap` - the destination snapshot key

  - ### putHandler

    void putHandler(TraceEmulationIntegration.PieceHandler<?,?> handler)
    Add or replace a handler

    The handler must identify the address and value domains for which it is applicable. If there is already a handler for the same domains, the old handler is replaced by this one. Otherwise, this handler is added without removing any others. The handler is invoked if and only if the emulator's state contains a piece for the same domains. Otherwise, the handler may be silently ignored.

    Parameters:
      `handler` - the handler

  - ### callbacks

    default <T> PcodeEmulationCallbacks<T> callbacks()
    Cast this writer to fit the emulator's value domain

    Use this as the callbacks parameter when constructing the trace-integrated emulator. We assert this cast is safe, because none of the callbacks actually depend on the emulator's value domain. Instead, the states are accessed generically and invocations doled out to respective `TraceEmulationIntegration.PieceHandler`s based on their applicable domain types.

    Type Parameters:
      `T` - the emulator's value domain
    Returns:
      this