Package ghidra.pcode.emu.jit
Class JitPassage.DecodeErrorInstruction
java.lang.Object
ghidra.app.util.PseudoInstruction
ghidra.pcode.emu.jit.JitPassage.DecodeErrorInstruction
- All Implemented Interfaces:
InstructionContext,ProcessorContext,ProcessorContextView,CodeUnit,Instruction,MemBuffer,PropertySet
- Enclosing class:
JitPassage
An instruction denoting a decode error
The Sleigh disassembler normally denotes this with a PseudoInstruction having an
InvalidPrototype. We essentially do the same here, but with custom types that are
simpler to identify. Additionally, the types contain additional information, e.g., the error
message. We also need the prototype to produce a single JitPassage.DecodeErrorPcodeOp.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Addressprotected byte[]protected Map<CommentType, String> protected static final Address[]protected static final Reference[]protected intprotected booleanprotected intprotected Addressprotected Programprotected ReferenceManagerFields 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_PROPERTYFields inherited from interface ghidra.program.model.listing.Instruction
INVALID_DEPTH_CHANGE, MAX_LENGTH_OVERRIDE -
Constructor Summary
ConstructorsConstructorDescriptionDecodeErrorInstruction(Language language, Address address, RegisterValue ctx, String message) Construct an instruction to indicate a decode error -
Method Summary
Modifier and TypeMethodDescriptionvoidaddMnemonicReference(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.intCompares the given address to the address range of this node.booleanDetermines if this code unit contains the indicated address.Get the Address which corresponds to the offset 0.getAddressString(boolean showBlockName, boolean pad) Get the string representation of the starting address for this code unit.getBigInteger(int offset, int size, boolean signed) returns the value at the given offset, taking into account the endianness.bytegetByte(int offset) Get one byte from memory at the current position plus offset.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.getComment(CommentType commentType) Get the comment for the given typeString[]getCommentAsArray(CommentType commentType) Get the comment as an array where each element is a single line for the given type.getExternalReference(int opIndex) Gets the external reference (if any) at the opIndexintgetInt(int offset) returns the int at the given offset, taking into account the endianness.intgetIntProperty(String name) Get the int property for name.getLabel()Deprecated.final intGet the length of the code unit.longgetLong(int offset) returns the long at the given offset, taking into account the endianness.Get the ending address for this code unit.Get the Memory object actually used by the MemBuffer.Get the message for the exception, should this instruction be "executed"Get the starting address for this code unit.Get references for the mnemonic for this instruction.Returns the code unit after this code unit..getObjectProperty(String name) Get the object property for name; returns null if there is no name property for this code unit.Returns the code unit before this code unit..getPrimaryReference(int index) Returns the primary reference for the operand index..Get the primary Symbol for this code unit.Returns the program that generated this CodeUnit..Returns an iterator over all references TO this code unit..Get ALL reference FROM this code unit.shortgetShort(int offset) returns the short at the given offset, taking into account the endianness.getStackReference(int opIndex) getStringProperty(String name) Get the string property for name; returns null if there is no name property for this code unit.Symbol[]Get the symbols for this code unit.booleangetVoidProperty(String name) Returns whether this code unit is marked as having the name property.inthashCode()booleanhasProperty(String name) Returns true if the codeunit has the given property defined.voidInvalidate memory bufferbooleanReturns true if the underlying bytes are in big-endian order, false if they are little endian.booleanisValid()Get an iterator over the property names which have values applied.protected voidvoidremoveExternalReference(int opIndex) Remove external reference (if any) at the given opIndexvoidremoveMnemonicReference(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(String name) Remove the property value with the given name for this code unit.voidremoveStackReference(int opIndex) voidsetComment(CommentType commentType, String comment) Set the comment for the given type.voidsetCommentAsArray(CommentType commentType, String[] comment) Set the comment for the given type.voidvoidsetMemoryReference(int opIndex, Address refAddr, RefType refType) voidSets a memory reference to be the primary reference at its address/opIndex location.voidsetProperty(String name) Mark the property name as having a value for this code unit.voidsetProperty(String name, int value) Set the property name with the given value for this code unit.voidsetProperty(String name, Saveable value) Set the property name with the given value for this code unit.voidsetProperty(String name, 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 referenceMethods inherited from class ghidra.app.util.PseudoInstruction
clearFallThroughOverride, clearRegister, equals, getAddress, getBaseContextRegister, getDefaultFallThrough, getDefaultFallThroughOffset, getDefaultFlows, getDefaultOperandRepresentation, getDefaultOperandRepresentationList, getDelaySlotDepth, getFallFrom, getFallThrough, getFlowOverride, getFlows, getFlowType, getInputObjects, getInstructionContext, getMemBuffer, getMnemonicString, getNext, getNumOperands, getOperandReferences, getOperandRefType, getOperandType, getOpObjects, getParsedBytes, getParsedLength, getParserContext, getParserContext, getPcode, getPcode, getPcode, getPrevious, getProcessorContext, getPrototype, getRegister, getRegister, getRegisters, getRegisterValue, getRepeatedByte, getResultObjects, getScalar, getSeparator, getValue, hasFallthrough, hasValue, isFallthrough, isFallThroughOverridden, isInDelaySlot, isLengthOverridden, setFallThrough, setFlowOverride, setInstructionBlock, setLengthOverride, setRegisterValue, setValue, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface ghidra.program.model.listing.CodeUnit
addMnemonicReference, addOperandReference, compareTo, contains, getAddressString, getBytes, getBytesInCodeUnit, getComment, getComment, getCommentAsArray, getCommentAsArray, getExternalReference, getLabel, getLength, getMaxAddress, getMinAddress, getMnemonicReferences, getPrimaryReference, getPrimarySymbol, getProgram, getReferenceIteratorTo, getReferencesFrom, getSymbols, removeExternalReference, removeMnemonicReference, removeOperandReference, setComment, setComment, setCommentAsArray, setCommentAsArray, setPrimaryMemoryReference, setRegisterReference, setStackReferenceMethods inherited from interface ghidra.program.model.lang.InstructionContext
getAddressMethods inherited from interface ghidra.program.model.mem.MemBuffer
getAddress, getBigInteger, getByte, getBytes, getInputStream, getInputStream, getInt, getLong, getMemory, getShort, getUnsignedByte, getUnsignedInt, getUnsignedShort, getVarLengthInt, getVarLengthUnsignedInt, isBigEndian, isInitializedMemoryMethods inherited from interface ghidra.program.model.util.PropertySet
getIntProperty, getObjectProperty, getStringProperty, getVoidProperty, hasProperty, propertyNames, removeProperty, setProperty, setProperty, setProperty, setProperty
-
Field Details
-
address
-
maxAddress
-
program
-
length
protected int length -
emptyAddrArray
-
hash
protected int hash -
bytes
protected byte[] bytes -
isBigEndian
protected boolean isBigEndian -
emptyMemRefs
-
comments
-
refMgr
-
-
Constructor Details
-
DecodeErrorInstruction
public DecodeErrorInstruction(Language language, Address address, RegisterValue ctx, String message) throws AddressOverflowException Construct an instruction to indicate a decode error- Parameters:
language- the emulation target langaugeaddress- the address where decode was attemptedctx- the input decode contextmessage- a message for theDecodePcodeExecutionExceptionif the emulator attempts to execute this instruction- Throws:
AddressOverflowException- never
-
-
Method Details
-
getMessage
Get the message for the exception, should this instruction be "executed"- Returns:
- the error message
-
invalidate
public void invalidate()Invalidate memory buffer -
isValid
public boolean isValid() -
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
-
getLength
public final int getLength()Get the length of the code unit. -
refreshIfNeeded
protected void refreshIfNeeded() -
getBytes
Gets 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
Description 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
Description copied from interface:MemBufferreturns the short at the given offset, taking into account the endianness.- 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 endianness.
- Throws:
MemoryAccessException- if a 2-byte short value cannot be read at the specified offset
-
getInt
Description copied from interface:MemBufferreturns the int at the given offset, taking into account the endianness.- 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 endianness.
- Throws:
MemoryAccessException- if a 4-byte integer value cannot be read at the specified offset
-
getLong
Description copied from interface:MemBufferreturns the long at the given offset, taking into account the endianness.- 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 endianness.
- Throws:
MemoryAccessException- if a 8-byte long value cannot be read at the specified offset
-
getBigInteger
Description copied from interface:MemBufferreturns the value at the given offset, taking into account the endianness.- 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 endianness.
- Throws:
MemoryAccessException- if the request size value cannot be read at the specified offset
-
setProperty
Set the property name with the given value for this code unit.- Specified by:
setPropertyin interfacePropertySet- 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 typesConcurrentModificationException- if this object is no longer valid.
-
setProperty
Set the property name with the given value for this code unit.- Specified by:
setPropertyin interfacePropertySet- 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 typesConcurrentModificationException- if this object is no longer valid.
-
setProperty
Set the property name with the given value for this code unit.- Specified by:
setPropertyin interfacePropertySet- 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 typesConcurrentModificationException- if this object is no longer valid.
-
setProperty
Mark the property name as having a value for this code unit.- Specified by:
setPropertyin interfacePropertySet- Parameters:
name- the name of the property to save.- Throws:
TypeMismatchException- if the property manager for name does not support void typesConcurrentModificationException- if this object is no longer valid.
-
getObjectProperty
Get 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.- Throws:
TypeMismatchException- if the property manager for name does not support object typesConcurrentModificationException- if this object is no longer valid.
-
getStringProperty
Get 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
- Throws:
TypeMismatchException- if the property manager for name does not support string typesConcurrentModificationException- if this object is no longer valid.
-
getIntProperty
Get 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 unitTypeMismatchException- if the property manager for name does not support int typesConcurrentModificationException- if this object is no longer valid.
-
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
Returns 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
- Throws:
TypeMismatchException- if the property manager for name does not support void typesConcurrentModificationException- if this object is no longer valid.
-
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
Remove the property value with the given name for this code unit.- Specified by:
removePropertyin interfacePropertySet- Parameters:
name- the name of the property.
-
getLabel
Deprecated.Get the label for this code unit.- Specified by:
getLabelin interfaceCodeUnit- Returns:
- the label for this code unit.
- Throws:
ConcurrentModificationException- if this object is no longer valid.
-
getSymbols
Get the symbols for this code unit.- Specified by:
getSymbolsin interfaceCodeUnit- Returns:
- the Symbols for this code unit.
- Throws:
ConcurrentModificationException- if this object is no longer valid.
-
getPrimarySymbol
Get the primary Symbol for this code unit.- Specified by:
getPrimarySymbolin interfaceCodeUnit- Returns:
- the Primary Symbol for this code unit.
- Throws:
ConcurrentModificationException- if this object is no longer valid.
-
getMinAddress
Get the starting address for this code unit.- Specified by:
getMinAddressin interfaceCodeUnit- Returns:
- the starting address for this code unit.
- Throws:
ConcurrentModificationException- if this object is no longer valid.
-
getMaxAddress
Get the ending address for this code unit.- Specified by:
getMaxAddressin interfaceCodeUnit- Returns:
- the ending address for this code unit.
- Throws:
ConcurrentModificationException- if this object is no longer valid.
-
getNextCodeUnit
Returns the code unit after this code unit..- Returns:
- the code unit after this code unit.
- Throws:
ConcurrentModificationException- if this object is no longer valid.
-
getPreviousCodeUnit
Returns the code unit before this code unit..- Returns:
- the code unit before this code unit.
- Throws:
ConcurrentModificationException- if this object is no longer valid.
-
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
-
getCommentAsArray
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:
IllegalArgumentException- if type is not one of the three types of comments supportedConcurrentModificationException- if this object is no longer valid.
-
setCommentAsArray
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:
IllegalArgumentException- if type is not one of the three types of comments supportedConcurrentModificationException- if this object is no longer valid.
-
setComment
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:
IllegalArgumentException- if type is not one of the three types of comments supportedConcurrentModificationException- if this object is no longer valid.
-
contains
Determines if this code unit contains the indicated address.- Specified by:
containsin interfaceCodeUnit- Parameters:
testAddr- the address to test- Returns:
- true if address is contained in the range.
- Throws:
ConcurrentModificationException- if this object is no longer valid.
-
compareTo
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:
ConcurrentModificationException- if this object is no longer valid.
-
getByte
Get 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 spaceIndexOutOfBoundsException- if offset is negativeMemoryAccessException- if memory cannot be read
-
getAddress
Get the Address which corresponds to the offset 0.- Specified by:
getAddressin interfaceMemBuffer- Returns:
- the current address of offset 0.
-
getMemory
Get the Memory object actually used by the MemBuffer. return the Memory used by this MemBuffer. -
addMnemonicReference
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
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
Remove a reference to the mnemonic for this instruction.- Specified by:
removeMnemonicReferencein interfaceCodeUnit- Parameters:
refAddr- the address to remove as a reference.
-
addOperandReference
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:
-
removeOperandReference
Remove a user defined reference to the operand at opIndex.- Specified by:
removeOperandReferencein interfaceCodeUnit- Parameters:
opIndex- operand indexrefAddr- address referencing the operand
-
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
-
setMemoryReference
-
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
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
Description copied from interface:CodeUnitReturns the primary reference for the operand index..- Specified by:
getPrimaryReferencein interfaceCodeUnit- Parameters:
index- operand index (0 is the first operand)- Returns:
- the primary reference for the operand index.
-
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.
-
getStackReference
-
removeStackReference
public void removeStackReference(int opIndex) -
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.
-
removeExternalReference
public 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.
-
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.
-
getProgram
Description copied from interface:CodeUnitReturns the program that generated this CodeUnit..- Specified by:
getProgramin interfaceCodeUnit- Returns:
- the program that generated this CodeUnit.
-
hashCode
public int hashCode()
-