Package ghidra.program.model.listing
Interface Instruction
-
- All Superinterfaces:
CodeUnit
,MemBuffer
,ProcessorContext
,ProcessorContextView
- All Known Implementing Classes:
InstructionDB
,InstructionStub
,PseudoInstruction
public interface Instruction extends CodeUnit, ProcessorContext
Interface to define an instruction for a processor.
-
-
Field Summary
Fields Modifier and Type Field Description static int
INVALID_DEPTH_CHANGE
-
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
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
clearFallThroughOverride()
Restores this instruction's fallthrough address back to the default fallthrough for this instruction.Address
getDefaultFallThrough()
Get the default fallthrough for this instruction.int
getDefaultFallThroughOffset()
Get default fall-through offset in bytes from start of instruction to the fallthrough instruction.Address[]
getDefaultFlows()
Get an array of Address objects for all default flows established by the underlying instruction prototype.java.lang.String
getDefaultOperandRepresentation(int opIndex)
Get the operand representation for the given operand index without markup.java.util.List<java.lang.Object>
getDefaultOperandRepresentationList(int opIndex)
Get the operand representation for the given operand index.int
getDelaySlotDepth()
Get the number of delay slot instructions for this argument.Address
getFallFrom()
Get the Address for the instruction that fell through to this instruction.Address
getFallThrough()
Get the fallthrough for this instruction, factoring in any fallthrough override and delay slotted instructions.FlowOverride
getFlowOverride()
Returns the flow override which may have been set on this instruction.Address[]
getFlows()
Get an array of Address objects for all flows other than a fall-through.FlowType
getFlowType()
Get the flow type of this instruction (how this instruction flows to the next instruction).java.lang.Object[]
getInputObjects()
Get the Input objects used by this instruction.InstructionContext
getInstructionContext()
Instruction
getNext()
Get the instruction following this one in address order.RefType
getOperandRefType(int index)
Get the operand reference type for the given operand index.int
getOperandType(int opIndex)
Get the type of a specific operand.java.lang.Object[]
getOpObjects(int opIndex)
Get objects used by this operand (Address, Scalar, Register ...)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.Instruction
getPrevious()
Get the instruction before this one in address order.InstructionPrototype
getPrototype()
Get the prototype for this instruction.Register
getRegister(int opIndex)
If operand is a pure Register, return the register.java.lang.Object[]
getResultObjects()
Get the Result objects produced/affected by this instruction These would probably only be Register or Addressjava.lang.String
getSeparator(int opIndex)
Get the separator strings between an operand.boolean
hasFallthrough()
Returns true if this instruction has a fall-through flow.boolean
isFallthrough()
Returns true if this instruction has no execution flow other than fall-through.boolean
isFallThroughOverridden()
Returns true if this instructions fallthrough has been overriden.boolean
isInDelaySlot()
Return true if this instruction was disassembled in a delay slotvoid
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.-
Methods inherited from interface ghidra.program.model.listing.CodeUnit
addMnemonicReference, addOperandReference, compareTo, contains, getAddress, getAddressString, getBytes, getBytesInCodeUnit, getComment, getCommentAsArray, getExternalReference, getIntProperty, getLabel, getLength, getMaxAddress, getMinAddress, getMnemonicReferences, getMnemonicString, getNumOperands, getObjectProperty, getOperandReferences, getPrimaryReference, getPrimarySymbol, getProgram, getReferenceIteratorTo, getReferencesFrom, getScalar, 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
-
Methods inherited from interface ghidra.program.model.lang.ProcessorContext
clearRegister, setRegisterValue, setValue
-
Methods inherited from interface ghidra.program.model.lang.ProcessorContextView
getBaseContextRegister, getRegister, getRegisters, getRegisterValue, getValue, hasValue
-
-
-
-
Field Detail
-
INVALID_DEPTH_CHANGE
static final int INVALID_DEPTH_CHANGE
- See Also:
- Constant Field Values
-
-
Method Detail
-
getPrototype
InstructionPrototype getPrototype()
Get the prototype for this instruction.
-
getRegister
Register getRegister(int opIndex)
If operand is a pure Register, return the register.- Parameters:
opIndex
- index of the operand.- Returns:
- A register if the operand represents a register.
-
getOpObjects
java.lang.Object[] getOpObjects(int opIndex)
Get objects used by this operand (Address, Scalar, Register ...)- Parameters:
opIndex
- index of the operand.
-
getInputObjects
java.lang.Object[] getInputObjects()
Get the Input objects used by this instruction. These could be Scalars, Registers, Addresses- Returns:
- an array of objects that are used by this instruction
-
getResultObjects
java.lang.Object[] getResultObjects()
Get the Result objects produced/affected by this instruction These would probably only be Register or Address- Returns:
- an array of objects that are affected by this instruction
-
getDefaultOperandRepresentation
java.lang.String getDefaultOperandRepresentation(int opIndex)
Get the operand representation for the given operand index without markup.- Parameters:
opIndex
- operand index- Returns:
- operand represented as a string.
-
getDefaultOperandRepresentationList
java.util.List<java.lang.Object> getDefaultOperandRepresentationList(int opIndex)
Get the operand representation for the given operand index. A list of Register, Address, Scalar, Character and String objects is returned - without markup!- Parameters:
opIndex
- operand index- Returns:
- ArrayList of pieces of the operand representation. Unsupported languages may return null.
-
getSeparator
java.lang.String getSeparator(int opIndex)
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.- Parameters:
opIndex
- valid values are 0 thru numOperands+1- Returns:
- separator string, or null if there is no string
-
getOperandType
int getOperandType(int opIndex)
Get the type of a specific operand.- Parameters:
opIndex
- the index of the operand. (zero based)- Returns:
- the type of the operand.
-
getOperandRefType
RefType getOperandRefType(int index)
Get the operand reference type for the given operand index.- Parameters:
index
- operand index
-
getDefaultFallThroughOffset
int getDefaultFallThroughOffset()
Get default fall-through offset in bytes from start of instruction to the fallthrough instruction. This accounts for any instructions contained with delay slots.- Returns:
- default fall-through offset or zero (0) if instruction has no fallthrough
-
getDefaultFallThrough
Address getDefaultFallThrough()
Get the default fallthrough for this instruction. This accounts for any instructions contained with delay slots.- Returns:
- fall-through address or null if instruction has no default fallthrough
-
getFallThrough
Address getFallThrough()
Get the fallthrough for this instruction, factoring in any fallthrough override and delay slotted instructions.- Returns:
- fall-through address or null if instruction has no fallthrough
-
getFallFrom
Address getFallFrom()
Get the Address for the instruction that fell through to this instruction. This is useful for handling instructions that are found in a delay slot.
-
getFlows
Address[] getFlows()
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.- Returns:
- flow addresses or null if there are no flows
-
getDefaultFlows
Address[] getDefaultFlows()
Get an array of Address objects for all default flows established by the underlying instruction prototype. References are ignored.- Returns:
- flow addresses or null if there are no flows
-
getFlowType
FlowType getFlowType()
Get the flow type of this instruction (how this instruction flows to the next instruction).
-
isFallthrough
boolean isFallthrough()
Returns true if this instruction has no execution flow other than fall-through.
-
hasFallthrough
boolean hasFallthrough()
Returns true if this instruction has a fall-through flow.
-
getFlowOverride
FlowOverride getFlowOverride()
Returns the flow override which may have been set on this instruction.
-
setFlowOverride
void setFlowOverride(FlowOverride flowOverride)
Set the flow override for this instruction.- Parameters:
flowOverride
-
-
getPcode
PcodeOp[] getPcode()
Get an array of PCode operations (micro code) that this instruction performs. Flow overrides are not factored into pcode.- Returns:
- an array of Pcode operations, a zero length array if the language does not support PCode
-
getPcode
PcodeOp[] getPcode(boolean includeOverrides)
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. If your analysis is sensitive to this you should consider usingInstructionPrototype#getPcode(ghidra.program.model.mem.MemBuffer, ProcessorContext, FlowOverride, ghidra.program.model.address.UniqueAddressFactory)
instead with your ownUniqueAddressFactory
to prevent duplication within your scope of analysis. by this method may not be suitable for use with certain analysis- 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
PcodeOp[] getPcode(int opIndex)
Get an array of PCode operations (micro code) that a particular operand performs to compute its value.- 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
int getDelaySlotDepth()
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.
-
isInDelaySlot
boolean isInDelaySlot()
Return true if this instruction was disassembled in a delay slot
-
getNext
Instruction getNext()
Get the instruction following this one in address order.
-
getPrevious
Instruction getPrevious()
Get the instruction before this one in address order.
-
setFallThrough
void setFallThrough(Address addr)
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.- Parameters:
addr
- the address to be used as this instructions fallthrough address. May be null.
-
clearFallThroughOverride
void clearFallThroughOverride()
Restores this instruction's fallthrough address back to the default fallthrough for this instruction.
-
isFallThroughOverridden
boolean isFallThroughOverridden()
Returns true if this instructions fallthrough has been overriden.
-
getInstructionContext
InstructionContext getInstructionContext()
-
-