Package ghidra.pcode.exec.trace.data

# Interface PcodeTraceAccess

All Known Subinterfaces:
  `PcodeDebuggerAccess`

All Known Implementing Classes:
  `AbstractPcodeTraceAccess`, `DefaultPcodeTraceAccess`

public interface PcodeTraceAccess
A trace access shim

This encapsulates the source or destination "coordinates" of a trace to simplify access to that trace by p-code operations. This is also meant to encapsulate certain conventions, e.g., writes are effective from the destination snapshot into the indefinite future, and meant to protect p-code executor/emulator states from future re-factorings of the Trace API.

While, technically anything can be behind the shim, the default implementations are backed by a trace. The shim is associated with a chosen platform and snapshot. All methods are with respect to that platform. In particular the addresses must all be in spaces of the platform's language. Note that the platform may be the trace's host platform.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `PcodeTraceAccess`
  `deriveForWrite(long snap)`
  Derive an access for writing a snapshot, where this access was the emulator's source
  `PcodeTraceRegistersAccess`
  `getDataForLocalState(PcodeThread<?> thread, int frame)`
  Get the data-access shim for use in an emulator thread's local state
  `PcodeTraceRegistersAccess`
  `getDataForLocalState(TraceThread thread, int frame)`
  Get the data-access shim for use in an emulator thread's local state
  `PcodeTraceMemoryAccess`
  `getDataForSharedState()`
  Get the data-access shim for use in an emulator's shared state
  `default PcodeTraceDataAccess`
  `getDataForThreadState(TraceThread thread, int frame)`
  Get the data-access shim for use in an executor having thread context
  `Language`
  `getLanguage()`
  Get the language of the associated platform
  `default PcodeTraceDataAccess`
  `newPcodeTraceThreadAccess(PcodeTraceMemoryAccess shared, PcodeTraceRegistersAccess local)`
  Construct a new trace thread data-access shim

- ## Method Details

  - ### deriveForWrite

    PcodeTraceAccess deriveForWrite(long snap)
    Derive an access for writing a snapshot, where this access was the emulator's source
    Parameters:
      `snap` - the destination snapshot key
    Returns:
      the derived access shim

  - ### getLanguage

    Language getLanguage()
    Get the language of the associated platform
    Returns:
      the langauge

  - ### getDataForSharedState

    PcodeTraceMemoryAccess getDataForSharedState()
    Get the data-access shim for use in an emulator's shared state
    Returns:
      the shim

  - ### getDataForLocalState

    PcodeTraceRegistersAccess getDataForLocalState(PcodeThread<?> thread, int frame)
    Get the data-access shim for use in an emulator thread's local state
    Parameters:
      `thread` - the emulator's thread
      `frame` - the frame, usually 0
    Returns:
      the shim

  - ### getDataForLocalState

    PcodeTraceRegistersAccess getDataForLocalState(TraceThread thread, int frame)
    Get the data-access shim for use in an emulator thread's local state
    Parameters:
      `thread` - the trace thread associated with the emulator's thread
      `frame` - the frame, usually 0
    Returns:
      the shim

  - ### newPcodeTraceThreadAccess

    default PcodeTraceDataAccess newPcodeTraceThreadAccess(PcodeTraceMemoryAccess shared, PcodeTraceRegistersAccess local)
    Construct a new trace thread data-access shim
    Parameters:
      `shared` - the shared (memory) state
      `local` - the local (register) state
    Returns:
      the thread data-access shim

  - ### getDataForThreadState

    default PcodeTraceDataAccess getDataForThreadState(TraceThread thread, int frame)
    Get the data-access shim for use in an executor having thread context

    NOTE: Do not use this shim for an emulator thread's local state. Use `getDataForLocalState(PcodeThread, int)` instead. This shim is meant for use in stand-alone executors, e.g., for evaluating Sleigh expressions. Most likely, the thread is the active thread in the UI.

    Parameters:
      `thread` - the trace thread for context, if applicable, or null
      `frame` - the frame
    Returns:
      the shim