Package ghidra.program.model.listing
Class InstructionStub
java.lang.Object
ghidra.program.model.listing.InstructionStub
- All Implemented Interfaces:
ProcessorContext
,ProcessorContextView
,CodeUnit
,Instruction
,MemBuffer
,PropertySet
InstructionStub can be extended for use by tests. It throws an UnsupportedOperationException
for all methods in the Instruction interface. Any method that is needed for your test can then
be overridden so it can provide its own test implementation and return value.
-
Field Summary
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
Fields inherited from interface ghidra.program.model.listing.Instruction
INVALID_DEPTH_CHANGE, MAX_LENGTH_OVERRIDE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addMnemonicReference
(Address refAddr, RefType refType, SourceType sourceType) Add a reference to the mnemonic for this code unit.void
addOperandReference
(int index, Address refAddr, RefType type, SourceType sourceType) Add a memory reference to the operand at the given index.void
Restores this instruction's fallthrough address back to the default fallthrough for this instruction.void
clearRegister
(Register register) Clears the register within this context.int
Compares the given address to the address range of this node.boolean
Returns true if address is contained in the range of this codeUnitGet the Address which corresponds to the offset 0.getAddress
(int opIndex) Get the Address for the given operand index if one exists.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.byte
getByte
(int offset) Get one byte from memory at the current position plus offset.byte[]
getBytes()
Get the bytes that make up this code unit.int
getBytes
(byte[] b, int memoryBufferOffset) Readsb.length
bytes from this memory buffer starting at the address of this memory buffer plus the given memoryBufferOffset from that position.void
getBytesInCodeUnit
(byte[] buffer, int bufferOffset) Copies max(buffer.length, code unit length) bytes into buffer starting at location offset in buffer.getComment
(int commentType) Get the comment for the given typeString[]
getCommentAsArray
(int commentType) Get the comment for the given type and parse it into an array of strings such that each line is its own string.Get the default fallthrough for this instruction.int
Get default fall-through offset in bytes from start of instruction to the fallthrough instruction.Address[]
Get an array of Address objects for all default flows established by the underlying instruction prototype.getDefaultOperandRepresentation
(int opIndex) Get the operand representation for the given operand index without markup.getDefaultOperandRepresentationList
(int opIndex) Get the operand representation for the given operand index.int
Get the number of delay slot instructions for this argument.getExternalReference
(int opIndex) Gets the external reference (if any) at the opIndexGet the fallthrough for this instruction, factoring in any fallthrough override and delay slotted instructions.Address[]
getFlows()
Get an array of Address objects for all flows other than a fall-through.Object[]
Get the Input objects used by this instruction.int
getInt
(int offset) returns the int at the given offset, taking into account the endianness.int
getIntProperty
(String name) Get the int property for name.getLabel()
Get the label for this code unit.int
Get length of this code unit.long
getLong
(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 starting address for this code unit.Get references for the mnemonic for this code unit.Get the mnemonic for this code unit, e.g., MOV, JMPgetNext()
int
Get the number of operands for this code unit.getObjectProperty
(String name) Get the object property for name; returns null if there is no name property for this code unit.getOperandReferences
(int index) Get the references for the operand index.getOperandRefType
(int index) Get the operand reference type for the given operand index.int
getOperandType
(int opIndex) Get the type of a specific operand.Object[]
getOpObjects
(int opIndex) Get objects used by this operand (Address, Scalar, Register ...)byte[]
Get the actual bytes parsed when forming this instruction.int
Get the actual number of bytes parsed when forming this instruction.PcodeOp[]
getPcode()
Get an array of PCode operations (micro code) that this instruction performs.PcodeOp[]
getPcode
(boolean includeOverrides) Get an array of PCode operations (micro code) that this instruction performs.PcodeOp[]
getPcode
(int opIndex) Get an array of PCode operations (micro code) that a particular operand performs to compute its value.getPrimaryReference
(int index) Get the primary reference for the operand index.Get the Primary Symbol for this code unit.Returns the program that generated this CodeUnit.Get an iterator over all references TO this code unit.Get ALL memory references FROM this code unit.getRegister
(int opIndex) If operand is a pure Register, return the register.getRegister
(String name) Get a Register given the name of a registerReturns all the Registers for the processor as an unmodifiable listgetRegisterValue
(Register register) Get the RegisterValue for the given register.Object[]
Get the Result objects produced/affected by this instruction These would probably only be Register or AddressgetScalar
(int opIndex) Returns the scalar at the given operand index.getSeparator
(int opIndex) Get the separator strings between an operand.short
getShort
(int offset) returns the short at the given offset, taking into account the endianness.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.Get the contents of a processor register as a BigInteger objectboolean
getVoidProperty
(String name) Returns whether this code unit is marked as having the name property.boolean
boolean
hasProperty
(String name) Returns true if the codeunit has the given property defined.boolean
Returns true if a value is defined for the given register.boolean
Returns true if the underlying bytes are in big-endian order, false if they are little endian.boolean
boolean
boolean
boolean
Determine if an instruction length override has been set.Get an iterator over the property names which have values applied.void
removeExternalReference
(int opIndex) Remove external reference (if any) at the given opIndex opIndex the index of the operand from which to remove any external reference.void
removeMnemonicReference
(Address refAddr) Remove a reference to the mnemonic for this code unit.void
removeOperandReference
(int index, Address refAddr) Remove a reference to the operand.void
removeProperty
(String name) Remove the property value associated with the given name .void
setComment
(int commentType, String comment) Set the comment for the given comment type.void
setCommentAsArray
(int commentType, String[] comment) Set the comment (with each line in its own string) for the given comment typevoid
setFallThrough
(Address addr) Overrides the instruction's default fallthrough address to the given address.void
setFlowOverride
(FlowOverride flowOverride) Set the flow override for this instruction.void
setLengthOverride
(int length) Set instruction length override.void
Sets a memory reference to be the primary reference at its address/opIndex location.void
setProperty
(String name) Set the named property.void
setProperty
(String name, int value) Set the named integer property with the given value.void
setProperty
(String name, Saveable value) Set the named property with the givenSaveable
value.void
setProperty
(String name, String value) Set the named string property with the given value.void
setRegisterReference
(int opIndex, Register reg, SourceType sourceType, RefType refType) Sets a register reference at theoffset
on 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 referencevoid
setRegisterValue
(RegisterValue value) Sets the specified register value within this context.void
setStackReference
(int opIndex, int offset, SourceType sourceType, RefType refType) Sets a stack reference at theoffset
on 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 referencevoid
setValue
(Register register, BigInteger value) Sets the value for a Register.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface ghidra.program.model.mem.MemBuffer
getInputStream, getInputStream, getUnsignedByte, getUnsignedInt, getUnsignedShort, getVarLengthInt, getVarLengthUnsignedInt, isInitializedMemory
-
Constructor Details
-
InstructionStub
public InstructionStub()
-
-
Method Details
-
getAddressString
Description copied from interface:CodeUnit
Get the string representation of the starting address for this code unit.- Specified by:
getAddressString
in 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
-
setProperty
Description copied from interface:PropertySet
Set the named property with the givenSaveable
value.- Specified by:
setProperty
in interfacePropertySet
- Parameters:
name
- the name of the property.value
- value to be stored.
-
setProperty
Description copied from interface:PropertySet
Set the named string property with the given value.- Specified by:
setProperty
in interfacePropertySet
- Parameters:
name
- the name of the property.value
- value to be stored.
-
setProperty
Description copied from interface:PropertySet
Set the named integer property with the given value.- Specified by:
setProperty
in interfacePropertySet
- Parameters:
name
- the name of the property.value
- value to be stored.
-
setProperty
Description copied from interface:PropertySet
Set the named property. This method is used for "void" properites. The property is either set or not set - there is no value- Specified by:
setProperty
in interfacePropertySet
- Parameters:
name
- the name of the property.
-
getObjectProperty
Description copied from interface:PropertySet
Get the object property for name; returns null if there is no name property for this code unit.- Specified by:
getObjectProperty
in interfacePropertySet
- Parameters:
name
- the name of the property- Returns:
Saveable
property value, with map-specific implementation class, or null.
-
getStringProperty
Description copied from interface:PropertySet
Get the string property for name; returns null if there is no name property for this code unit.- Specified by:
getStringProperty
in interfacePropertySet
- Parameters:
name
- the name of the property- Returns:
- string property value or null
-
getIntProperty
Description copied from interface:PropertySet
Get the int property for name.- Specified by:
getIntProperty
in 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:PropertySet
Returns true if the codeunit has the given property defined. This method works for all property map types.- Specified by:
hasProperty
in interfacePropertySet
- Parameters:
name
- the name of the property- Returns:
- true if property has been set, else false
-
getVoidProperty
Description copied from interface:PropertySet
Returns whether this code unit is marked as having the name property.- Specified by:
getVoidProperty
in interfacePropertySet
- Parameters:
name
- the name of the property- Returns:
- true if property has been set, else false
-
propertyNames
Description copied from interface:PropertySet
Get an iterator over the property names which have values applied.- Specified by:
propertyNames
in interfacePropertySet
- Returns:
- iterator of all property map names which have values applied
-
removeProperty
Description copied from interface:PropertySet
Remove the property value associated with the given name .- Specified by:
removeProperty
in interfacePropertySet
- Parameters:
name
- the name of the property
-
getLabel
Description copied from interface:CodeUnit
Get the label for this code unit. -
getSymbols
Description copied from interface:CodeUnit
Get the Symbols for this code unit.- Specified by:
getSymbols
in interfaceCodeUnit
-
getPrimarySymbol
Description copied from interface:CodeUnit
Get the Primary Symbol for this code unit.- Specified by:
getPrimarySymbol
in interfaceCodeUnit
-
getMinAddress
Description copied from interface:CodeUnit
Get the starting address for this code unit.- Specified by:
getMinAddress
in interfaceCodeUnit
-
getMaxAddress
Description copied from interface:CodeUnit
Get the ending address for this code unit.- Specified by:
getMaxAddress
in interfaceCodeUnit
-
getMnemonicString
Description copied from interface:CodeUnit
Get the mnemonic for this code unit, e.g., MOV, JMP- Specified by:
getMnemonicString
in interfaceCodeUnit
-
getComment
Description copied from interface:CodeUnit
Get the comment for the given type- Specified by:
getComment
in 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
Description copied from interface:CodeUnit
Get the comment for the given type and parse it into an array of strings such that each line is its own string.- Specified by:
getCommentAsArray
in interfaceCodeUnit
- Parameters:
commentType
- either EOL_COMMENT, PRE_COMMENT, POST_COMMENT, or REPEATABLE_COMMENT- 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.
-
setComment
Description copied from interface:CodeUnit
Set the comment for the given comment type. Passingnull
clears the comment- Specified by:
setComment
in interfaceCodeUnit
- Parameters:
commentType
- either EOL_COMMENT, PRE_COMMENT, POST_COMMENT, or REPEATABLE_COMMENTcomment
- comment for code unit; null clears the comment
-
setCommentAsArray
Description copied from interface:CodeUnit
Set the comment (with each line in its own string) for the given comment type- Specified by:
setCommentAsArray
in interfaceCodeUnit
- Parameters:
commentType
- either EOL_COMMENT, PRE_COMMENT, POST_COMMENT, or REPEATABLE_COMMENTcomment
- an array of strings where each string is a single line of the comment.
-
getLength
public int getLength()Description copied from interface:CodeUnit
Get length of this code unit. NOTE: If aninstruction length-override
is set this method will return the reduced length. -
getParsedLength
public int getParsedLength()Description copied from interface:Instruction
Get the actual number of bytes parsed when forming this instruction. While this method will generally return the same value asCodeUnit.getLength()
, its value will differ whenInstruction.setLengthOverride(int)
has been used. In addition, it is important to note thatCodeUnit.getMaxAddress()
will always reflect a non-overlapping address which reflectsCodeUnit.getLength()
. This method is equivalent to the following code for a given instruction:
InstructionPrototype
proto = instruction.Instruction.getPrototype()
; int length = proto.getLength()
;- Specified by:
getParsedLength
in interfaceInstruction
- Returns:
- the actual number of bytes parsed when forming this instruction
-
getBytes
Description copied from interface:CodeUnit
Get the bytes that make up this code unit. NOTE: If aninstruction length-override
is set this method will not return all bytes associated with theinstruction prototype
.- Specified by:
getBytes
in 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.
-
getParsedBytes
Description copied from interface:Instruction
Get the actual bytes parsed when forming this instruction. While this method will generally return the same value asCodeUnit.getBytes()
, it will return more bytes whenInstruction.setLengthOverride(int)
has been used. In this override situation, the bytes returned will generally duplicate some of the parsed bytes associated with the next instruction that this instruction overlaps. This method is equivalent to the following code for a given instruction:
InstructionPrototype
proto = instruction.Instruction.getPrototype()
;Memory
mem = instruction.MemBuffer.getMemory()
; byte[] bytes = mem.getBytes(instruction.MemBuffer.getAddress()
, proto.getLength()); int length = proto.getLength()
;- Specified by:
getParsedBytes
in interfaceInstruction
- Returns:
- the actual number of bytes parsed when forming this instruction
- Throws:
MemoryAccessException
- if the full number of bytes could not be read
-
getBytesInCodeUnit
Description copied from interface:CodeUnit
Copies max(buffer.length, code unit length) bytes into buffer starting at location offset in buffer.- Specified by:
getBytesInCodeUnit
in 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.
-
contains
Description copied from interface:CodeUnit
Returns true if address is contained in the range of this codeUnit -
compareTo
Description copied from interface:CodeUnit
Compares the given address to the address range of this node. -
addMnemonicReference
Description copied from interface:CodeUnit
Add a reference to the mnemonic for this code unit.- Specified by:
addMnemonicReference
in interfaceCodeUnit
- Parameters:
refAddr
- address to add as a reference.refType
- the type of reference to add.sourceType
- the source of this reference
-
removeMnemonicReference
Description copied from interface:CodeUnit
Remove a reference to the mnemonic for this code unit.- Specified by:
removeMnemonicReference
in interfaceCodeUnit
- Parameters:
refAddr
- the address to remove as a reference.
-
getMnemonicReferences
Description copied from interface:CodeUnit
Get references for the mnemonic for this code unit.- Specified by:
getMnemonicReferences
in interfaceCodeUnit
- 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:CodeUnit
Get the references for the operand index.- Specified by:
getOperandReferences
in interfaceCodeUnit
- Parameters:
index
- operand index (0 is the first operand)
-
getPrimaryReference
Description copied from interface:CodeUnit
Get the primary reference for the operand index.- Specified by:
getPrimaryReference
in interfaceCodeUnit
- Parameters:
index
- operand index (0 is the first operand)
-
addOperandReference
Description copied from interface:CodeUnit
Add a memory reference to the operand at the given index.- Specified by:
addOperandReference
in interfaceCodeUnit
- Parameters:
index
- operand indexrefAddr
- reference addresstype
- the reference type to be added.sourceType
- the source of this reference
-
removeOperandReference
Description copied from interface:CodeUnit
Remove a reference to the operand.- Specified by:
removeOperandReference
in interfaceCodeUnit
- Parameters:
index
- operand indexrefAddr
- address referencing the operand
-
getReferencesFrom
Description copied from interface:CodeUnit
Get ALL memory references FROM this code unit.- Specified by:
getReferencesFrom
in interfaceCodeUnit
- Returns:
- an array of memory references from this codeUnit or an empty array if there are no references.
-
getReferenceIteratorTo
Description copied from interface:CodeUnit
Get an iterator over all references TO this code unit.- Specified by:
getReferenceIteratorTo
in interfaceCodeUnit
-
getProgram
Description copied from interface:CodeUnit
Returns the program that generated this CodeUnit.- Specified by:
getProgram
in interfaceCodeUnit
-
getExternalReference
Description copied from interface:CodeUnit
Gets the external reference (if any) at the opIndex- Specified by:
getExternalReference
in 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:CodeUnit
Remove external reference (if any) at the given opIndex opIndex the index of the operand from which to remove any external reference.- Specified by:
removeExternalReference
in interfaceCodeUnit
-
setPrimaryMemoryReference
Description copied from interface:CodeUnit
Sets 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:
setPrimaryMemoryReference
in interfaceCodeUnit
- Parameters:
ref
- the reference to be set as primary.
-
setStackReference
Description copied from interface:CodeUnit
Sets a stack reference at theoffset
on 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:
setStackReference
in 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:CodeUnit
Sets a register reference at theoffset
on 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:
setRegisterReference
in 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...
-
getNumOperands
public int getNumOperands()Description copied from interface:CodeUnit
Get the number of operands for this code unit.- Specified by:
getNumOperands
in interfaceCodeUnit
-
getAddress
Description copied from interface:CodeUnit
Get the Address for the given operand index if one exists. Data objects have one operand (the value).- Specified by:
getAddress
in 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.
-
getScalar
Description copied from interface:CodeUnit
Returns the scalar at the given operand index. Data objects have one operand (the value). -
getByte
Description copied from interface:MemBuffer
Get one byte from memory at the current position plus offset.- Specified by:
getByte
in interfaceMemBuffer
- Parameters:
offset
- the displacement from the current position.- Returns:
- the data at offset from the current position.
- Throws:
MemoryAccessException
- if memory cannot be read at the specified offset
-
getBytes
public int getBytes(byte[] b, int memoryBufferOffset) Description copied from interface:MemBuffer
Readsb.length
bytes 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:
getBytes
in interfaceMemBuffer
- Parameters:
b
- the buffer into which bytes will be placedmemoryBufferOffset
- 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.
-
getAddress
Description copied from interface:MemBuffer
Get the Address which corresponds to the offset 0.- Specified by:
getAddress
in interfaceMemBuffer
- Returns:
- the current address of offset 0.
-
getMemory
Description copied from interface:MemBuffer
Get the Memory object actually used by the MemBuffer. -
isBigEndian
public boolean isBigEndian()Description copied from interface:MemBuffer
Returns true if the underlying bytes are in big-endian order, false if they are little endian.- Specified by:
isBigEndian
in interfaceMemBuffer
- Returns:
- true if the underlying bytes are in big-endian order, false if they are little endian.
-
getShort
Description copied from interface:MemBuffer
returns the short at the given offset, taking into account the endianness.- Specified by:
getShort
in 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:MemBuffer
returns the int at the given offset, taking into account the endianness.- Specified by:
getInt
in 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:MemBuffer
returns the long at the given offset, taking into account the endianness.- Specified by:
getLong
in 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:MemBuffer
returns the value at the given offset, taking into account the endianness.- Specified by:
getBigInteger
in 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
-
setValue
Description copied from interface:ProcessorContext
Sets the value for a Register.- Specified by:
setValue
in interfaceProcessorContext
- Parameters:
register
- the register to have its value setvalue
- the value for the register (null is not permitted).- Throws:
ContextChangeException
- an illegal attempt to change context was made
-
setRegisterValue
Description copied from interface:ProcessorContext
Sets the specified register value within this context.- Specified by:
setRegisterValue
in interfaceProcessorContext
- Parameters:
value
- register value- Throws:
ContextChangeException
- an illegal attempt to change context was made
-
clearRegister
Description copied from interface:ProcessorContext
Clears the register within this context.- Specified by:
clearRegister
in interfaceProcessorContext
- Parameters:
register
- register to be cleared.- Throws:
ContextChangeException
- an illegal attempt to change context was made
-
getBaseContextRegister
- Specified by:
getBaseContextRegister
in interfaceProcessorContextView
- Returns:
- the base processor context register or null if one has not been defined
-
getRegisters
Description copied from interface:ProcessorContextView
Returns all the Registers for the processor as an unmodifiable list- Specified by:
getRegisters
in interfaceProcessorContextView
- Returns:
- all the Registers for the processor
-
getRegister
Description copied from interface:ProcessorContextView
Get a Register given the name of a register- Specified by:
getRegister
in interfaceProcessorContextView
- Parameters:
name
- the name of the register.- Returns:
- The register with the given name.
-
getValue
Description copied from interface:ProcessorContextView
Get the contents of a processor register as a BigInteger object- Specified by:
getValue
in interfaceProcessorContextView
- Parameters:
register
- register to get the value for- Returns:
- a BigInteger object containing the value of the register if a value exists, otherwise null.
-
getRegisterValue
Description copied from interface:ProcessorContextView
Get the RegisterValue for the given register.- Specified by:
getRegisterValue
in interfaceProcessorContextView
- Parameters:
register
- register to get the value for- Returns:
- RegisterValue object containing the value of the register if a value exists, otherwise null.
-
hasValue
Description copied from interface:ProcessorContextView
Returns true if a value is defined for the given register.- Specified by:
hasValue
in interfaceProcessorContextView
- Parameters:
register
- the register to check for a value.- Returns:
- true if the given register has a value.
-
getPrototype
- Specified by:
getPrototype
in interfaceInstruction
- Returns:
- the prototype for this instruction.
-
getRegister
Description copied from interface:Instruction
If operand is a pure Register, return the register.- Specified by:
getRegister
in interfaceInstruction
- Parameters:
opIndex
- index of the operand.- Returns:
- A register if the operand represents a register.
-
getOpObjects
Description copied from interface:Instruction
Get objects used by this operand (Address, Scalar, Register ...)- Specified by:
getOpObjects
in interfaceInstruction
- Parameters:
opIndex
- index of the operand.- Returns:
- objects used by this operand (Address, Scalar, Register ...)
-
getInputObjects
Description copied from interface:Instruction
Get the Input objects used by this instruction. These could be Scalars, Registers, Addresses- Specified by:
getInputObjects
in interfaceInstruction
- Returns:
- an array of objects that are used by this instruction
-
getResultObjects
Description copied from interface:Instruction
Get the Result objects produced/affected by this instruction These would probably only be Register or Address- Specified by:
getResultObjects
in interfaceInstruction
- Returns:
- an array of objects that are affected by this instruction
-
getDefaultOperandRepresentation
Description copied from interface:Instruction
Get the operand representation for the given operand index without markup.- Specified by:
getDefaultOperandRepresentation
in interfaceInstruction
- Parameters:
opIndex
- operand index- Returns:
- operand represented as a string.
-
getDefaultOperandRepresentationList
Description copied from interface:Instruction
Get the operand representation for the given operand index. A list of Register, Address, Scalar, Character and String objects is returned - without markup!- Specified by:
getDefaultOperandRepresentationList
in interfaceInstruction
- Parameters:
opIndex
- operand index- Returns:
- ArrayList of pieces of the operand representation. Unsupported languages may return null.
-
getSeparator
Description copied from interface:Instruction
Get the separator strings between an operand. The separator string for 0 are the characters before the first operand. The separator string for numOperands+1 are the characters after the last operand.- Specified by:
getSeparator
in interfaceInstruction
- Parameters:
opIndex
- valid values are 0 thru numOperands+1- Returns:
- separator string, or null if there is no string
-
getOperandType
public int getOperandType(int opIndex) Description copied from interface:Instruction
Get the type of a specific operand.- Specified by:
getOperandType
in interfaceInstruction
- Parameters:
opIndex
- the index of the operand. (zero based)- Returns:
- the type of the operand.
- See Also:
-
getOperandRefType
Description copied from interface:Instruction
Get the operand reference type for the given operand index.- Specified by:
getOperandRefType
in interfaceInstruction
- Parameters:
index
- operand index- Returns:
- the operand reference type for the given operand index.
-
getDefaultFallThroughOffset
public int getDefaultFallThroughOffset()Description copied from interface:Instruction
Get default fall-through offset in bytes from start of instruction to the fallthrough instruction. This accounts for any instructions contained with delay slots.- Specified by:
getDefaultFallThroughOffset
in interfaceInstruction
- Returns:
- default fall-through offset or zero (0) if instruction has no fallthrough
-
getDefaultFallThrough
Description copied from interface:Instruction
Get the default fallthrough for this instruction. This accounts for any instructions contained with delay slots.- Specified by:
getDefaultFallThrough
in interfaceInstruction
- Returns:
- fall-through address or null if instruction has no default fallthrough
-
getFallThrough
Description copied from interface:Instruction
Get the fallthrough for this instruction, factoring in any fallthrough override and delay slotted instructions.- Specified by:
getFallThrough
in interfaceInstruction
- Returns:
- fall-through address or null if instruction has no fallthrough
-
getFallFrom
- Specified by:
getFallFrom
in interfaceInstruction
- Returns:
- the Address for the instruction that fell through to
this instruction.
This is useful for handling instructions that are found
in a delay slot.
Note: if an instruction is in a delayslot, then it may have
a branch into the delayslot, which is handled as follows
JMPIF Y, X lab: _ADD getFallFrom() = JMPIF MOV getFallFrom() = _ADD JMP Y, X lab: _ADD getFallFrom() = null MOV getFallFrom() = _ADD JMPIF Y, X _ADD getFallFrom() = JMPIF MOV getFallFrom() = JMPIF JMP Y, X _ADD getFallFrom() = JMP MOV getFallFrom() = null
-
getFlows
Description copied from interface:Instruction
Get an array of Address objects for all flows other than a fall-through. This will include any flow references which have been added to the instruction.- Specified by:
getFlows
in interfaceInstruction
- Returns:
- flow addresses or null if there are no flows
-
getDefaultFlows
Description copied from interface:Instruction
Get an array of Address objects for all default flows established by the underlying instruction prototype. References are ignored.- Specified by:
getDefaultFlows
in interfaceInstruction
- Returns:
- flow addresses or null if there are no flows
-
getFlowType
- Specified by:
getFlowType
in interfaceInstruction
- Returns:
- the flow type of this instruction (how this instruction flows to the next instruction).
-
isFallthrough
public boolean isFallthrough()- Specified by:
isFallthrough
in interfaceInstruction
- Returns:
- true if this instruction has no execution flow other than fall-through.
-
hasFallthrough
public boolean hasFallthrough()- Specified by:
hasFallthrough
in interfaceInstruction
- Returns:
- true if this instruction has a fall-through flow.
-
getFlowOverride
- Specified by:
getFlowOverride
in interfaceInstruction
- Returns:
- the flow override which may have been set on this instruction.
-
setLengthOverride
public void setLengthOverride(int length) Description copied from interface:Instruction
Set instruction length override. Specified length must be in the range 0..7 where 0 clears the setting and adopts the default length. The specified length must be less than the actual number of bytes consumed by the prototype and be a multiple of the language specified instruction alignment.NOTE: Use of the feature with a delay slot instruction is discouraged.
- Specified by:
setLengthOverride
in interfaceInstruction
- Parameters:
length
- effective instruction code unit length.
-
isLengthOverridden
public boolean isLengthOverridden()Description copied from interface:Instruction
Determine if an instruction length override has been set.- Specified by:
isLengthOverridden
in interfaceInstruction
- Returns:
- true if length override has been set else false.
-
setFlowOverride
Description copied from interface:Instruction
Set the flow override for this instruction.- Specified by:
setFlowOverride
in interfaceInstruction
- Parameters:
flowOverride
- flow override setting orFlowOverride.NONE
to clear.
-
getPcode
Description copied from interface:Instruction
Get an array of PCode operations (micro code) that this instruction performs. Flow overrides are not factored into pcode.- Specified by:
getPcode
in interfaceInstruction
- Returns:
- an array of Pcode operations, a zero length array if the language does not support PCode
-
getPcode
Description copied from interface:Instruction
Get an array of PCode operations (micro code) that this instruction performs. NOTE: If includeOverrides is true, unique temporary varnodes may be produced which vary in size to those produced for other instructions.- Specified by:
getPcode
in interfaceInstruction
- Parameters:
includeOverrides
- if true any flow overrides will be factored into generated pcode.- Returns:
- an array of Pcode operations, a zero length array if the language does not support PCode
-
getPcode
Description copied from interface:Instruction
Get an array of PCode operations (micro code) that a particular operand performs to compute its value.- Specified by:
getPcode
in interfaceInstruction
- Parameters:
opIndex
- index of the operand to retrieve PCode- Returns:
- an array of PCode operations, a zero length array if the language does not support PCode
-
getDelaySlotDepth
public int getDelaySlotDepth()Description copied from interface:Instruction
Get the number of delay slot instructions for this argument. This should be 0 for instructions which don't have a delay slot. This is used to support the delay slots found on some RISC processors such as SPARC and the PA-RISC. This returns an integer instead of a boolean in case some other processor executes more than one instruction from a delay slot.- Specified by:
getDelaySlotDepth
in interfaceInstruction
- Returns:
- delay slot depth (number of instructions)
-
isInDelaySlot
public boolean isInDelaySlot()- Specified by:
isInDelaySlot
in interfaceInstruction
- Returns:
- true if this instruction was disassembled in a delay slot
-
getNext
- Specified by:
getNext
in interfaceInstruction
- Returns:
- the instruction following this one in address order or null if none found.
-
getPrevious
- Specified by:
getPrevious
in interfaceInstruction
- Returns:
- the instruction before this one in address order or null if none found.
-
setFallThrough
Description copied from interface:Instruction
Overrides the instruction's default fallthrough address to the given address. The given address may be null to indicate that the instruction has no fallthrough.- Specified by:
setFallThrough
in interfaceInstruction
- Parameters:
addr
- the address to be used as this instructions fallthrough address. May be null.
-
clearFallThroughOverride
public void clearFallThroughOverride()Description copied from interface:Instruction
Restores this instruction's fallthrough address back to the default fallthrough for this instruction.- Specified by:
clearFallThroughOverride
in interfaceInstruction
-
isFallThroughOverridden
public boolean isFallThroughOverridden()- Specified by:
isFallThroughOverridden
in interfaceInstruction
- Returns:
- true if this instructions fallthrough has been overriden.
-
getInstructionContext
- Specified by:
getInstructionContext
in interfaceInstruction
- Returns:
- the instruction context for this instruction
-