Class DBTraceTimeViewport
- All Implemented Interfaces:
TraceTimeViewport
This is used primarily by the TraceProgramView implementation to resolve most-recent
objects according to a layering or forking structure given in snapshot schedules. This listens on
the given trace for changes in snapshot schedules and keeps an up-to-date set of visible (or
potentially-visible) ranges from the given snap.
TODO: Because complicated forking structures are not anticipated, some minimal effort is given to cull meaningless changes, but in general, changes cause a complete re-computation of the viewport. If complex, deep forking structures prove to be desirable, then this is an area for optimization.
-
Nested Class Summary
Nested classes/interfaces inherited from interface ghidra.trace.model.TraceTimeViewport
TraceTimeViewport.Occlusion<T>, TraceTimeViewport.QueryOcclusion<T>, TraceTimeViewport.RangeQueryOcclusion<T>, TraceTimeViewport.SetQueryOcclusion<T> -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ListenerSet<Runnable> NB: This is also the syncing object for the viewport.protected longprotected final Lifespan.MutableLifeSetprotected final Trace -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a listener for when the forking structure of this viewport changesprotected static booleanaddSnapRange(long lower, long upper, Lifespan.MutableLifeSet spanSet, List<Lifespan> ordered) protected booleancheckSnapshotAddedNeedsRefresh(TraceSnapshot snapshot) protected booleanprotected booleanprotected static voidcollectForkRanges(TraceTimeManager timeManager, long curSnap, Lifespan.MutableLifeSet spanSet, List<Lifespan> ordered) Construct the ranges (set and ordered)<T> AddressSetcomputeVisibleParts(AddressSetView set, Lifespan lifespan, T object, TraceTimeViewport.Occlusion<T> occlusion) Compute the parts of a given object that are visible past more-recent objectsbooleancontainsAnyUpper(Lifespan range) Check if the given lifespan contains any upper snap among the involved spansGet the snaps involved in the view in most-recent-first orderGet the spans involved in the view in most-recent-first ordergetOrderedSpans(long snap) Get the snaps involved in the view in least-recent-first orderGet the spans involved in the view in least-recent-first order<T> TGet the first non-null result of the function, applied to the most-recent snaps first<T> booleanisCompletelyVisible(AddressRange range, Lifespan lifespan, T object, TraceTimeViewport.Occlusion<T> occlusion) Check if any part of the given object is occluded by more-recent objectsbooleanisForked()Check if this view is forkedprotected booleanisLower(long lower) protected static TraceSnapshotlocateMostRecentFork(TraceTimeManager timeManager, long from) <T> Iterator<T> mergedIterator(Function<Long, Iterator<T>> iterFunc, Comparator<? super T> comparator) Merge iterators from each involved snap into a single iteratorprotected voidvoidRemove a listener for forking structure changesvoidsetSnap(long snap) Set the snapshot for this viewportunionedAddresses(Function<Long, AddressSetView> viewFunc) Union address sets from each involved snapprotected voidupdateSnapshotAdded(TraceSnapshot snapshot) protected voidupdateSnapshotChanged(TraceSnapshot snapshot) protected voidupdateSnapshotDeleted(TraceSnapshot snapshot)
-
Field Details
-
trace
-
ordered
NB: This is also the syncing object for the viewport. If there's even a chance an operation may need the DB's lock, esp., considering user callbacks, then it must first acquire the DB lock. -
spanSet
-
changeListeners
-
snap
protected long snap
-
-
Constructor Details
-
DBTraceTimeViewport
-
-
Method Details
-
addChangeListener
Description copied from interface:TraceTimeViewportAdd a listener for when the forking structure of this viewport changesThis can occur when the snap changes or when any snapshot involved changes
- Specified by:
addChangeListenerin interfaceTraceTimeViewport- Parameters:
l- the listener
-
removeChangeListener
Description copied from interface:TraceTimeViewportRemove a listener for forking structure changes- Specified by:
removeChangeListenerin interfaceTraceTimeViewport- Parameters:
l- the listener- See Also:
-
containsAnyUpper
Description copied from interface:TraceTimeViewportCheck if the given lifespan contains any upper snap among the involved spans- Specified by:
containsAnyUpperin interfaceTraceTimeViewport- Parameters:
range- the lifespan to consider- Returns:
- true if it contains any upper snap, false otherwise.
-
isCompletelyVisible
public <T> boolean isCompletelyVisible(AddressRange range, Lifespan lifespan, T object, TraceTimeViewport.Occlusion<T> occlusion) Description copied from interface:TraceTimeViewportCheck if any part of the given object is occluded by more-recent objects- Specified by:
isCompletelyVisiblein interfaceTraceTimeViewport- Type Parameters:
T- the type of the object- Parameters:
range- the address range of the objectlifespan- the lifespan of the objectobject- optionally, the object to examine. Used to avoid "self occlusion"occlusion- a mechanism for querying other like objects and checking for occlusion- Returns:
- true if completely visible, false if even partially occluded
-
computeVisibleParts
public <T> AddressSet computeVisibleParts(AddressSetView set, Lifespan lifespan, T object, TraceTimeViewport.Occlusion<T> occlusion) Description copied from interface:TraceTimeViewportCompute the parts of a given object that are visible past more-recent objects- Specified by:
computeVisiblePartsin interfaceTraceTimeViewport- Type Parameters:
T- the type of the object- Parameters:
set- the addresses comprising the objectlifespan- the lifespan of the objectobject- the object to examineocclusion- a mechanism for query other like objects and removing occluded parts- Returns:
- the set of visible addresses
-
isLower
protected boolean isLower(long lower) -
addSnapRange
protected static boolean addSnapRange(long lower, long upper, Lifespan.MutableLifeSet spanSet, List<Lifespan> ordered) -
locateMostRecentFork
-
collectForkRanges
protected static void collectForkRanges(TraceTimeManager timeManager, long curSnap, Lifespan.MutableLifeSet spanSet, List<Lifespan> ordered) Construct the ranges (set and ordered)NOTE: I cannot hold the lock during this, because I also require the DB's read lock. There are other operations, e.g., addRegion, that will hold the DB's write lock, and then also require the viewport's lock to check if it is visible. That would cause the classic tango of death.
- Parameters:
curSnap- the seed snap
-
refreshSnapRanges
protected void refreshSnapRanges() -
setSnap
public void setSnap(long snap) Description copied from interface:TraceTimeViewportSet the snapshot for this viewport- Specified by:
setSnapin interfaceTraceTimeViewport- Parameters:
snap- the snap
-
updateSnapshotAdded
-
updateSnapshotChanged
-
updateSnapshotDeleted
-
checkSnapshotAddedNeedsRefresh
-
checkSnapshotChangedNeedsRefresh
-
checkSnapshotDeletedNeedsRefresh
-
isForked
public boolean isForked()Description copied from interface:TraceTimeViewportCheck if this view is forkedThe view is considered forked if any snap previous to this has a schedule with an initial snap other than the immediately-preceding one. Such forks "break" the linearity of the trace's usual time line.
- Specified by:
isForkedin interfaceTraceTimeViewport- Returns:
- true if forked, false otherwise
-
getOrderedSpans
Description copied from interface:TraceTimeViewportGet the spans involved in the view in most-recent-first order- Specified by:
getOrderedSpansin interfaceTraceTimeViewport- Returns:
- the list of spans
-
getReversedSpans
Description copied from interface:TraceTimeViewportGet the spans involved in the view in least-recent-first order- Specified by:
getReversedSpansin interfaceTraceTimeViewport- Returns:
- the list of spans
-
getOrderedSpans
-
getOrderedSnaps
Description copied from interface:TraceTimeViewportGet the snaps involved in the view in most-recent-first orderThe first is always this view's snap. Following are the source snaps of each previous snapshot's schedule where applicable.
- Specified by:
getOrderedSnapsin interfaceTraceTimeViewport- Returns:
- the list of snaps
-
getReversedSnaps
Description copied from interface:TraceTimeViewportGet the snaps involved in the view in least-recent-first order- Specified by:
getReversedSnapsin interfaceTraceTimeViewport- Returns:
- the list of snaps
-
getTop
Description copied from interface:TraceTimeViewportGet the first non-null result of the function, applied to the most-recent snaps firstTypically, func both retrieves an object and tests for its suitability.
- Specified by:
getTopin interfaceTraceTimeViewport- Type Parameters:
T- the type of object to retrieve- Parameters:
func- the function on a snap to retrieve an object- Returns:
- the first non-null result
-
mergedIterator
public <T> Iterator<T> mergedIterator(Function<Long, Iterator<T>> iterFunc, Comparator<? super T> comparator) Description copied from interface:TraceTimeViewportMerge iterators from each involved snap into a single iteratorTypically, the resulting iterator is passed through a filter to test each objects suitability.
- Specified by:
mergedIteratorin interfaceTraceTimeViewport- Type Parameters:
T- the type of objects in each iterator- Parameters:
iterFunc- a function on a snap to retrieve each iteratorcomparator- the comparator for merging, which must yield the same order as each iterator- Returns:
- the merged iterator
-
unionedAddresses
Description copied from interface:TraceTimeViewportUnion address sets from each involved snapThe returned union is computed lazily.
- Specified by:
unionedAddressesin interfaceTraceTimeViewport- Parameters:
viewFunc- a function on a snap to retrieve the address set- Returns:
- the union
-