Interface DBTraceCodeUnitAdapter
- All Superinterfaces:
CodeUnit,MemBuffer,MemBufferMixin,PropertySet,TraceCodeUnit
- All Known Subinterfaces:
DBTraceDataAdapter,DBTraceDefinedDataAdapter
- All Known Implementing Classes:
AbstractDBTraceCodeUnit,AbstractDBTraceDataComponent,AbstractDBTraceProgramViewListing.DBTraceProgramViewUndefinedData,DBTraceData,DBTraceDataArrayElementComponent,DBTraceDataCompositeFieldComponent,DBTraceInstruction,UndefinedDBTraceData
TraceCodeUnit
This behaves somewhat like a mixin, allowing it to be used on code units as well as data components, e.g., fields of a struct data unit.
-
Field Summary
Fields inherited from interface ghidra.program.model.listing.CodeUnit
COMMENT_PROPERTY, DEFINED_DATA_PROPERTY, EOL_COMMENT, INSTRUCTION_PROPERTY, MNEMONIC, PLATE_COMMENT, POST_COMMENT, PRE_COMMENT, REPEATABLE_COMMENT, SPACE_PROPERTY -
Method Summary
Modifier and TypeMethodDescriptiondefault voidaddMnemonicReference(Address refAddr, RefType refType, SourceType sourceType) Add a reference to the mnemonic for this code unit.default voidaddOperandReference(int index, Address refAddr, RefType type, SourceType sourceType) Add a memory reference to the operand at the given index.default intCompares the given address to the address range of this node.default booleanReturns true if address is contained in the range of this codeUnit.default AddressSpacedefault StringgetAddressString(boolean showBlockName, boolean pad) Get the string representation of the starting address for this code unit.default byte[]getBytes()Get the bytes that make up this code unit.default voidgetBytesInCodeUnit(byte[] buffer, int bufferOffset) Copies max(buffer.length, code unit length) bytes into buffer starting at the given offset inbuffer.default StringgetComment(CommentType commentType) Get the comment for the given typedefault String[]getCommentAsArray(CommentType commentType) Get the comment for the given type and parse it into an array of strings such that each line is its own string.default ExternalReferencegetExternalReference(int opIndex) Gets the external reference (if any) at the opIndexdefault intgetIntProperty(String name) Get the int property for name.default StringgetLabel()Returns the label for this code unit..default MemoryGet the Memory object actually used by the MemBuffer.default AddressReturns the starting address for this code unit..default DBTraceReference[]Get references for the mnemonic for this code unit.default SaveablegetObjectProperty(String name) Get the object property for name; returns null if there is no name property for this code unit.default DBTraceReference[]getOperandReferences(int index) Returns the references for the operand index..default DBTraceReferencegetPrimaryReference(int index) Returns the primary reference for the operand index..default SymbolReturns the Primary Symbol for this code unit..default TraceProgramViewReturns the program that generated this CodeUnit..default <T> TgetProperty(String name, Class<T> valueClass) Get a property having the given typedefault ReferenceIteratorReturns an iterator over all references TO this code unit..default DBTraceReference[]Get ALL memory references FROM this code unit.default StringgetStringProperty(String name) Get the string property for name; returns null if there is no name property for this code unit.default Symbol[]Returns the Symbols for this code unit..getTrace()Get the trace in which this code unit existsdefault booleangetVoidProperty(String name) Returns whether this code unit is marked as having the name property.default booleanhasProperty(String name) Returns true if the codeunit has the given property defined.default booleanReturns true if the underlying bytes are in big-endian order, false if they are little endian.Get an iterator over the property names which have values applied.default voidremoveExternalReference(int opIndex) Remove external reference (if any) at the given opIndexdefault voidremoveMnemonicReference(Address refAddr) Remove a reference to the mnemonic for this code unit.default voidremoveOperandReference(int index, Address refAddr) Remove a reference to the operand.default voidremoveProperty(String name) Remove the property value associated with the given name .default voidsetComment(CommentType commentType, String comment) Set the comment for the given comment type.default voidsetCommentAsArray(CommentType commentType, String[] comment) Set the comment (with each line in its own string) for the given comment typedefault voidSets a memory reference to be the primary reference at its address/opIndex location.default voidsetProperty(String name) Set the named property.default voidsetProperty(String name, int value) Set the named integer property with the given value.default voidsetProperty(String name, Saveable value) Set the named property with the givenSaveablevalue.default <T> voidsetProperty(String name, Class<T> valueClass, T value) Set a property of the given type to the given valuedefault voidsetProperty(String name, String value) Set the named string property with the given value.default voidsetRegisterReference(int opIndex, Register reg, SourceType sourceType, RefType refType) Sets a register reference at theoffseton the specified operand index, which effectively substitutes the previous operation interpretation
NOTE: If another reference was previously set on the operand, then it will be replaced with this register referencedefault voidsetStackReference(int opIndex, int offset, SourceType sourceType, RefType refType) Sets a stack reference at theoffseton the specified operand index, which effectively substitutes the previous operation interpretation
NOTE: If another reference was previously set on the operand, then it will be replaced with this stack referencedefault <T,U extends T>
voidsetTypedProperty(String name, T value) Set a property having the same type as the given valueMethods inherited from interface ghidra.program.model.listing.CodeUnit
getAddress, getComment, getCommentAsArray, getLength, getMaxAddress, getMnemonicString, getNumOperands, getScalar, setComment, setCommentAsArrayMethods inherited from interface ghidra.program.model.mem.MemBuffer
getAddress, getInputStream, getInputStream, getUnsignedByte, getUnsignedInt, getUnsignedShort, getVarLengthInt, getVarLengthUnsignedInt, isInitializedMemoryMethods inherited from interface ghidra.program.model.mem.MemBufferMixin
getBigInteger, getByte, getBytes, getBytes, getBytesInFull, getInt, getLong, getShortMethods inherited from interface ghidra.trace.model.listing.TraceCodeUnit
delete, getBounds, getBytes, getEndSnap, getLanguage, getLifespan, getPlatform, getRange, getStartSnap, getThread, setEndSnap
-
Method Details
-
getTrace
DBTrace getTrace()Description copied from interface:TraceCodeUnitGet the trace in which this code unit exists- Specified by:
getTracein interfaceTraceCodeUnit- Returns:
- the trace
-
getProgram
Description copied from interface:CodeUnitReturns the program that generated this CodeUnit..- Specified by:
getProgramin interfaceCodeUnit- Specified by:
getProgramin interfaceTraceCodeUnit- Returns:
- the program that generated this CodeUnit.
-
getAddressString
Description copied from interface:CodeUnitGet the string representation of the starting address for this code unit.- Specified by:
getAddressStringin interfaceCodeUnit- Parameters:
showBlockName- true if the string should include the memory block namepad- if true, the address will be padded with leading zeros. Even if pad is false, the string will be padded to make the address string contain at least 4 digits.- Returns:
- string representation of address
-
getAddressSpace
-
setProperty
Description copied from interface:TraceCodeUnitSet a property of the given type to the given valueThis method is preferred to
TraceCodeUnit.setTypedProperty(String, Object), because in the case the property map does not already exist, the desired type is given explicitly.While it is best practice to match
valueClassexactly with the type of the map, this method will work so long as the givenvalueClassis a subtype of the map's type. If the property map does not already exist, it is created with the givenvalueClass. Note that there is no established mechanism for restoring values of a subtype from the underlying database.Currently, the only supported types are
Integer,String,Void, and subtypes ofSaveable.- Specified by:
setPropertyin interfaceTraceCodeUnit- Parameters:
name- the name of the propertyvalueClass- the type of the propertyvalue- the value of the property
-
setTypedProperty
Description copied from interface:TraceCodeUnitSet a property having the same type as the given valueIf the named property has a super-type of the value's type, the value is accepted. If not, a
TypeMismatchExceptionis thrown. If the property map does not already exist, it is created having exactly the type of the given value.This method exists for two reasons: 1) To introduce the type variable U, which is more existential, and 2) to remove the requirement to subtype
Saveable. Otherwise, this method is identical in operation toPropertySet.setProperty(String, Saveable).- Specified by:
setTypedPropertyin interfaceTraceCodeUnit- Parameters:
name- the name of the propertyvalue- the value of the property
-
setProperty
Description copied from interface:PropertySetSet the named property with the givenSaveablevalue.- Specified by:
setPropertyin interfacePropertySet- Parameters:
name- the name of the property.value- value to be stored.
-
setProperty
Description copied from interface:PropertySetSet the named string property with the given value.- Specified by:
setPropertyin interfacePropertySet- Parameters:
name- the name of the property.value- value to be stored.
-
setProperty
Description copied from interface:PropertySetSet the named integer property with the given value.- Specified by:
setPropertyin interfacePropertySet- Parameters:
name- the name of the property.value- value to be stored.
-
setProperty
Description copied from interface:PropertySetSet the named property. This method is used for "void" properites. The property is either set or not set - there is no value- Specified by:
setPropertyin interfacePropertySet- Parameters:
name- the name of the property.
-
getProperty
Description copied from interface:TraceCodeUnitGet a property having the given typeIf the named property has a sub-type of the given
valueClass, the value (possiblynull) is returned. If the property does not exist,nullis returned. OtherwiseTypeMismatchExceptionis thrown, even if the property is not set at this unit's address.Note that getting a
Voidproperty will always returnnull. UsePropertySet.getVoidProperty(String)instead to detect if the property is set.PropertySet.hasProperty(String)will also work, but it does not verify that the property's type is actuallyVoid.- Specified by:
getPropertyin interfaceTraceCodeUnit- Parameters:
name- the name of the propertyvalueClass- the expected type of the value (or a super-type thereof)- Returns:
- the value of the property, or
null
-
getObjectProperty
Description copied from interface:PropertySetGet the object property for name; returns null if there is no name property for this code unit.- Specified by:
getObjectPropertyin interfacePropertySet- Parameters:
name- the name of the property- Returns:
Saveableproperty value, with map-specific implementation class, or null.
-
getStringProperty
Description copied from interface:PropertySetGet the string property for name; returns null if there is no name property for this code unit.- Specified by:
getStringPropertyin interfacePropertySet- Parameters:
name- the name of the property- Returns:
- string property value or null
-
getIntProperty
Description copied from interface:PropertySetGet the int property for name.- Specified by:
getIntPropertyin interfacePropertySet- Parameters:
name- the name of the property- Returns:
- integer property value property has been set
- Throws:
NoValueException- if there is not name property for this code unit
-
hasProperty
Description copied from interface:PropertySetReturns true if the codeunit has the given property defined. This method works for all property map types.- Specified by:
hasPropertyin interfacePropertySet- Parameters:
name- the name of the property- Returns:
- true if property has been set, else false
-
getVoidProperty
Description copied from interface:PropertySetReturns whether this code unit is marked as having the name property.- Specified by:
getVoidPropertyin interfacePropertySet- Parameters:
name- the name of the property- Returns:
- true if property has been set, else false
-
propertyNames
Description copied from interface:PropertySetGet an iterator over the property names which have values applied.- Specified by:
propertyNamesin interfacePropertySet- Returns:
- iterator of all property map names which have values applied
-
removeProperty
Description copied from interface:PropertySetRemove the property value associated with the given name .- Specified by:
removePropertyin interfacePropertySet- Parameters:
name- the name of the property
-
getLabel
Description copied from interface:CodeUnitReturns the label for this code unit.. -
getSymbols
Description copied from interface:CodeUnitReturns the Symbols for this code unit..- Specified by:
getSymbolsin interfaceCodeUnit- Returns:
- the Symbols for this code unit.
-
getPrimarySymbol
Description copied from interface:CodeUnitReturns the Primary Symbol for this code unit..- Specified by:
getPrimarySymbolin interfaceCodeUnit- Returns:
- the Primary Symbol for this code unit.
-
getMinAddress
Description copied from interface:CodeUnitReturns the starting address for this code unit..- Specified by:
getMinAddressin interfaceCodeUnit- Returns:
- the starting address for this code unit.
-
setComment
Description copied from interface:CodeUnitSet the comment for the given comment type. Passingnullclears the comment- Specified by:
setCommentin interfaceCodeUnit- Parameters:
commentType-comment typecomment- comment for code unit; null clears the comment
-
getComment
Description copied from interface:CodeUnitGet the comment for the given type- Specified by:
getCommentin interfaceCodeUnit- Parameters:
commentType-comment type- Returns:
- the comment string of the appropriate type or null if no comment of that type exists for this code unit
-
setCommentAsArray
Description copied from interface:CodeUnitSet the comment (with each line in its own string) for the given comment type- Specified by:
setCommentAsArrayin interfaceCodeUnit- Parameters:
commentType-comment typecomment- an array of strings where each string is a single line of the comment.
-
getCommentAsArray
Description copied from interface:CodeUnitGet the comment for the given type and parse it into an array of strings such that each line is its own string.- Specified by:
getCommentAsArrayin interfaceCodeUnit- Parameters:
commentType-comment type- Returns:
- an array of strings where each item in the array is a line of text in the comment. If there is no comment of the requested type, an empty array is returned.
-
contains
Description copied from interface:CodeUnitReturns true if address is contained in the range of this codeUnit. -
compareTo
Description copied from interface:CodeUnitCompares the given address to the address range of this node. -
addMnemonicReference
Description copied from interface:CodeUnitAdd a reference to the mnemonic for this code unit.- Specified by:
addMnemonicReferencein interfaceCodeUnit- Parameters:
refAddr- address to add as a reference.refType- the type of reference to add.sourceType- the source of this reference
-
addOperandReference
Description copied from interface:CodeUnitAdd a memory reference to the operand at the given index.- Specified by:
addOperandReferencein interfaceCodeUnit- Parameters:
index- operand indexrefAddr- reference addresstype- the reference type to be added.sourceType- the source of this reference
-
setPrimaryMemoryReference
Description copied from interface:CodeUnitSets a memory reference to be the primary reference at its address/opIndex location. The primary reference is the one that is used in the getOperandRepresentation() method.- Specified by:
setPrimaryMemoryReferencein interfaceCodeUnit- Parameters:
ref- the reference to be set as primary.
-
setStackReference
Description copied from interface:CodeUnitSets a stack reference at theoffseton the specified operand index, which effectively substitutes the previous operation interpretation
NOTE: If another reference was previously set on the operand, then it will be replaced with this stack reference- Specified by:
setStackReferencein interfaceCodeUnit- Parameters:
opIndex- the index of the operand to set this stack referenceoffset- the (+/-) offset from stack base addresssourceType- the source of this referencerefType- type of reference, RefType.READ,WRITE,PTR...
-
setRegisterReference
default void setRegisterReference(int opIndex, Register reg, SourceType sourceType, RefType refType) Description copied from interface:CodeUnitSets a register reference at theoffseton the specified operand index, which effectively substitutes the previous operation interpretation
NOTE: If another reference was previously set on the operand, then it will be replaced with this register reference- Specified by:
setRegisterReferencein interfaceCodeUnit- Parameters:
opIndex- the index of the operand to set this register referencereg- a registersourceType- the source of this referencerefType- type of reference, RefType.READ,WRITE,PTR...
-
getMnemonicReferences
Description copied from interface:CodeUnitGet references for the mnemonic for this code unit.- Specified by:
getMnemonicReferencesin interfaceCodeUnit- Specified by:
getMnemonicReferencesin interfaceTraceCodeUnit- Returns:
- an array of memory references. A zero length array will be returned if there are no references for the mnemonic.
-
getOperandReferences
Description copied from interface:CodeUnitReturns the references for the operand index..- Specified by:
getOperandReferencesin interfaceCodeUnit- Specified by:
getOperandReferencesin interfaceTraceCodeUnit- Parameters:
index- operand index (0 is the first operand)- Returns:
- the references for the operand index.
-
getPrimaryReference
Description copied from interface:CodeUnitReturns the primary reference for the operand index..- Specified by:
getPrimaryReferencein interfaceCodeUnit- Specified by:
getPrimaryReferencein interfaceTraceCodeUnit- Parameters:
index- operand index (0 is the first operand)- Returns:
- the primary reference for the operand index.
-
getReferencesFrom
Description copied from interface:CodeUnitGet ALL memory references FROM this code unit.- Specified by:
getReferencesFromin interfaceCodeUnit- Specified by:
getReferencesFromin interfaceTraceCodeUnit- Returns:
- an array of memory references from this codeUnit or an empty array if there are no references.
-
getReferenceIteratorTo
Description copied from interface:CodeUnitReturns an iterator over all references TO this code unit..- Specified by:
getReferenceIteratorToin interfaceCodeUnit- Returns:
- an iterator over all references TO this code unit.
-
getExternalReference
Description copied from interface:CodeUnitGets the external reference (if any) at the opIndex- Specified by:
getExternalReferencein interfaceCodeUnit- Parameters:
opIndex- the operand index to look for external references- Returns:
- the external reference at the operand or null if none exists.
-
removeMnemonicReference
Description copied from interface:CodeUnitRemove a reference to the mnemonic for this code unit.- Specified by:
removeMnemonicReferencein interfaceCodeUnit- Parameters:
refAddr- the address to remove as a reference.
-
removeOperandReference
Description copied from interface:CodeUnitRemove a reference to the operand.- Specified by:
removeOperandReferencein interfaceCodeUnit- Parameters:
index- operand indexrefAddr- address referencing the operand
-
removeExternalReference
default void removeExternalReference(int opIndex) Description copied from interface:CodeUnitRemove external reference (if any) at the given opIndex- Specified by:
removeExternalReferencein interfaceCodeUnit- Parameters:
opIndex- the index of the operand from which to remove any external reference.
-
getMemory
Description copied from interface:MemBufferGet the Memory object actually used by the MemBuffer. -
isBigEndian
default boolean isBigEndian()Description copied from interface:MemBufferReturns true if the underlying bytes are in big-endian order, false if they are little endian.- Specified by:
isBigEndianin interfaceMemBuffer- Returns:
- true if the underlying bytes are in big-endian order, false if they are little endian.
-
getBytes
Description copied from interface:CodeUnitGet the bytes that make up this code unit. NOTE: If aninstruction length-overrideis set this method will not return all bytes associated with theinstruction prototype.- Specified by:
getBytesin interfaceCodeUnit- Returns:
- an array of bytes that are in memory at the codeunits address. The array length is the same as the codeUnits length
- Throws:
MemoryAccessException- if the full number of bytes could not be read.
-
getBytesInCodeUnit
Description copied from interface:CodeUnitCopies max(buffer.length, code unit length) bytes into buffer starting at the given offset inbuffer.- Specified by:
getBytesInCodeUnitin interfaceCodeUnit- Parameters:
buffer- byte array to copy intobufferOffset- offset in byte array the copy will start- Throws:
MemoryAccessException- if the full number of bytes could not be read.
-