Class DefaultPcodeTraceThreadAccess

java.lang.Object
ghidra.pcode.exec.trace.data.DefaultPcodeTraceThreadAccess
All Implemented Interfaces:
PcodeTraceDataAccess, PcodeTraceMemoryAccess, PcodeTraceRegistersAccess

public class DefaultPcodeTraceThreadAccess extends Object implements PcodeTraceMemoryAccess, PcodeTraceRegistersAccess
The default data-access shim, for both memory and registers

This is not designed for use with the emulator, but rather with stand-alone p-code executors, e.g., to evaluate a Sleigh expression. It multiplexes a given memory access shim and another register access shim into a single shim for use in one state piece.

  • Field Details

  • Constructor Details

    • DefaultPcodeTraceThreadAccess

      protected DefaultPcodeTraceThreadAccess(PcodeTraceMemoryAccess memory, PcodeTraceRegistersAccess registers)
      Construct a shim
      Parameters:
      memory - the memory access shim
      registers - the regsiter access shim
  • Method Details

    • getLanguage

      public Language getLanguage()
      Description copied from interface: PcodeTraceDataAccess
      Get the language of the associated platform
      Specified by:
      getLanguage in interface PcodeTraceDataAccess
      Returns:
      the language
    • setState

      public void setState(AddressRange range, TraceMemoryState state)
      Description copied from interface: PcodeTraceDataAccess
      Set the memory state of an address range

      The state is set only for the destination snapshot. It is not effective for the indefinite future.

      Specified by:
      setState in interface PcodeTraceDataAccess
      Parameters:
      range - the range
      state - the desired state
    • getViewportState

      public TraceMemoryState getViewportState(AddressRange range)
      Description copied from interface: PcodeTraceDataAccess
      Get the composite state of an address range, using the snapshot's viewport

      Typically, the viewport is at most 2 snapshots deep. When reading from a captured snapshot, the viewport includes only the source snapshot. When reading from scratch snapshot (usually generated by emulation), the viewport includes that scratch snapshot and the original source snapshot. The TraceMemoryState.KNOWN address set is the union of known address sets among all snapshots in the viewport. If all addresses in the given range are TraceMemoryState.KNOWN, then the composite state is known. Otherwise, the composite state is TraceMemoryState.UNKNOWN.

      Specified by:
      getViewportState in interface PcodeTraceDataAccess
      Parameters:
      range - the range to check
      Returns:
      the composite state of the range
    • intersectViewKnown

      public AddressSetView intersectViewKnown(AddressSetView view, boolean useFullSpans)
      Description copied from interface: PcodeTraceDataAccess
      Compute the intersection of the given address set and the set of TraceMemoryState.KNOWN or (@link TraceMemoryState.ERROR memory
      Specified by:
      intersectViewKnown in interface PcodeTraceDataAccess
      Parameters:
      view - the address set
      useFullSpans - how to treat the viewport; true for ever known, false for known now.
      Returns:
      the intersection
    • intersectUnknown

      public AddressSetView intersectUnknown(AddressSetView view)
      Description copied from interface: PcodeTraceDataAccess
      Compute the intersection of the given address set and the set of TraceMemoryState.UNKNOWN memory
      Specified by:
      intersectUnknown in interface PcodeTraceDataAccess
      Parameters:
      view - the address set
      Returns:
      the intersection
    • putBytes

      public int putBytes(Address start, ByteBuffer buf)
      Description copied from interface: PcodeTraceDataAccess
      Write bytes into the trace

      Each written byte is effective for future snapshots up to but excluding the next snapshot where another byte is written at the same address.

      Specified by:
      putBytes in interface PcodeTraceDataAccess
      Parameters:
      start - the address of the first byte to write
      buf - a buffer of bytes to write
      Returns:
      the number of bytes written
    • getBytes

      public int getBytes(Address start, ByteBuffer buf)
      Description copied from interface: PcodeTraceDataAccess
      Read bytes from the trace
      Specified by:
      getBytes in interface PcodeTraceDataAccess
      Parameters:
      start - the address of the first byte to read
      buf - a buffer to receive the bytes
      Returns:
      the number of bytes read
    • translate

      public Address translate(Address address)
      Description copied from interface: PcodeTraceDataAccess
      Translate the given emulator address to a host/overlay address
      Specified by:
      translate in interface PcodeTraceDataAccess
      Parameters:
      address - the emulator address
      Returns:
      the host/overlay address
    • getPropertyAccess

      public <T> PcodeTracePropertyAccess<T> getPropertyAccess(String name, Class<T> type)
      Description copied from interface: PcodeTraceDataAccess
      Get a property-access shim for the named property
      Specified by:
      getPropertyAccess in interface PcodeTraceDataAccess
      Type Parameters:
      T - the type of the property's values
      Parameters:
      name - the name of the property
      type - the class of the property's values
      Returns:
      the access shim
    • initializeThreadContext

      public void initializeThreadContext(PcodeThread<?> thread)
      Description copied from interface: PcodeTraceRegistersAccess
      Initialize the given p-code thread's context register using register context from the trace at the thread's program counter

      This is called during thread construction, after the program counter is initialized from the same trace thread. This will ensure that the instruction decoder starts in the same mode as the disassembler was for the trace.

      Specified by:
      initializeThreadContext in interface PcodeTraceRegistersAccess
      Parameters:
      thread - the thread to initialize