Interface TraceMemoryManager
- All Superinterfaces:
TraceMemoryOperations
- All Known Implementing Classes:
DBTraceMemoryManager
The manager is not bound to any particular address space and may be used to access information
about any memory address. For register spaces, you must use
getMemoryRegisterSpace(TraceThread, int, boolean).
-
Method Summary
Modifier and TypeMethodDescriptiondefault TraceMemoryRegionaddRegion(String path, Lifespan lifespan, AddressRange range, TraceMemoryFlag... flags) addRegion(String path, Lifespan lifespan, AddressRange range, Collection<TraceMemoryFlag> flags) Add a new region with the given propertiescreateOverlayAddressSpace(String name, AddressSpace base) Create a new address space with the given name based upon the given spacedefault TraceMemoryRegioncreateRegion(String path, long snap, AddressRange range, TraceMemoryFlag... flags) default TraceMemoryRegioncreateRegion(String path, long snap, AddressRange range, Collection<TraceMemoryFlag> flags) Add a region created at the given snap, with no specified destruction snapvoidDelete an overlay address spaceCollection<? extends TraceMemoryRegion> Get all the regions in this space or managergetLiveRegionByPath(long snap, String path) Get the region with the given path at the given snapgetMemoryRegisterSpace(TraceStackFrame frame, boolean createIfAbsent) Obtain a "memory" space bound to the register address space for a stack framegetMemoryRegisterSpace(TraceThread thread, boolean createIfAbsent) Obtain a "memory" space bound to the register address space for frame 0 of a given threadgetMemoryRegisterSpace(TraceThread thread, int frame, boolean createIfAbsent) Obtain a "memory" space bound to the register address space for a given thread and stack framegetMemorySpace(AddressSpace space, boolean createIfAbsent) Obtain a memory space bound to a particular address spacegetOrCreateOverlayAddressSpace(String name, AddressSpace base) Get or create an overlay address spacegetRegionContaining(long snap, Address address) Get the region at the given address and snapgetRegionsAddressSet(long snap) Get the addresses contained by regions at the given snapgetRegionsAddressSetWith(long snap, Predicate<TraceMemoryRegion> predicate) Get the addresses contained by regions at the given snap satisfying the given predicateCollection<? extends TraceMemoryRegion> getRegionsAtSnap(long snap) Collect regions at the given snapCollection<? extends TraceMemoryRegion> getRegionsIntersecting(Lifespan lifespan, AddressRange range) Collect regions intersecting the given lifespan and rangegetStateChanges(long from, long to) Collect all the state changes between two given snapsMethods inherited from interface ghidra.trace.model.memory.TraceMemoryOperations
findBytes, getAddressesWithState, getAddressesWithState, getAddressesWithState, getAddressesWithState, getBlockSize, getBufferAt, getBufferAt, getBytes, getBytes, getBytes, getMostRecentStateEntry, getMostRecentStates, getMostRecentStates, getSnapOfMostRecentChangeToBlock, getState, getState, getState, getStates, getStates, getStates, getTrace, getValue, getValue, getViewBytes, getViewMostRecentStateEntry, getViewMostRecentStateEntry, getViewState, getViewValue, getViewValue, isKnown, pack, putBytes, putBytes, putBytes, removeBytes, removeValue, removeValue, setState, setState, setState, setState, setState, setState, setValue, setValue
-
Method Details
-
createOverlayAddressSpace
AddressSpace createOverlayAddressSpace(String name, AddressSpace base) throws DuplicateNameException Create a new address space with the given name based upon the given spaceThe purpose of overlay spaces in traces is often to store bytes for things other than memory or registers. Some targets may expose other byte-based storage, or provide alternative views of memory.
NOTE: This also provides a transitional piece for recording a model (sub)tree directly into a trace, without mapping to a Ghidra language first. As we experiment with that mode, we will likely instantiate traces with the "DATA:BE:64:default" language and generate an overlay space named after the path of each memory being recorded. Of course, the mapping still needs to occur between the trace and parts of the display and during emulation.
NOTE: We are also moving away from (space, thread, frame) triples to uniquely identify register storage. Instead, that will be encoded into the address space itself. Register overlays will overlay register space and be named after the register container object, which subsumes thread and frame when applicable.
- Parameters:
name- the name of the new address spacebase- the space after which this is modeled- Returns:
- the create space
- Throws:
DuplicateNameException- if an address space with the name already exists
-
getOrCreateOverlayAddressSpace
Get or create an overlay address spaceIf the space already exists, and it overlays the given base, the existing space is returned. If it overlays a different space, null is returned. If the space does not exist, it is created with the given base space.
- Parameters:
name- the name of the address spacebase- the expected base space- Returns:
- the space, or null
- See Also:
-
deleteOverlayAddressSpace
Delete an overlay address spaceTODO: At the moment, this will not destroy manager spaces created for the deleted address space. We should assess this behavior, esp. wrt. re-creating the address space later, and decide whether or not to clean up.
- Parameters:
name- the name of the address space to delete
-
addRegion
TraceMemoryRegion addRegion(String path, Lifespan lifespan, AddressRange range, Collection<TraceMemoryFlag> flags) throws TraceOverlappedRegionException Add a new region with the given propertiesRegions model the memory mappings of a debugging target. As such, they are never allowed to overlap. Additionally, to ensure
getLiveRegionByPath(long, String)returns a unique region, duplicate paths cannot exist in the same snap.Regions have a "full name" (path) as well as a short name. The path is immutable and can be used to reliably retrieve the same region later. The short name should be something suitable for display on the screen. Short names are mutable and can be -- but probbaly shouldn't be -- duplicated.
- Parameters:
path- the "full name" of the regionlifespan- the lifespan of the regionrange- the address range of the regionflags- the flags, e.g., permissions, of the region- Returns:
- the newly-added region
- Throws:
TraceOverlappedRegionException- if the specified region would overlap an existing one
-
addRegion
default TraceMemoryRegion addRegion(String path, Lifespan lifespan, AddressRange range, TraceMemoryFlag... flags) throws TraceOverlappedRegionException - Throws:
TraceOverlappedRegionException- See Also:
-
createRegion
default TraceMemoryRegion createRegion(String path, long snap, AddressRange range, Collection<TraceMemoryFlag> flags) throws TraceOverlappedRegionException, DuplicateNameException Add a region created at the given snap, with no specified destruction snap- Throws:
TraceOverlappedRegionExceptionDuplicateNameException- See Also:
-
createRegion
default TraceMemoryRegion createRegion(String path, long snap, AddressRange range, TraceMemoryFlag... flags) throws TraceOverlappedRegionException, DuplicateNameException - Throws:
TraceOverlappedRegionExceptionDuplicateNameException- See Also:
-
getAllRegions
Collection<? extends TraceMemoryRegion> getAllRegions()Get all the regions in this space or manager- Returns:
- the collection of all regions
-
getLiveRegionByPath
Get the region with the given path at the given snap- Parameters:
snap- the snap which must be within the region's lifespanpath- the "full name" of the region- Returns:
- the region, or
nullif no region matches
-
getRegionContaining
Get the region at the given address and snap- Parameters:
snap- the snap which must be within the region's lifespanaddress- the address which must be within the region's range- Returns:
- the region, or
nullif no region matches
-
getRegionsIntersecting
Collection<? extends TraceMemoryRegion> getRegionsIntersecting(Lifespan lifespan, AddressRange range) Collect regions intersecting the given lifespan and range- Parameters:
lifespan- the lifespanrange- the range- Returns:
- the collection of matching regions
-
getRegionsAtSnap
Collect regions at the given snap- Parameters:
snap- the snap which must be within the regions' lifespans- Returns:
- the collection of matching regions
-
getRegionsAddressSet
Get the addresses contained by regions at the given snapThe implementation may provide a view that updates with changes.
- Parameters:
snap- the snap which must be within the regions' lifespans- Returns:
- the union of ranges of matching regions
-
getRegionsAddressSetWith
Get the addresses contained by regions at the given snap satisfying the given predicateThe implementation may provide a view that updates with changes.
- Parameters:
snap- the snap which must be within the region's lifespanspredicate- a predicate on regions to search for- Returns:
- the address set
-
getMemorySpace
Obtain a memory space bound to a particular address space- Parameters:
space- the address spacecreateIfAbsent- true to create the space if it's not already present- Returns:
- the space, or
nullif absent and not created
-
getMemoryRegisterSpace
Obtain a "memory" space bound to the register address space for a given thread and stack frame- Parameters:
thread- the given threadframe- the "level" of the given stack frame. 0 is the innermost frame.createIfAbsent- true to create the space if it's not already present- Returns:
- the space, or
nullif absent and not created
-
getMemoryRegisterSpace
Obtain a "memory" space bound to the register address space for frame 0 of a given thread- Parameters:
thread- the given threadcreateIfAbsent- true to create the space if it's not already present- Returns:
- the space, or
nullif absent and not created - See Also:
-
getMemoryRegisterSpace
Obtain a "memory" space bound to the register address space for a stack frameNote this is simply a convenience, and does not in any way bind the space to the lifespan of the given frame. Nor, if the frame is moved, will this space move with it.
- Parameters:
frame- the stack framecreateIfAbsent- true to create the space if it's not already present- Returns:
- the space, or
nullif absent and not created - See Also:
-
getStateChanges
Collect all the state changes between two given snaps- Parameters:
from- the earlier snapto- the later snap- Returns:
- the collection of state changes
-