Package ghidra.trace.database.module

# Class DBTraceStaticMappingManager

java.lang.Object
ghidra.trace.database.module.DBTraceStaticMappingManager

All Implemented Interfaces:
  `ErrorHandler`, `DBTraceManager`, `TraceStaticMappingManager`

public class DBTraceStaticMappingManager extends Object implements TraceStaticMappingManager, DBTraceManager

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected final DBHandle`
  `dbh`
  `protected final ReadWriteLock`
  `lock`
  `protected final DBCachedObjectIndex<Address,DBTraceStaticMapping>`
  `mappingsByAddress`
  `protected final DBCachedObjectStore<DBTraceStaticMapping>`
  `mappingStore`
  `protected final DBTraceOverlaySpaceAdapter`
  `overlayAdapter`
  `protected final DBTrace`
  `trace`
  `protected final Collection<DBTraceStaticMapping>`
  `view`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `DBTraceStaticMappingManager(DBHandle dbh, OpenMode openMode, ReadWriteLock lock, TaskMonitor monitor, DBTrace trace, DBTraceOverlaySpaceAdapter overlayAdapter)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `DBTraceStaticMapping`
  `add(AddressRange range, Lifespan lifespan, URL toProgramURL, String toAddress)`
  Add a new mapping, if not already covered
  `void`
  `dbError(IOException e)`
  Notification that an IO exception occurred.
  `void`
  `delete(DBTraceStaticMapping mapping)`
  `Collection<? extends DBTraceStaticMapping>`
  `findAllOverlapping(AddressRange range, Lifespan lifespan)`
  Find all mappings which overlap the given adddress range and span of time
  `DBTraceStaticMapping`
  `findAnyConflicting(AddressRange range, Lifespan lifespan, URL toProgramURL, String toAddress)`
  Check if another mapping would conflict with the given prospective mapping
  `DBTraceStaticMapping`
  `findContaining(Address address, long snap)`
  Find any mapping applicable to the given snap and address
  `Collection<? extends DBTraceStaticMapping>`
  `getAllEntries()`
  Get all mappings in the manager
  `void`
  `invalidateCache(boolean all)`
  Invalidate this manager's caches

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### dbh

    protected final DBHandle dbh

  - ### lock

    protected final ReadWriteLock lock

  - ### trace

    protected final DBTrace trace

  - ### overlayAdapter

    protected final DBTraceOverlaySpaceAdapter overlayAdapter

  - ### mappingStore

    protected final DBCachedObjectStore<DBTraceStaticMapping> mappingStore

  - ### mappingsByAddress

    protected final DBCachedObjectIndex<Address,DBTraceStaticMapping> mappingsByAddress

  - ### view

    protected final Collection<DBTraceStaticMapping> view

- ## Constructor Details

  - ### DBTraceStaticMappingManager

    public DBTraceStaticMappingManager(DBHandle dbh, OpenMode openMode, ReadWriteLock lock, TaskMonitor monitor, DBTrace trace, DBTraceOverlaySpaceAdapter overlayAdapter) throws VersionException, IOException
    Throws:
      `VersionException`
      `IOException`

- ## Method Details

  - ### invalidateCache

    public void invalidateCache(boolean all)
    Description copied from interface: `DBTraceManager`
    Invalidate this manager's caches
    Specified by:
      `invalidateCache` in interface `DBTraceManager`
    Parameters:
      `all` - probably nothing. Check out implementations of `ManagerDB.invalidateCache(boolean)`.

  - ### dbError

    public void dbError(IOException e)
    Description copied from interface: `ErrorHandler`
    Notification that an IO exception occurred.
    Specified by:
      `dbError` in interface `ErrorHandler`
    Parameters:
      `e` - `IOException` which was cause of error

  - ### add

    public DBTraceStaticMapping add(AddressRange range, Lifespan lifespan, URL toProgramURL, String toAddress) throws TraceConflictedMappingException
    Description copied from interface: `TraceStaticMappingManager`
    Add a new mapping, if not already covered

    A new mapping may overlap an existing mapping, so long as they agree in address shift. Furthermore, in such cases, the implementation may coalesce mappings to remove duplication.

    Specified by:
      `add` in interface `TraceStaticMappingManager`
    Parameters:
      `range` - the range in the trace ("from")
      `lifespan` - the span of time in the trace
      `toProgramURL` - the (Ghidra) URL of the static image ("to")
      `toAddress` - the starting address (in string form) in the static image ("to")
    Returns:
      the new entry, or any entry which subsumes the specified mapping
    Throws:
      `TraceConflictedMappingException` - if an existing mapping conflicts. See `TraceStaticMappingManager.findAnyConflicting(AddressRange, Lifespan, URL, String)`

  - ### getAllEntries

    public Collection<? extends DBTraceStaticMapping> getAllEntries()
    Description copied from interface: `TraceStaticMappingManager`
    Get all mappings in the manager
    Specified by:
      `getAllEntries` in interface `TraceStaticMappingManager`
    Returns:
      the collection of mappings

  - ### findContaining

    public DBTraceStaticMapping findContaining(Address address, long snap)
    Description copied from interface: `TraceStaticMappingManager`
    Find any mapping applicable to the given snap and address
    Specified by:
      `findContaining` in interface `TraceStaticMappingManager`
    Parameters:
      `address` - the address
      `snap` - the snap
    Returns:
      the mapping, or `null` if none exist at the given location

  - ### findAnyConflicting

    public DBTraceStaticMapping findAnyConflicting(AddressRange range, Lifespan lifespan, URL toProgramURL, String toAddress)
    Description copied from interface: `TraceStaticMappingManager`
    Check if another mapping would conflict with the given prospective mapping

    Mappings are allowed to overlap, but they must agree on the destination program and address throughout all overlapping portions.

    TODO: It'd be nice if the manager automatically merged overlapping mappings in agreement or provided a "de-duplicate" method which optimized the entries in the database. This gets complicated, since we're dealing with overlapping rectangles, not strict one-dimensional ranges. Look into existing research for optimizing coverage of shapes by rectangles. The same is needed for property maps in 2 dimensions.

    Specified by:
      `findAnyConflicting` in interface `TraceStaticMappingManager`
    Parameters:
      `range` - the range in the trace ("from")
      `lifespan` - the span of time in the trace
      `toProgramURL` - the (Ghidra) URL of the static image ("to")
      `toAddress` - the starting address (in string form) in the static image ("to")
    Returns:
      a conflicting mapping, or `null` if none exist

  - ### findAllOverlapping

    public Collection<? extends DBTraceStaticMapping> findAllOverlapping(AddressRange range, Lifespan lifespan)
    Description copied from interface: `TraceStaticMappingManager`
    Find all mappings which overlap the given adddress range and span of time

    Note, this returns overlapping entries whether or not they conflict.

    Specified by:
      `findAllOverlapping` in interface `TraceStaticMappingManager`
    Parameters:
      `range` - the range in the trace ("from")
      `lifespan` - the span of time in the trace
    Returns:
      an unmodifiable collection of overlapped entries

  - ### delete

    public void delete(DBTraceStaticMapping mapping)