Class DBTraceCodeManager
- All Implemented Interfaces:
ErrorHandler,DBTraceManager,DBTraceDelegatingManager<DBTraceCodeSpace>,TraceCodeManager,TraceCodeOperations
TraceCodeManager for DBTrace
The "fluent" interfaces actually create quite a burden to implement here; however, we have some
opportunity to extract common code among the various views. There are a few concepts and nuances
to consider in order to handle all the fluent cases. The manager implements
TraceCodeOperations directly, which means it must provide a version of each
TraceCodeUnitsView that composes all memory address spaces. These are named with the
suffix MemoryView and extend AbstractBaseDBTraceCodeUnitsMemoryView.
In addition, in order to support getCodeSpace(AddressSpace, boolean), it must provide a
version of each that can be bound to a single memory address space. Same for
getCodeRegisterSpace(TraceThread, int, boolean). These are named with the suffix
View and extend AbstractBaseDBTraceCodeUnitsView.
Furthermore, there are three types of views:
- Those defined by a table, i.e., defined data and instructions. These extend
AbstractBaseDBTraceDefinedUnitsView. - Those defined implicitly, but may have a support table, i.e., undefined units. This is
implemented by
DBTraceUndefinedDataView. - Those defined as the composition of others, i.e., data and defined units. These extend
AbstractComposedDBTraceCodeUnitsView.
The first two types represent a view of a single code unit type, so they both extend
AbstractSingleDBTraceCodeUnitsView.
The abstract classes do not nominally implement the trace manager's
TraceBaseCodeUnitsView nor TraceBaseDefinedUnitsView interfaces, because Java
prevents the (nominal) implementation of the same interface with different type parameters by the
same class. E.g., DBTraceDataView would inherit
TraceBaseCodeUnitsView<DBTraceData> via AbstractBaseDBTraceCodeUnitsView, but
also TraceBaseCodeUnitsView<TraceDataUnit> via TraceDataView. Instead, the
abstract classes structurally implement those interfaces, meaning they implement the
methods required by the interface, but without naming the interface in their `implements` clause.
The realizations, e.g., DBTraceDataView, nominally implement their corresponding
interfaces, meaning they do name the interface. Each realization will inherit the structural
implementation from the abstract classes, satisfying the requirements imposed by nominally
implementing the interface.
Note, as a result, navigating from declarations in the interfaces to implementations in abstract classes using your IDE may not work as expected :/ . The best way is probably to display the type hierarchy of the interface declaring the desired method. Open one of the classes implementing it, then display all its methods, including those inherited, and search for desired method.
Here is the type hierarchy presented with notes regarding structural interface implementations:
AbstractBaseDBTraceCodeUnitsViewstructurally implementsTraceBaseCodeUnitsViewAbstractComposedDBTraceCodeUnitsViewDBTraceCodeUnitsViewnominally implementsTraceCodeUnitsViewDBTraceDataViewnominally implementsTraceDataViewDBTraceDefinedUnitsViewnominally implementsTraceDefinedUnitsView
AbstractSingleDBTraceCodeUnitsViewAbstractBaseDBTraceDefinedUnitsViewstructurally implementsTraceBaseDefinedUnitsViewDBTraceDefinedDataViewnominally implementsTraceDefinedDataViewDBTraceInstructionsViewnominally implementsTraceInstructionsView
DBTraceUndefinedDataViewnominally implementsTraceUndefinedDataView
The view composition is not hierarchical, as each may represent a different combination, and one type may appear in several compositions. The single-type views are named first, then the composed views:
- Instructions - single-type view
- Defined Data - single-type view
- Undefined Data - single-type view
Note that while the API presents separate views for defined data and undefined units, both are
represented by the type TraceData. Meaning, a client with a data unit in hand cannot
determine whether it is defined or undefined from its type alone. It must invoke
Data.isDefined() instead. While the implementation provides a separate type, which we see
mirrors the hierarchy of the views' implementation, the client interfaces do not.
- Code Units - Instructions, Defined Data, Undefined Data
- Data - Defined Data, Undefined Data
- Defined Units - Instructions, Defined Data
The MemoryView classes compose the memory address spaces into a single view. These need
not mirror the same implementation hierarchy as the views they compose. Other than special
handling for compositions including undefined units, each memory view need not know anything
about the views it composes. There are two abstract classes:
AbstractBaseDBTraceCodeUnitsMemoryView, which is suitable for composing views without
undefined units, and AbstractWithUndefinedDBTraceCodeUnitsMemoryView, which extends the
base making it suitable for composing views with undefined units. The realizations each extend
from the appropriate abstract class. Again, the abstract classes do not nominally implement
TraceBaseCodeUnitsView. They structurally implement it, partly satisfying the
requirements on the realizations, which nominally implement their appropriate interfaces.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA prototype entryNested classes/interfaces inherited from class ghidra.trace.database.space.AbstractDBTraceSpaceBasedManager
AbstractDBTraceSpaceBasedManager.DBTraceSpaceEntryNested classes/interfaces inherited from interface ghidra.trace.database.space.DBTraceDelegatingManager
DBTraceDelegatingManager.ExcConsumer<T,E extends Throwable>, DBTraceDelegatingManager.ExcFunction<T, R, E extends Throwable>, DBTraceDelegatingManager.ExcPredicate<T, E extends Throwable>, DBTraceDelegatingManager.ExcSupplier<T, E extends Throwable> -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final DBTraceCodeUnitsMemoryViewprotected final DBTraceDataMemoryViewprotected final DBTraceDataTypeManagerprotected final DBTraceDefinedDataMemoryViewprotected final DBTraceDefinedUnitsMemoryViewprotected final Map<InstructionPrototype, DBTraceCodeManager.DBTraceCodePrototypeEntry> protected final DBTraceInstructionsMemoryViewstatic final Stringprotected final DBTraceOverlaySpaceAdapterprotected final DBTracePlatformManagerprotected final DBCachedObjectStore<DBTraceCodeManager.DBTraceCodePrototypeEntry> protected final DBTraceReferenceManagerprotected final Map<AddressSnap, UndefinedDBTraceData> protected final DBTraceUndefinedDataMemoryViewFields inherited from class ghidra.trace.database.space.AbstractDBTraceSpaceBasedManager
baseLanguage, dbh, lock, name, NO_ADDRESS_SPACE, regSpacesByContainer, spaces, spaceStore, spacesView, threadManager, trace -
Constructor Summary
ConstructorsConstructorDescriptionDBTraceCodeManager(DBHandle dbh, OpenMode openMode, ReadWriteLock lock, TaskMonitor monitor, Language baseLanguage, DBTrace trace, DBTraceThreadManager threadManager, DBTracePlatformManager platformManager, DBTraceDataTypeManager dataTypeManager, DBTraceOverlaySpaceAdapter overlayAdapter, DBTraceReferenceManager referenceManager) -
Method Summary
Modifier and TypeMethodDescriptionvoidclearData(Set<Long> deletedDataTypeIds, TaskMonitor monitor) voidclearPlatform(Lifespan span, AddressRange range, DBTraceGuestPlatform guest, TaskMonitor monitor) Get a view of all the code units in the listingprotected DBTraceCodeSpacedata()Get a view of only the data units (defined and undefined) in the listingGet a view of only the defined data units in the listingGet a view of only the defined units (data and instructions) in the listingvoiddeleteLangauge(DBTraceGuestPlatform.DBTraceGuestLanguage guest, TaskMonitor monitor) voiddeletePlatform(DBTraceGuestPlatform guest, TaskMonitor monitor) doCreateUndefinedUnit(long snap, Address address, TraceThread thread, int frameLevel) doRecordPrototype(InstructionPrototype prototype, DBTraceGuestPlatform.DBTraceGuestLanguage guest, MemBuffer memBuffer, ProcessorContextView context) findOrRecordPrototype(InstructionPrototype prototype, DBTraceGuestPlatform.DBTraceGuestLanguage guest, MemBuffer memBuffer, ProcessorContextView context) getCodeAdded(long from, long to) Query for the address set where code units have been added between the two given snapsgetCodeRegisterSpace(TraceStackFrame frame, boolean createIfAbsent) Get the code space for registers of the given stack framegetCodeRegisterSpace(TraceThread thread, boolean createIfAbsent) Get the code space for registers of the given thread's innermost framegetCodeRegisterSpace(TraceThread thread, int frameLevel, boolean createIfAbsent) Get the code space for registers of the given thread and framegetCodeRemoved(long from, long to) Query for the address set where code units have been removed between the two given snapsgetCodeSpace(AddressSpace space, boolean createIfAbsent) Get the code space for the memory of the given address spacegetForSpace(AddressSpace space, boolean createIfAbsent) protected InstructionPrototypegetPrototypeByKey(int key) protected static AddressinstructionMax(Instruction instruction, boolean includeDelays) Get a view of only the instructions in the listingvoidinvalidateCache(boolean all) Invalidate this manager's cachesprotected voidreadLock()voidreplaceDataTypes(Map<Long, Long> dataTypeReplacementMap) Get a view of only the undefined data units in the listingprotected byte[]Methods inherited from class ghidra.trace.database.space.AbstractDBTraceSpaceBasedManager
dbError, get, getActiveSpaces, getBaseLanguage, getForRegisterSpace, getForRegisterSpace, getForRegisterSpace, getLock, getSpaceByName, getTabledSpaces, getTrace, loadSpaces, tableNameMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ghidra.trace.database.space.DBTraceDelegatingManager
checkIsInMemory, delegateAddressSet, delegateAny, delegateCollection, delegateDeleteB, delegateDeleteV, delegateFirst, delegateHashSet, delegateRead, delegateRead, delegateReadB, delegateReadI, delegateReadI, delegateReadOr, delegateWrite, delegateWriteAll, delegateWriteI, delegateWriteV
-
Field Details
-
NAME
- See Also:
-
platformManager
-
dataTypeManager
-
overlayAdapter
-
referenceManager
-
protoStore
-
entriesByProto
protected final Map<InstructionPrototype,DBTraceCodeManager.DBTraceCodePrototypeEntry> entriesByProto -
codeUnits
-
instructions
-
data
-
definedData
-
undefinedData
-
definedUnits
-
undefinedCache
-
-
Constructor Details
-
DBTraceCodeManager
public DBTraceCodeManager(DBHandle dbh, OpenMode openMode, ReadWriteLock lock, TaskMonitor monitor, Language baseLanguage, DBTrace trace, DBTraceThreadManager threadManager, DBTracePlatformManager platformManager, DBTraceDataTypeManager dataTypeManager, DBTraceOverlaySpaceAdapter overlayAdapter, DBTraceReferenceManager referenceManager) throws IOException, VersionException - Throws:
IOExceptionVersionException
-
-
Method Details
-
instructionMax
protected static Address instructionMax(Instruction instruction, boolean includeDelays) throws AddressOverflowException - Throws:
AddressOverflowException
-
doCreateUndefinedUnit
public UndefinedDBTraceData doCreateUndefinedUnit(long snap, Address address, TraceThread thread, int frameLevel) -
loadPrototypes
protected void loadPrototypes() -
valueBytes
-
doRecordPrototype
protected DBTraceCodeManager.DBTraceCodePrototypeEntry doRecordPrototype(InstructionPrototype prototype, DBTraceGuestPlatform.DBTraceGuestLanguage guest, MemBuffer memBuffer, ProcessorContextView context) -
findOrRecordPrototype
protected DBTraceCodeManager.DBTraceCodePrototypeEntry findOrRecordPrototype(InstructionPrototype prototype, DBTraceGuestPlatform.DBTraceGuestLanguage guest, MemBuffer memBuffer, ProcessorContextView context) -
getPrototypeByKey
-
createSpace
protected DBTraceCodeSpace createSpace(AddressSpace space, AbstractDBTraceSpaceBasedManager.DBTraceSpaceEntry ent) throws VersionException, IOException - Specified by:
createSpacein classAbstractDBTraceSpaceBasedManager<DBTraceCodeSpace>- Throws:
VersionExceptionIOException
-
getForSpace
- Specified by:
getForSpacein interfaceDBTraceDelegatingManager<DBTraceCodeSpace>- Overrides:
getForSpacein classAbstractDBTraceSpaceBasedManager<DBTraceCodeSpace>
-
readLock
- Specified by:
readLockin interfaceDBTraceDelegatingManager<DBTraceCodeSpace>
-
writeLock
- Specified by:
writeLockin interfaceDBTraceDelegatingManager<DBTraceCodeSpace>
-
getCodeSpace
Description copied from interface:TraceCodeManagerGet the code space for the memory of the given address space- Specified by:
getCodeSpacein interfaceTraceCodeManager- Parameters:
space- the address spacecreateIfAbsent- true to create the space if it's not already present- Returns:
- the space, of
nullif absent and not created
-
getCodeRegisterSpace
Description copied from interface:TraceCodeManagerGet the code space for registers of the given thread's innermost frame- Specified by:
getCodeRegisterSpacein interfaceTraceCodeManager- Parameters:
thread- the threadcreateIfAbsent- true to create the space if it's not already present- Returns:
- the space, of
nullif absent and not created
-
getCodeRegisterSpace
public DBTraceCodeSpace getCodeRegisterSpace(TraceThread thread, int frameLevel, boolean createIfAbsent) Description copied from interface:TraceCodeManagerGet the code space for registers of the given thread and frame- Specified by:
getCodeRegisterSpacein interfaceTraceCodeManager- Parameters:
thread- the threadframeLevel- the frame (0 for innermost)createIfAbsent- true to create the space if it's not already present- Returns:
- the space, of
nullif absent and not created
-
getCodeRegisterSpace
Description copied from interface:TraceCodeManagerGet the code space for registers of the given stack frameNote this is simply a shortcut for
TraceCodeManager.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.- Specified by:
getCodeRegisterSpacein interfaceTraceCodeManager- Parameters:
frame- the frame whose space to getcreateIfAbsent- true to create the space if it's not already present- Returns:
- the space, or
nullif absent and not created
-
replaceDataTypes
-
clearData
-
clearPlatform
public void clearPlatform(Lifespan span, AddressRange range, DBTraceGuestPlatform guest, TaskMonitor monitor) throws CancelledException - Throws:
CancelledException
-
deletePlatform
public void deletePlatform(DBTraceGuestPlatform guest, TaskMonitor monitor) throws CancelledException - Throws:
CancelledException
-
deleteLangauge
public void deleteLangauge(DBTraceGuestPlatform.DBTraceGuestLanguage guest, TaskMonitor monitor) throws CancelledException - Throws:
CancelledException
-
invalidateCache
public void invalidateCache(boolean all) Description copied from interface:DBTraceManagerInvalidate this manager's caches- Specified by:
invalidateCachein interfaceDBTraceManager- Overrides:
invalidateCachein classAbstractDBTraceSpaceBasedManager<DBTraceCodeSpace>- Parameters:
all- probably nothing. Check out implementations ofManagerDB.invalidateCache(boolean).
-
codeUnits
Description copied from interface:TraceCodeOperationsGet a view of all the code units in the listing- Specified by:
codeUnitsin interfaceTraceCodeOperations- Returns:
- the code-units view
-
instructions
Description copied from interface:TraceCodeOperationsGet a view of only the instructions in the listingThis view supports the creation of new instruction units. This view also supports clearing.
- Specified by:
instructionsin interfaceTraceCodeOperations- Returns:
- the instruction-units view
-
data
Description copied from interface:TraceCodeOperationsGet a view of only the data units (defined and undefined) in the listing- Specified by:
datain interfaceTraceCodeOperations- Returns:
- the data-units view
-
definedData
Description copied from interface:TraceCodeOperationsGet a view of only the defined data units in the listingThis view supports the creation of new data units. This view also supports clearing.
- Specified by:
definedDatain interfaceTraceCodeOperations- Returns:
- the defined-data-units view
-
undefinedData
Description copied from interface:TraceCodeOperationsGet a view of only the undefined data units in the listing- Specified by:
undefinedDatain interfaceTraceCodeOperations- Returns:
- return the undefined-data-units view
-
definedUnits
Description copied from interface:TraceCodeOperationsGet a view of only the defined units (data and instructions) in the listingThis view support clearing.
- Specified by:
definedUnitsin interfaceTraceCodeOperations- Returns:
- the defined-units-view
-
getCodeAdded
Description copied from interface:TraceCodeManagerQuery for the address set where code units have been added between the two given snaps- Specified by:
getCodeAddedin interfaceTraceCodeManager- Parameters:
from- the beginning snapto- the ending snap- Returns:
- the view of addresses where units have been added
-
getCodeRemoved
Description copied from interface:TraceCodeManagerQuery for the address set where code units have been removed between the two given snaps- Specified by:
getCodeRemovedin interfaceTraceCodeManager- Parameters:
from- the beginning snapto- the ending snap- Returns:
- the view of addresses where units have been removed
-