Class DBTraceTimeManager

java.lang.Object
ghidra.trace.database.time.DBTraceTimeManager
All Implemented Interfaces:
ErrorHandler, DBTraceManager, TraceTimeManager

public class DBTraceTimeManager extends Object implements TraceTimeManager, DBTraceManager
  • Field Details

  • Constructor Details

  • Method Details

    • 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
    • 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).
    • notifySnapshotAdded

      protected void notifySnapshotAdded(DBTraceSnapshot snapshot)
    • notifySnapshotChanged

      protected void notifySnapshotChanged(DBTraceSnapshot snapshot)
    • notifySnapshotDeleted

      protected void notifySnapshotDeleted(DBTraceSnapshot snapshot)
    • createSnapshot

      public DBTraceSnapshot createSnapshot(String description)
      Description copied from interface: TraceTimeManager
      Create a new snapshot after the latest
      Specified by:
      createSnapshot in interface TraceTimeManager
      Parameters:
      description - a description of the new snapshot, i.e., the reason for advancing
      Returns:
      the created snapshot
    • getSnapshot

      public DBTraceSnapshot getSnapshot(long snap, boolean createIfAbsent)
      Description copied from interface: TraceTimeManager
      Get the snapshot with the given key, optionally creating it
      Specified by:
      getSnapshot in interface TraceTimeManager
      Parameters:
      snap - the snapshot key
      createIfAbsent - create the snapshot if it's missing
      Returns:
      the snapshot or null
    • getMostRecentSnapshot

      public DBTraceSnapshot getMostRecentSnapshot(long snap)
      Description copied from interface: TraceTimeManager
      Get the most recent snapshot since a given key
      Specified by:
      getMostRecentSnapshot in interface TraceTimeManager
      Parameters:
      snap - the snapshot key
      Returns:
      the snapshot or null
    • getSnapshotsWithSchedule

      public Collection<? extends TraceSnapshot> getSnapshotsWithSchedule(TraceSchedule schedule)
      Description copied from interface: TraceTimeManager
      Get all snapshots with the given schedule

      Ideally, the snapshot schedules should be managed such that the returned collection contains at most one snapshot.

      Specified by:
      getSnapshotsWithSchedule in interface TraceTimeManager
      Parameters:
      schedule - the schedule to find
      Returns:
      the snapshots
    • findScratchSnapshot

      public TraceSnapshot findScratchSnapshot(TraceSchedule schedule)
      Description copied from interface: TraceTimeManager
      Find or create a the snapshot with the given schedule

      If a snapshot with the given schedule already exists, this returns the first such snapshot found. Ideally, there is exactly one. If this method is consistently used for creating scratch snapshots, then that should always be the case. If no such snapshot exists, this creates a snapshot with the minimum available negative snapshot key, that is starting at Long.MIN_VALUE and increasing from there.

      Specified by:
      findScratchSnapshot in interface TraceTimeManager
      Parameters:
      schedule - the schedule to find
      Returns:
      the snapshot
    • doGetValidSnapshotBySchedule

      protected DBTraceSnapshot doGetValidSnapshotBySchedule(String key, long version)
    • doFindNearest

      protected DBTraceSnapshot doFindNearest(TraceSchedule schedule, long version)
    • findSnapshotWithNearestPrefix

      public TraceSnapshot findSnapshotWithNearestPrefix(TraceSchedule schedule)
      Find the nearest related snapshot whose schedule is a prefix of the given schedule

      This finds a snapshot that can be used as the initial state of an emulator to materialize the state at the given schedule. The one it returns is the one that would require the fewest instruction steps. Note that since an emulator cannot be initialized into the middle of an instruction, snapshots whose schedules contain p-code op steps are ignored. Additionally, this will ignore any snapshots whose version is less than the emulator cache version.

      Specified by:
      findSnapshotWithNearestPrefix in interface TraceTimeManager
      Parameters:
      schedule - the desired schedule
      Returns:
      the found snapshot, or null
      See Also:
      Implementation Notes:
      Because the index is lexicographic, we have to hack a bit. Consider that 20 would come before 3 in the index. That said, all the steps leading up to the last would have to be equal for it to be a prefix, so I don't think any weird lexicographic stuff comes into play except in the final step., Even if the index were numeric, we have to worry about non-related schedules appearing between related ones, e.g., 0:t0-2, 0:t0-3;t1-1, when searching for 0:t0-4.
    • getAllSnapshots

      public Collection<? extends DBTraceSnapshot> getAllSnapshots()
      Description copied from interface: TraceTimeManager
      List all snapshots in the trace
      Specified by:
      getAllSnapshots in interface TraceTimeManager
      Returns:
      the set of snapshots
    • getSnapshots

      public Collection<? extends DBTraceSnapshot> getSnapshots(long fromSnap, boolean fromInclusive, long toSnap, boolean toInclusive)
      Description copied from interface: TraceTimeManager
      List all snapshots between two given snaps in the trace
      Specified by:
      getSnapshots in interface TraceTimeManager
      Parameters:
      fromSnap - the starting snap
      fromInclusive - whether to include the from snap
      toSnap - the ending snap
      toInclusive - when to include the to snap
      Returns:
      the set of snapshots
    • getMaxSnap

      public Long getMaxSnap()
      Description copied from interface: TraceTimeManager
      Get maximum snapshot key that has ever existed, usually that of the latest snapshot Note, the corresponding snapshot need not exist, as it may have been deleted.
      Specified by:
      getMaxSnap in interface TraceTimeManager
      Returns:
      the key, or null if no snapshots have existed
    • getSnapshotCount

      public long getSnapshotCount()
      Description copied from interface: TraceTimeManager
      Get the number of snapshots
      Specified by:
      getSnapshotCount in interface TraceTimeManager
      Returns:
      the count
    • deleteSnapshot

      public void deleteSnapshot(DBTraceSnapshot snapshot)
    • setTimeRadix

      public void setTimeRadix(TraceSchedule.TimeRadix radix)
      Description copied from interface: TraceTimeManager
      Set the radix for displaying and parsing time (snapshots and step counts)

      This only affects the GUI, but storing it in the trace gives the back end a means of controlling it.

      Specified by:
      setTimeRadix in interface TraceTimeManager
      Parameters:
      radix - the radix
    • getTimeRadix

      public TraceSchedule.TimeRadix getTimeRadix()
      Description copied from interface: TraceTimeManager
      Get the radix for displaying and parsing time (snapshots and step counts)
      Specified by:
      getTimeRadix in interface TraceTimeManager
      Returns:
      radix the radix
      See Also: