Package ghidra.trace.model.listing

# Interface TraceCodeManager

All Superinterfaces:
  `TraceCodeOperations`

All Known Implementing Classes:
  `DBTraceCodeManager`

public interface TraceCodeManager extends TraceCodeOperations
The manager for trace code units, i.e., the equivalent of `Listing`

This supports a "fluent" interface, which differs from `Listing`. For example, instead of `Listing.getInstructionContaining(Address)`, a client would invoke `TraceCodeOperations.instructions()` then `TraceBaseCodeUnitsView.getContaining(long, Address)`. Because traces include register spaces, this chain could be preceded by `getCodeSpace(AddressSpace, boolean)` or `getCodeRegisterSpace(TraceThread, int, boolean)`.

To create an instruction, see `TraceInstructionsView.create(Lifespan, Address, TracePlatform, InstructionPrototype, ProcessorContextView, int)`. Since clients do not ordinarily have an `InstructionPrototype` in hand, the more common method is to invoke the `Disassembler` on `Trace.getProgramView()`.

To create a data unit, see `TraceDefinedDataView.create(Lifespan, Address, DataType, int)`. The method chain to create a data unit in memory is `TraceCodeOperations.definedData()` then `create(...)`. The method chain to create a data unit on a register is `getCodeRegisterSpace(TraceThread, int, boolean)`, then `TraceCodeOperations.definedData()`, then `TraceDefinedDataView.create(Lifespan, Register, DataType)`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `AddressSetView`
  `getCodeAdded(long from, long to)`
  Query for the address set where code units have been added between the two given snaps
  `TraceCodeSpace`
  `getCodeRegisterSpace(TraceStackFrame frame, boolean createIfAbsent)`
  Get the code space for registers of the given stack frame
  `TraceCodeSpace`
  `getCodeRegisterSpace(TraceThread thread, boolean createIfAbsent)`
  Get the code space for registers of the given thread's innermost frame
  `TraceCodeSpace`
  `getCodeRegisterSpace(TraceThread thread, int frameLevel, boolean createIfAbsent)`
  Get the code space for registers of the given thread and frame
  `AddressSetView`
  `getCodeRemoved(long from, long to)`
  Query for the address set where code units have been removed between the two given snaps
  `TraceCodeSpace`
  `getCodeSpace(AddressSpace space, boolean createIfAbsent)`
  Get the code space for the memory of the given address space

  ### Methods inherited from interface ghidra.trace.model.listing.TraceCodeOperations

  `codeUnits, data, definedData, definedUnits, instructions, undefinedData`

- ## Method Details

  - ### getCodeSpace

    TraceCodeSpace getCodeSpace(AddressSpace space, boolean createIfAbsent)
    Get the code space for the memory of the given address space
    Parameters:
      `space` - the address space
      `createIfAbsent` - true to create the space if it's not already present
    Returns:
      the space, of `null` if absent and not created

  - ### getCodeRegisterSpace

    TraceCodeSpace getCodeRegisterSpace(TraceThread thread, boolean createIfAbsent)
    Get the code space for registers of the given thread's innermost frame
    Parameters:
      `thread` - the thread
      `createIfAbsent` - true to create the space if it's not already present
    Returns:
      the space, of `null` if absent and not created

  - ### getCodeRegisterSpace

    TraceCodeSpace getCodeRegisterSpace(TraceThread thread, int frameLevel, boolean createIfAbsent)
    Get the code space for registers of the given thread and frame
    Parameters:
      `thread` - the thread
      `frameLevel` - the frame (0 for innermost)
      `createIfAbsent` - true to create the space if it's not already present
    Returns:
      the space, of `null` if absent and not created

  - ### getCodeRegisterSpace

    TraceCodeSpace getCodeRegisterSpace(TraceStackFrame frame, boolean createIfAbsent)
    Get the code space for registers of the given stack frame

    Note this is simply a shortcut for `getCodeRegisterSpace(TraceThread, int, boolean)`, and does not in any way bind the space to the lifetime of the given frame. Nor, if the frame is moved, will this space move with it.

    Parameters:
      `frame` - the frame whose space to get
      `createIfAbsent` - true to create the space if it's not already present
    Returns:
      the space, or `null` if absent and not created

  - ### getCodeAdded

    AddressSetView getCodeAdded(long from, long to)
    Query for the address set where code units have been added between the two given snaps
    Parameters:
      `from` - the beginning snap
      `to` - the ending snap
    Returns:
      the view of addresses where units have been added

  - ### getCodeRemoved

    AddressSetView getCodeRemoved(long from, long to)
    Query for the address set where code units have been removed between the two given snaps
    Parameters:
      `from` - the beginning snap
      `to` - the ending snap
    Returns:
      the view of addresses where units have been removed