Package ghidra.app.util
Class PseudoData
- java.lang.Object
-
- ghidra.app.util.PseudoData
-
-
Field Summary
Fields Modifier and Type Field Description protected Addressaddressprotected DataTypebaseDataTypeprotected byte[]bytesprotected java.util.Map<java.lang.Integer,java.lang.String>commentsprotected DataTypeManagerDBdataMgrprotected DataTypedataTypeprotected static Address[]emptyAddrArrayprotected static Reference[]emptyMemRefsprotected inthashprotected booleanisBigEndianprotected intlengthprotected intlevelprotected AddressmaxAddressprotected static intOP_INDEXprotected Programprogramprotected ReferenceManagerrefMgr-
Fields inherited from interface ghidra.program.model.listing.CodeUnit
COMMENT_PROPERTY, DEFINED_DATA_PROPERTY, EOL_COMMENT, INSTRUCTION_PROPERTY, MNEMONIC, NO_COMMENT, PLATE_COMMENT, POST_COMMENT, PRE_COMMENT, REPEATABLE_COMMENT, SPACE_PROPERTY
-
-
Constructor Summary
Constructors Constructor Description PseudoData(Address address, DataType dataType, MemBuffer memBuffer)PseudoData(Program program, Address address, DataType dataType, MemBuffer memBuffer)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddMnemonicReference(Address refAddr, RefType refType, SourceType sourceType)Add a reference to the mnemonic for this code unit.voidaddOperandReference(int opIndex, Address refAddr, RefType type, SourceType sourceType)Add a user defined reference to the operand at the given index.voidaddValueReference(Address refAddr, RefType type)Add a memory reference to the value.voidclearAllSettings()Removes all name-value pairs from this settings objectvoidclearSetting(java.lang.String name)Removes any value associated with the given nameintcompareTo(Address a)Compares the given address to the address range of this node.protected static intcomputeLength(DataType dataType, Address address)booleancontains(Address testAddr)Determines if this code unit contains the indicated address.booleanequals(java.lang.Object obj)AddressgetAddress()Get the Address which corresponds to the offset 0.AddressgetAddress(int opIndex)Get the Address for the given operand index if one exists.java.lang.StringgetAddressString(boolean showBlockName, boolean pad)Get the string representation of the starting address for this code unit.DataTypegetBaseDataType()If the dataType is a typeDef, then the typeDef's base type is returned, otherwise, the datatType is returned.protected static DataTypegetBaseDataType(DataType dataType)java.math.BigIntegergetBigInteger(int offset, int size, boolean signed)returns the value at the given offset, taking into account the endianess.bytegetByte(int offset)Get one byte from memory at the current position plus offset.byte[]getByteArray(java.lang.String name)Gets the byte[] value associated with the given namejava.lang.StringgetByteCodeString()byte[]getBytes()Gets the bytes for this code unit.intgetBytes(byte[] b, int offset)Readsb.lengthbytes from this memory buffer starting at the address of this memory buffer plus the given memoryBufferOffset from that position.voidgetBytesInCodeUnit(byte[] buffer, int bufferOffset)Copies max(buffer.length, code unit length) bytes into buffer starting at location offset in buffer.java.lang.StringgetComment(int commentType)Get the comment for the given typejava.lang.String[]getCommentAsArray(int commentType)Get the comment as an array where each element is a single line for the given type.DatagetComponent(int index)Returns the immediate n'th component or null if none exists.DatagetComponent(int[] componentPath)Get a data item given the index path.DatagetComponentAt(int offset)Deprecated.DatagetComponentContaining(int offset)RReturn the first immediate child component that contains the byte at the given offset.intgetComponentIndex()Get the index of this component in its parentintgetComponentLevel()Get this data's component level in its hierarchy of components.int[]getComponentPath()Get the component path if this is a component.java.lang.StringgetComponentPathName()Returns the component path name (dot notation) for this fieldjava.util.List<Data>getComponentsContaining(int offset)Returns a list of all the immediate child components that contain the byte at the given offset.DataTypegetDataType()Get the Data type for the data.java.lang.StringgetDefaultLabelPrefix(DataTypeDisplayOptions options)Returns the appropriate string to use as the default label prefix or null if it has no preferred default label prefix;SettingsgetDefaultSettings()Returns the underlying default settings for these settings or null if there are nonejava.lang.StringgetDefaultValueRepresentation()Returns a string that represents the data value without markup.ExternalReferencegetExternalReference(int opIndex)Gets the external reference (if any) at the opIndexjava.lang.StringgetFieldName()Get the field name of this data item if it is "inside" another data item, otherwise return null.intgetInt(int offset)returns the int at the given offset, taking into account the endianess.intgetIntProperty(java.lang.String name)Get the int property for name.java.lang.StringgetLabel()Deprecated.intgetLength()Get the length of the code unit.longgetLong(int offset)returns the long at the given offset, taking into account the endianess.java.lang.LonggetLong(java.lang.String name)Gets the Long value associated with the given nameAddressgetMaxAddress()Get the ending address for this code unit.MemorygetMemory()Get the Memory object actually used by the MemBuffer.AddressgetMinAddress()Get the starting address for this code unit.Reference[]getMnemonicReferences()Get references for the mnemonic for this instruction.java.lang.StringgetMnemonicString()Get the mnemonic for this code unit, e.g., MOV, JMPjava.lang.String[]getNames()Get this list of keys that currently have values associated with themCodeUnitgetNextCodeUnit()Get the code unit after this code unit.intgetNumComponents()Return the number of components that make up this data item.intgetNumOperands()Get the number of operands for this code unit.SaveablegetObjectProperty(java.lang.String name)Get the object property for name; returns null if there is no name property for this code unit.Reference[]getOperandReferences(int opIndex)Get the references for the operand index.DatagetParent()Get the immediate parent data item of this data item or null if this data item is not contained in another data item.intgetParentOffset()Get the offset of this Data item from the start of its immediate parent.java.lang.StringgetPathName()Returns the full path name (dot notation) for this field.CodeUnitgetPreviousCodeUnit()Get the code unit before this code unit.ReferencegetPrimaryReference(int index)Get the primary reference for the operand index.SymbolgetPrimarySymbol()Get the primary Symbol for this code unit.DatagetPrimitiveAt(int offset)Returns the primitive component containing this offset (i.e., one that does not have sub-components).ProgramgetProgram()Returns the program that generated this CodeUnit.ReferenceIteratorgetReferenceIteratorTo()Get an iterator over all references TO this code unit.Reference[]getReferencesFrom()Get ALL reference FROM this code unit.DatagetRoot()Get the highest level Data item in a hierarchy of structures containing this component.intgetRootOffset()Get the offset of this Data item from the start of the root data item of some hierarchy of structures.ScalargetScalar(int opIndex)Returns the scalar at the given operand index.shortgetShort(int offset)returns the short at the given offset, taking into account the endianess.StackReferencegetStackReference(int opIndex)java.lang.StringgetString(java.lang.String name)Gets the String value associated with the given namejava.lang.StringgetStringProperty(java.lang.String name)Get the string property for name; returns null if there is no name property for this code unit.Symbol[]getSymbols()Get the symbols for this code unit.java.lang.ObjectgetValue()Returns the value of the data item.java.lang.ObjectgetValue(java.lang.String name)Gets the object associated with the given namejava.lang.Class<?>getValueClass()Get the class used to express the value of this data.Reference[]getValueReferences()Get the references for the value.booleangetVoidProperty(java.lang.String name)Returns whether this code unit is marked as having the name property.inthashCode()booleanhasProperty(java.lang.String name)Returns true if the codeunit has the given property defined.booleanhasStringValue()Returns true if this data corresponds to string data.voidinvalidate()Invalidate memory bufferbooleanisArray()Returns true if this data item is an Array of DataTypesbooleanisBigEndian()Returns true if the underlying bytes are in big-endian order, false if they are little endian.booleanisConstant()booleanisDefined()Returns true if the data type is defined.booleanisDynamic()Returns true if this data item is a dynamic DataType.booleanisEmpty()Returns true if there are no key-value pairs stored in this settings objectbooleanisPointer()Returns true if this is a pointer, implies getValue() will will return an Object that is an Address.booleanisStructure()Returns true if this data item is a Structure.booleanisSuccessor(CodeUnit codeUnit)Return true if the given CodeUnit follows directly after this code unit.booleanisUnion()Returns true if this data item is a Union.booleanisValid()booleanisVolatile()java.util.Iterator<java.lang.String>propertyNames()Get an iterator over the property names.protected voidrefreshIfNeeded()voidremoveExternalReference(int opIndex)Remove external reference (if any) at the given opIndex opIndex the index of the operand from which to remove any external reference.voidremoveMnemonicReference(Address refAddr)Remove a reference to the mnemonic for this instruction.voidremoveOperandReference(int opIndex, Address refAddr)Remove a user defined reference to the operand at opIndex.voidremoveProperty(java.lang.String name)Remove the property value with the given name for this code unit.voidremoveStackReference(int opIndex)voidremoveValueReference(Address refAddr)Remove a reference to the value.voidsetByteArray(java.lang.String name, byte[] value)Associates the given byte[] with the namevoidsetComment(int commentType, java.lang.String comment)Set the comment for the given type.voidsetCommentAsArray(int commentType, java.lang.String[] comment)Set the comment for the given type.voidsetExternalReference(Reference ref)voidsetLong(java.lang.String name, long value)Associates the given long value with the namevoidsetMemoryReference(int opIndex, Address refAddr, RefType refType)voidsetPrimaryMemoryReference(Reference ref)Sets a memory reference to be the primary reference at its address/opIndex location.voidsetProperty(java.lang.String name)Mark the property name as having a value for this code unit.voidsetProperty(java.lang.String name, int value)Set the property name with the given value for this code unit.voidsetProperty(java.lang.String name, Saveable value)Set the property name with the given value for this code unit.voidsetProperty(java.lang.String name, java.lang.String value)Set the property name with the given value for this code unit.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 referencevoidsetStackReference(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 referencevoidsetString(java.lang.String name, java.lang.String value)Associates the given String value with the namevoidsetValue(java.lang.String name, java.lang.Object value)Associates the given object with the namejava.lang.StringtoString()voidvisitProperty(PropertyVisitor visitor, java.lang.String propertyName)Invokes the visit() method of the specified PropertyVisitor if the named property exists for this code unit.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ghidra.program.model.listing.CodeUnit
addMnemonicReference, addOperandReference, compareTo, contains, getAddressString, getBytes, getBytesInCodeUnit, getComment, getCommentAsArray, getExternalReference, getIntProperty, getLabel, getLength, getMaxAddress, getMinAddress, getMnemonicReferences, getObjectProperty, getOperandReferences, getPrimaryReference, getPrimarySymbol, getProgram, getReferenceIteratorTo, getReferencesFrom, getStringProperty, getSymbols, getVoidProperty, hasProperty, isSuccessor, propertyNames, removeExternalReference, removeMnemonicReference, removeOperandReference, removeProperty, setComment, setCommentAsArray, setPrimaryMemoryReference, setProperty, setProperty, setProperty, setProperty, setRegisterReference, setStackReference, visitProperty
-
Methods inherited from interface ghidra.program.model.mem.MemBuffer
getAddress, getBigInteger, getByte, getBytes, getInt, getLong, getMemory, getShort, getUnsignedByte, getUnsignedInt, getUnsignedShort, getVarLengthInt, getVarLengthUnsignedInt, isBigEndian, isInitializedMemory
-
-
-
-
Field Detail
-
dataType
protected DataType dataType
-
baseDataType
protected DataType baseDataType
-
OP_INDEX
protected static final int OP_INDEX
- See Also:
- Constant Field Values
-
level
protected int level
-
dataMgr
protected DataTypeManagerDB dataMgr
-
address
protected Address address
-
maxAddress
protected Address maxAddress
-
program
protected Program program
-
length
protected int length
-
emptyAddrArray
protected static final Address[] emptyAddrArray
-
hash
protected int hash
-
bytes
protected byte[] bytes
-
isBigEndian
protected boolean isBigEndian
-
emptyMemRefs
protected static final Reference[] emptyMemRefs
-
comments
protected java.util.Map<java.lang.Integer,java.lang.String> comments
-
refMgr
protected ReferenceManager refMgr
-
-
Constructor Detail
-
PseudoData
public PseudoData(Program program, Address address, DataType dataType, MemBuffer memBuffer) throws AddressOverflowException
- Throws:
AddressOverflowException
-
PseudoData
public PseudoData(Address address, DataType dataType, MemBuffer memBuffer) throws AddressOverflowException
- Throws:
AddressOverflowException
-
-
Method Detail
-
addValueReference
public void addValueReference(Address refAddr, RefType type)
Description copied from interface:DataAdd a memory reference to the value.- Specified by:
addValueReferencein interfaceData- Parameters:
refAddr- address referenced.type- the type of reference to be added.
-
removeValueReference
public void removeValueReference(Address refAddr)
Description copied from interface:DataRemove a reference to the value.- Specified by:
removeValueReferencein interfaceData- Parameters:
refAddr- address of reference to be removed.
-
getComponent
public Data getComponent(int index)
Description copied from interface:DataReturns the immediate n'th component or null if none exists.- Specified by:
getComponentin interfaceData- Parameters:
index- the index of the component to get.- Returns:
- the component
-
getAddress
public Address getAddress(int opIndex)
Description copied from interface:CodeUnitGet the Address for the given operand index if one exists. Data objects have one operand (the value).- Specified by:
getAddressin interfaceCodeUnit- Parameters:
opIndex- index of the operand.- Returns:
- An addres if the operand represents a fully qualified address (given the context), or if the operand is a Scalar treated as an address. Null is returned if no address or scalar exists on that operand.
-
getByteCodeString
public java.lang.String getByteCodeString()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getDefaultValueRepresentation
public java.lang.String getDefaultValueRepresentation()
Description copied from interface:DataReturns a string that represents the data value without markup.- Specified by:
getDefaultValueRepresentationin interfaceData- Returns:
- the string
-
getMnemonicString
public java.lang.String getMnemonicString()
Description copied from interface:CodeUnitGet the mnemonic for this code unit, e.g., MOV, JMP- Specified by:
getMnemonicStringin interfaceCodeUnit
-
getNumOperands
public int getNumOperands()
Description copied from interface:CodeUnitGet the number of operands for this code unit.- Specified by:
getNumOperandsin interfaceCodeUnit
-
getScalar
public Scalar getScalar(int opIndex)
Description copied from interface:CodeUnitReturns the scalar at the given operand index. Data objects have one operand (the value).
-
getBaseDataType
public DataType getBaseDataType()
Description copied from interface:DataIf the dataType is a typeDef, then the typeDef's base type is returned, otherwise, the datatType is returned.- Specified by:
getBaseDataTypein interfaceData- Returns:
- the data type
-
clearSetting
public void clearSetting(java.lang.String name)
Description copied from interface:SettingsRemoves any value associated with the given name- Specified by:
clearSettingin interfaceSettings- Parameters:
name- the key to remove any association
-
getByteArray
public byte[] getByteArray(java.lang.String name)
Description copied from interface:SettingsGets the byte[] value associated with the given name- Specified by:
getByteArrayin interfaceSettings- Parameters:
name- the key used to retrieve a value- Returns:
- the byte[] value for a key
-
getLong
public java.lang.Long getLong(java.lang.String name)
Description copied from interface:SettingsGets the Long value associated with the given name
-
getNames
public java.lang.String[] getNames()
Description copied from interface:SettingsGet this list of keys that currently have values associated with them
-
getString
public java.lang.String getString(java.lang.String name)
Description copied from interface:SettingsGets the String value associated with the given name
-
getValue
public java.lang.Object getValue(java.lang.String name)
Description copied from interface:SettingsGets the object associated with the given name
-
setByteArray
public void setByteArray(java.lang.String name, byte[] value)Description copied from interface:SettingsAssociates the given byte[] with the name- Specified by:
setByteArrayin interfaceSettings- Parameters:
name- the keyvalue- the value associated with the key
-
setLong
public void setLong(java.lang.String name, long value)Description copied from interface:SettingsAssociates the given long value with the name
-
setString
public void setString(java.lang.String name, java.lang.String value)Description copied from interface:SettingsAssociates the given String value with the name
-
setValue
public void setValue(java.lang.String name, java.lang.Object value)Description copied from interface:SettingsAssociates the given object with the name
-
getComponent
public Data getComponent(int[] componentPath)
Description copied from interface:DataGet a data item given the index path. Each integer in the array represents an index into the data item at that level.- Specified by:
getComponentin interfaceData- Parameters:
componentPath- the array of indexes to use to find the requested data item.- Returns:
- the component
-
getComponentAt
@Deprecated public Data getComponentAt(int offset)
Deprecated.Description copied from interface:DataReturn the first immediate child component that contains the byte at the given offset. It is important to note that with certain datatypes there may be more than one component containing the specified offset (seeData.getComponentsContaining(int)).- Specified by:
getComponentAtin interfaceData- Parameters:
offset- the amount to add to this data items address to get the address of the requested data item.- Returns:
- first data component containing offset or null
-
getComponentContaining
public Data getComponentContaining(int offset)
Description copied from interface:DataRReturn the first immediate child component that contains the byte at the given offset. It is important to note that with certain datatypes there may be more than one component containing the specified offset (seeData.getComponentsContaining(int)).- Specified by:
getComponentContainingin interfaceData- Parameters:
offset- the amount to add to this data items address to get the- Returns:
- first data component containing offset or null address of the requested data item.
-
getComponentsContaining
public java.util.List<Data> getComponentsContaining(int offset)
Description copied from interface:DataReturns a list of all the immediate child components that contain the byte at the given offset.For a union, this will return all the components (if the offset is 0). The presence of bit-fields or zero-length components may cause multiple components to be returned.
- Specified by:
getComponentsContainingin interfaceData- Parameters:
offset- the amount to add to this data items address to get the address of the requested data item.- Returns:
- a list of all the immediate child components that contain the byte at the given offset or null if offset is out of bounds.
-
getComponentIndex
public int getComponentIndex()
Description copied from interface:DataGet the index of this component in its parent- Specified by:
getComponentIndexin interfaceData- Returns:
- -1 if this data item is not a component of another data item.
-
getComponentLevel
public int getComponentLevel()
Description copied from interface:DataGet this data's component level in its hierarchy of components.- Specified by:
getComponentLevelin interfaceData- Returns:
- the level of this data item with 0 being the level of top data items.
-
getComponentPath
public int[] getComponentPath()
Description copied from interface:DataGet the component path if this is a component. The component path is an array of integers that represent each index in the tree of data items. Top level data items have an empty array for their component path.- Specified by:
getComponentPathin interfaceData- Returns:
- the path
-
getComponentPathName
public java.lang.String getComponentPathName()
Description copied from interface:DataReturns the component path name (dot notation) for this field- Specified by:
getComponentPathNamein interfaceData- Returns:
- the component path name
-
getDataType
public DataType getDataType()
Description copied from interface:DataGet the Data type for the data.- Specified by:
getDataTypein interfaceData- Returns:
- the data type
-
getFieldName
public java.lang.String getFieldName()
Description copied from interface:DataGet the field name of this data item if it is "inside" another data item, otherwise return null.- Specified by:
getFieldNamein interfaceData- Returns:
- the name of this data as known from some parent data item or null if this data item is not a component of another data item.
-
getNumComponents
public int getNumComponents()
Description copied from interface:DataReturn the number of components that make up this data item. if this is an Array, return the number of elements in the array.- Specified by:
getNumComponentsin interfaceData- Returns:
- the number of components
-
getParent
public Data getParent()
Description copied from interface:DataGet the immediate parent data item of this data item or null if this data item is not contained in another data item.
-
getParentOffset
public int getParentOffset()
Description copied from interface:DataGet the offset of this Data item from the start of its immediate parent.- Specified by:
getParentOffsetin interfaceData- Returns:
- the offset
-
getPathName
public java.lang.String getPathName()
Description copied from interface:DataReturns the full path name (dot notation) for this field. This includes the symbol name at this address.- Specified by:
getPathNamein interfaceData- Returns:
- the path name
-
getPrimitiveAt
public Data getPrimitiveAt(int offset)
Description copied from interface:DataReturns the primitive component containing this offset (i.e., one that does not have sub-components). This is useful for data items which are made up of multiple layers of other data items. This method immediately goes to the lowest level data item. If the minimum offset of a component is specified, the only first component containing the offset will be considered (e.g., 0-element array).- Specified by:
getPrimitiveAtin interfaceData- Parameters:
offset- the offset- Returns:
- primitive component containing this offset
-
getRoot
public Data getRoot()
Description copied from interface:DataGet the highest level Data item in a hierarchy of structures containing this component.
-
getRootOffset
public int getRootOffset()
Description copied from interface:DataGet the offset of this Data item from the start of the root data item of some hierarchy of structures.- Specified by:
getRootOffsetin interfaceData- Returns:
- the offset
-
getValue
public java.lang.Object getValue()
Description copied from interface:DataReturns the value of the data item. The value may be an address, a scalar, register or null if no value.
-
getValueClass
public java.lang.Class<?> getValueClass()
Description copied from interface:DataGet the class used to express the value of this data.NOTE: This determination is made based upon data type and settings only and does not examine memory bytes which are used to construct the data value object.
- Specified by:
getValueClassin interfaceData- Returns:
- value class or null if a consistent class is not utilized.
-
hasStringValue
public boolean hasStringValue()
Description copied from interface:DataReturns true if this data corresponds to string data. This is determined by the corresponding data type producing a String value.- Specified by:
hasStringValuein interfaceData- Returns:
- true if this data returns a String value and can be treated as string data.
-
getValueReferences
public Reference[] getValueReferences()
Description copied from interface:DataGet the references for the value.- Specified by:
getValueReferencesin interfaceData- Returns:
- the references
-
isArray
public boolean isArray()
Description copied from interface:DataReturns true if this data item is an Array of DataTypes
-
isDefined
public boolean isDefined()
Description copied from interface:DataReturns true if the data type is defined. Any address that has not been defined to be code or data is treated as undefined data.
-
isPointer
public boolean isPointer()
Description copied from interface:DataReturns true if this is a pointer, implies getValue() will will return an Object that is an Address.
-
isStructure
public boolean isStructure()
Description copied from interface:DataReturns true if this data item is a Structure.- Specified by:
isStructurein interfaceData- Returns:
- true if a structure
-
isDynamic
public boolean isDynamic()
Description copied from interface:DataReturns true if this data item is a dynamic DataType.
-
isUnion
public boolean isUnion()
Description copied from interface:DataReturns true if this data item is a Union.
-
clearAllSettings
public void clearAllSettings()
Description copied from interface:SettingsRemoves all name-value pairs from this settings object- Specified by:
clearAllSettingsin interfaceSettings
-
isEmpty
public boolean isEmpty()
Description copied from interface:SettingsReturns true if there are no key-value pairs stored in this settings object
-
getDefaultLabelPrefix
public java.lang.String getDefaultLabelPrefix(DataTypeDisplayOptions options)
Description copied from interface:DataReturns the appropriate string to use as the default label prefix or null if it has no preferred default label prefix;- Specified by:
getDefaultLabelPrefixin interfaceData- Parameters:
options- the options- Returns:
- the prefix
-
equals
public boolean equals(java.lang.Object obj)
-
isConstant
public boolean isConstant()
- Specified by:
isConstantin interfaceData- Returns:
- true if data is constant. If true, isConstant will always be false
-
isVolatile
public boolean isVolatile()
- Specified by:
isVolatilein interfaceData- Returns:
- true if data is volatile. If true, isVolatile will always be false
-
getDefaultSettings
public Settings getDefaultSettings()
Description copied from interface:SettingsReturns the underlying default settings for these settings or null if there are none- Specified by:
getDefaultSettingsin interfaceSettings
-
invalidate
public void invalidate()
Invalidate memory buffer
-
isValid
public boolean isValid()
-
getAddressString
public java.lang.String getAddressString(boolean showBlockName, boolean pad)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
-
getLength
public final int getLength()
Get the length of the code unit.
-
refreshIfNeeded
protected void refreshIfNeeded()
-
getBytes
public byte[] getBytes() throws MemoryAccessExceptionGets the bytes for this code unit.- 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.
-
getBytes
public int getBytes(byte[] b, int offset)Description copied from interface:MemBufferReadsb.lengthbytes from this memory buffer starting at the address of this memory buffer plus the given memoryBufferOffset from that position. The actual number of bytes may be fewer if bytes can't be read.- Specified by:
getBytesin interfaceMemBuffer- Parameters:
b- the buffer into which bytes will be placedoffset- the offset in this memory buffer from which to start reading bytes.- Returns:
- the number of bytes read which may be fewer than b.length if available bytes are exhausted or no bytes are available at the specified offset.
-
getBytesInCodeUnit
public void getBytesInCodeUnit(byte[] buffer, int bufferOffset) throws MemoryAccessExceptionDescription copied from interface:CodeUnitCopies max(buffer.length, code unit length) bytes into buffer starting at location offset in buffer.- 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.
-
isBigEndian
public 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.
-
getShort
public short getShort(int offset) throws MemoryAccessExceptionDescription copied from interface:MemBufferreturns the short at the given offset, taking into account the endianess.- Specified by:
getShortin interfaceMemBuffer- Parameters:
offset- the offset from the membuffers origin (the address that it is set at)- Returns:
- the short at the given offset, taking into account the endianess.
- Throws:
MemoryAccessException- if a 2-byte short value cannot be read at the specified offset
-
getInt
public int getInt(int offset) throws MemoryAccessExceptionDescription copied from interface:MemBufferreturns the int at the given offset, taking into account the endianess.- Specified by:
getIntin interfaceMemBuffer- Parameters:
offset- the offset from the membuffers origin (the address that it is set at)- Returns:
- the int at the given offset, taking into account the endianess.
- Throws:
MemoryAccessException- if a 4-byte integer value cannot be read at the specified offset
-
getLong
public long getLong(int offset) throws MemoryAccessExceptionDescription copied from interface:MemBufferreturns the long at the given offset, taking into account the endianess.- Specified by:
getLongin interfaceMemBuffer- Parameters:
offset- the offset from the membuffers origin (the address that it is set at)- Returns:
- the long at the given offset, taking into account the endianess.
- Throws:
MemoryAccessException- if a 8-byte long value cannot be read at the specified offset
-
getBigInteger
public java.math.BigInteger getBigInteger(int offset, int size, boolean signed) throws MemoryAccessExceptionDescription copied from interface:MemBufferreturns the value at the given offset, taking into account the endianess.- Specified by:
getBigIntegerin interfaceMemBuffer- Parameters:
offset- the offset from the membuffers origin (the address that it is set at)size- the number of bytes to include in the valuesigned- true if value should be treated as a signed twos-compliment value.- Returns:
- the value at the given offset, taking into account the endianess.
- Throws:
MemoryAccessException- if the request size value cannot be read at the specified offset
-
setProperty
public void setProperty(java.lang.String name, Saveable value)Set the property name with the given value for this code unit.- Specified by:
setPropertyin interfaceCodeUnit- Parameters:
name- the name of the property to save.value- the value of the property to save.- Throws:
TypeMismatchException- if the property manager for name does not support object typesjava.util.ConcurrentModificationException- if this object is no longer valid.
-
setProperty
public void setProperty(java.lang.String name, java.lang.String value)Set the property name with the given value for this code unit.- Specified by:
setPropertyin interfaceCodeUnit- Parameters:
name- the name of the property to save.value- the value of the property to save.- Throws:
TypeMismatchException- if the property manager for name does not support string typesjava.util.ConcurrentModificationException- if this object is no longer valid.
-
setProperty
public void setProperty(java.lang.String name, int value)Set the property name with the given value for this code unit.- Specified by:
setPropertyin interfaceCodeUnit- Parameters:
name- the name of the property to save.value- the value of the property to save.- Throws:
TypeMismatchException- if the property manager for name does not support int typesjava.util.ConcurrentModificationException- if this object is no longer valid.
-
setProperty
public void setProperty(java.lang.String name)
Mark the property name as having a value for this code unit.- Specified by:
setPropertyin interfaceCodeUnit- Parameters:
name- the name of the property to save.- Throws:
TypeMismatchException- if the property manager for name does not support void typesjava.util.ConcurrentModificationException- if this object is no longer valid.
-
getObjectProperty
public Saveable getObjectProperty(java.lang.String name)
Get the object property for name; returns null if there is no name property for this code unit.- Specified by:
getObjectPropertyin interfaceCodeUnit- Parameters:
name- the name of the property.- Throws:
TypeMismatchException- if the property manager for name does not support object typesjava.util.ConcurrentModificationException- if this object is no longer valid.
-
getStringProperty
public java.lang.String getStringProperty(java.lang.String name)
Get the string property for name; returns null if there is no name property for this code unit.- Specified by:
getStringPropertyin interfaceCodeUnit- Parameters:
name- the name of the property.- Throws:
TypeMismatchException- if the property manager for name does not support string typesjava.util.ConcurrentModificationException- if this object is no longer valid.
-
getIntProperty
public int getIntProperty(java.lang.String name) throws NoValueExceptionGet the int property for name.- Specified by:
getIntPropertyin interfaceCodeUnit- Parameters:
name- the name of the property.- Throws:
NoValueException- if there is not name property for this code unitTypeMismatchException- if the property manager for name does not support int typesjava.util.ConcurrentModificationException- if this object is no longer valid.
-
hasProperty
public boolean hasProperty(java.lang.String name)
Description copied from interface:CodeUnitReturns true if the codeunit has the given property defined.- Specified by:
hasPropertyin interfaceCodeUnit- Parameters:
name- the name of the property
-
getVoidProperty
public boolean getVoidProperty(java.lang.String name)
Returns whether this code unit is marked as having the name property.- Specified by:
getVoidPropertyin interfaceCodeUnit- Parameters:
name- the name of the property.- Throws:
TypeMismatchException- if the property manager for name does not support void typesjava.util.ConcurrentModificationException- if this object is no longer valid.
-
propertyNames
public java.util.Iterator<java.lang.String> propertyNames()
Description copied from interface:CodeUnitGet an iterator over the property names.- Specified by:
propertyNamesin interfaceCodeUnit
-
removeProperty
public void removeProperty(java.lang.String name)
Remove the property value with the given name for this code unit.- Specified by:
removePropertyin interfaceCodeUnit- Parameters:
name- the name of the property.
-
visitProperty
public void visitProperty(PropertyVisitor visitor, java.lang.String propertyName)
Invokes the visit() method of the specified PropertyVisitor if the named property exists for this code unit.- Specified by:
visitPropertyin interfaceCodeUnit- Parameters:
visitor- the class implementing the PropertyVisitor interface.propertyName- the name of the property to be visited.
-
getLabel
@Deprecated public java.lang.String getLabel()
Deprecated.Get the label for this code unit.
-
getSymbols
public Symbol[] getSymbols()
Get the symbols for this code unit.- Specified by:
getSymbolsin interfaceCodeUnit- Throws:
java.util.ConcurrentModificationException- if this object is no longer valid.
-
getPrimarySymbol
public Symbol getPrimarySymbol()
Get the primary Symbol for this code unit.- Specified by:
getPrimarySymbolin interfaceCodeUnit- Throws:
java.util.ConcurrentModificationException- if this object is no longer valid.
-
getMinAddress
public Address getMinAddress()
Get the starting address for this code unit.- Specified by:
getMinAddressin interfaceCodeUnit- Throws:
java.util.ConcurrentModificationException- if this object is no longer valid.
-
getMaxAddress
public Address getMaxAddress()
Get the ending address for this code unit.- Specified by:
getMaxAddressin interfaceCodeUnit- Throws:
java.util.ConcurrentModificationException- if this object is no longer valid.
-
getNextCodeUnit
public CodeUnit getNextCodeUnit()
Get the code unit after this code unit.- Throws:
java.util.ConcurrentModificationException- if this object is no longer valid.
-
getPreviousCodeUnit
public CodeUnit getPreviousCodeUnit()
Get the code unit before this code unit.- Throws:
java.util.ConcurrentModificationException- if this object is no longer valid.
-
isSuccessor
public boolean isSuccessor(CodeUnit codeUnit)
Return true if the given CodeUnit follows directly after this code unit.- Specified by:
isSuccessorin interfaceCodeUnit- Parameters:
codeUnit- the codeUnit being tested to see if it follows this codeUnit.- Throws:
java.util.ConcurrentModificationException- if this object is no longer valid.
-
getComment
public java.lang.String getComment(int commentType)
Description copied from interface:CodeUnitGet the comment for the given type- Specified by:
getCommentin interfaceCodeUnit- Parameters:
commentType- either EOL_COMMENT, PRE_COMMENT, POST_COMMENT, or REPEATABLE_COMMENT- Returns:
- the comment string of the appropriate type or null if no comment of that type exists for this codeunit
-
getCommentAsArray
public java.lang.String[] getCommentAsArray(int commentType)
Get the comment as an array where each element is a single line for the given type.- Specified by:
getCommentAsArrayin interfaceCodeUnit- Parameters:
commentType- must be either EOL_COMMENT_TYPE, PRE_COMMENT_TYPE, POST_COMMENT_TYPE, or PLATE_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.
- Throws:
java.lang.IllegalArgumentException- if type is not one of the three types of comments supportedjava.util.ConcurrentModificationException- if this object is no longer valid.
-
setCommentAsArray
public void setCommentAsArray(int commentType, java.lang.String[] comment)Set the comment for the given type.- Specified by:
setCommentAsArrayin interfaceCodeUnit- Parameters:
commentType- must be either EOL_COMMENT, PRE_COMMENT, POST_COMMENT, or PLATE_COMMENTcomment- the lines that make up the comment- Throws:
java.lang.IllegalArgumentException- if type is not one of the three types of comments supportedjava.util.ConcurrentModificationException- if this object is no longer valid.
-
setComment
public void setComment(int commentType, java.lang.String comment)Set the comment for the given type.- Specified by:
setCommentin interfaceCodeUnit- Parameters:
commentType- must be either EOL_COMMENT, PRE_COMMENT, POST_COMMENT, or PLATE_COMMENTcomment- the comment- Throws:
java.lang.IllegalArgumentException- if type is not one of the three types of comments supportedjava.util.ConcurrentModificationException- if this object is no longer valid.
-
contains
public boolean contains(Address testAddr)
Determines if this code unit contains the indicated address.
-
compareTo
public int compareTo(Address a)
Compares the given address to the address range of this node.- Specified by:
compareToin interfaceCodeUnit- Parameters:
a- the address- Returns:
- a negative integer if addr is greater than the maximum range address zero if addr is in the range a positive integer if addr is less than minimum range address
- Throws:
java.util.ConcurrentModificationException- if this object is no longer valid.
-
getByte
public byte getByte(int offset) throws MemoryAccessExceptionGet one byte from memory at the current position plus offset.- Specified by:
getBytein interfaceMemBuffer- Parameters:
offset- the displacement from the current position.- Returns:
- the data at offset from the current position.
- Throws:
AddressOutOfBoundsException- if offset exceeds address spacejava.lang.IndexOutOfBoundsException- if offset is negativeMemoryAccessException- if memory cannot be read
-
getAddress
public Address getAddress()
Get the Address which corresponds to the offset 0.- Specified by:
getAddressin interfaceMemBuffer- Returns:
- the current address of offset 0.
-
getMemory
public Memory getMemory()
Get the Memory object actually used by the MemBuffer. return the Memory used by this MemBuffer.
-
addMnemonicReference
public void addMnemonicReference(Address refAddr, RefType refType, SourceType sourceType)
Add a reference to the mnemonic for this code unit.- Specified by:
addMnemonicReferencein interfaceCodeUnit- Parameters:
refAddr- address of reference to addrefType- type of reference being addedsourceType- the source of this reference
-
getMnemonicReferences
public Reference[] getMnemonicReferences()
Get references for the mnemonic for this instruction.- Specified by:
getMnemonicReferencesin interfaceCodeUnit- Returns:
- an array of memory references. A zero length array will be returned if there are no references for the mnemonic.
-
removeMnemonicReference
public void removeMnemonicReference(Address refAddr)
Remove a reference to the mnemonic for this instruction.- Specified by:
removeMnemonicReferencein interfaceCodeUnit- Parameters:
refAddr- the address to remove as a reference.
-
addOperandReference
public void addOperandReference(int opIndex, Address refAddr, RefType type, SourceType sourceType)Add a user defined reference to the operand at the given index.- Specified by:
addOperandReferencein interfaceCodeUnit- Parameters:
opIndex- operand indexrefAddr- reference addresstype- the reference type to be added.sourceType- the source of this reference- See Also:
CodeUnit.addOperandReference(int, Address, RefType, SourceType)
-
getOperandReferences
public Reference[] getOperandReferences(int opIndex)
Get the references for the operand index. If the operand type is a register, then the user defined references are returned; otherwise an array with the address for the operand value is returned.- Specified by:
getOperandReferencesin interfaceCodeUnit- Parameters:
opIndex- operand index (0 is the first operand)
-
removeOperandReference
public void removeOperandReference(int opIndex, Address refAddr)Remove a user defined reference to the operand at opIndex.- Specified by:
removeOperandReferencein interfaceCodeUnit- Parameters:
opIndex- operand indexrefAddr- address referencing the operand
-
getReferencesFrom
public Reference[] getReferencesFrom()
Get ALL reference FROM this code unit.- Specified by:
getReferencesFromin interfaceCodeUnit- Returns:
- an array of memory references from this codeUnit or an empty array if there are no references.
-
setExternalReference
public void setExternalReference(Reference ref)
-
setStackReference
public void setStackReference(int opIndex, int offset, SourceType sourceType, RefType refType)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
public 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...
-
getPrimaryReference
public Reference getPrimaryReference(int index)
Description copied from interface:CodeUnitGet the primary reference for the operand index.- Specified by:
getPrimaryReferencein interfaceCodeUnit- Parameters:
index- operand index (0 is the first operand)
-
setPrimaryMemoryReference
public void setPrimaryMemoryReference(Reference ref)
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.
-
getStackReference
public StackReference getStackReference(int opIndex)
-
removeStackReference
public void removeStackReference(int opIndex)
-
getExternalReference
public ExternalReference getExternalReference(int opIndex)
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.
-
removeExternalReference
public void removeExternalReference(int opIndex)
Description copied from interface:CodeUnitRemove external reference (if any) at the given opIndex opIndex the index of the operand from which to remove any external reference.- Specified by:
removeExternalReferencein interfaceCodeUnit
-
getReferenceIteratorTo
public ReferenceIterator getReferenceIteratorTo()
Description copied from interface:CodeUnitGet an iterator over all references TO this code unit.- Specified by:
getReferenceIteratorToin interfaceCodeUnit
-
getProgram
public Program getProgram()
Description copied from interface:CodeUnitReturns the program that generated this CodeUnit.- Specified by:
getProgramin interfaceCodeUnit
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-