Interface IInstruction
- All Known Subinterfaces:
IDalvikInstruction
,IDInstruction
,IEAssign
,IECall
,IEJump
,IEJumpFar
,IEJumpWithOptionalCondition
,IENop
,IEReturn
,IEStatement
,IESwitch
,IEUntranslatedInstruction
,ILocatedInstruction
,IResizableInstruction
- All Known Implementing Classes:
AbstractInstruction
,AddressableInstruction
A generic interface to represent machine-code or bytecode instructions. Note that this interface
does not specify an address or offset for the instruction.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionboolean
canThrow()
Determine if the instruction can throw an exception.collectIndirectCallReferences
(long instructionAddress) Collect the list of dereferenced addresses computed by a call-to-sub instruction.Format the instruction for printingdefault ACS
getACS()
getBreakingFlow
(long instructionAddress) Determine if an instruction breaks the flow of execution.byte[]
getCode()
Get the binary code that makes up this instruction.default int
default void
Determine the variables defined and used by the instruction.void
Determine the variables defined and used by the instruction.default DefUseInfo
getDefUseInfo
(long instructionAddress, int flags) Determine the variables defined and used by the instruction.The instruction mnemonic.default IInstructionOperand
getOperand
(int index) Get an operand by index.Get the list of operands for this instruction.Get the instruction's optional prefix(es).default long
getPrimaryBranchAddress
(long instructionAddress) Convenience method used to retrieve the primary target of this branching instruction.int
Get the mode the processor was in when it parsed and created this instruction.getRoutineCall
(long instructionAddress) Determine if an instruction branches to (or calls into) a sub-routine.int
getSize()
Get the instruction size in bytes.
-
Method Details
-
getProcessorMode
int getProcessorMode()Get the mode the processor was in when it parsed and created this instruction. Refer toIProcessor
MODE_xxx
.- Returns:
- the mode, 0 for none/default
-
getSize
int getSize()Get the instruction size in bytes.- Returns:
- the instruction size
-
getCode
byte[] getCode()Get the binary code that makes up this instruction.- Returns:
- an array of bytes, or null if the instruction is abstract
-
getPrefix
String getPrefix()Get the instruction's optional prefix(es).- Returns:
- the prefix (or prefix string list), null if none
-
getMnemonic
String getMnemonic()The instruction mnemonic.- Returns:
-
getOperands
IInstructionOperand[] getOperands()Get the list of operands for this instruction.- Returns:
- a list (possibly empty) of operands, or null if operands are not applicable to the instruction set
-
getOperand
Get an operand by index.- Parameters:
index
-- Returns:
-
getCountOfOperands
default int getCountOfOperands() -
getBreakingFlow
Determine if an instruction breaks the flow of execution.Examples: jump instructions, conditional jumps, return-to-caller instructions, etc. Sub-routine calls should not be regarded as flow-breakers by this method. Refer to
getRoutineCall
.- Parameters:
instructionAddress
- the address of the current instruction- Returns:
IFlowInformation.isBroken()
is true if the instruction breaks the current flow of execution (sub-routine call instructions are excluded) , false otherwise; if true,IFlowInformation.getTargets()
may be filled with potential addresses, and the first entry should be the fall-through instruction, if there is any
-
getRoutineCall
Determine if an instruction branches to (or calls into) a sub-routine.Under normal circumstances, those instructions save the return address (e.g., on a stack or in a register). Therefore, the fall-through address is implied and should not be returned by
IFlowInformation.getTargets()
. The list of targets should contain the branch address - or addresses, for example if the processor branching instruction allows branch selection.- Parameters:
instructionAddress
- the address of the current instruction- Returns:
IFlowInformation.isBroken()
is true if the instruction calls into a sub-routine, false otherwise; if true,IFlowInformation.getTargets()
may be filled, else its contents is irrelevant
-
collectIndirectCallReferences
Collect the list of dereferenced addresses computed by a call-to-sub instruction. This method should not be confused withgetRoutineCall(long)
.- Parameters:
instructionAddress
- the address of the current instruction- Returns:
IFlowInformation.isBroken()
is true if the instruction indirectly calls into a sub-routine, false otherwise (in particular for direct routine calls); if true, theIFlowInformation.getTargets()
may be filled with the dereferenced addresses, else its contents is irrelevant
-
getPrimaryBranchAddress
default long getPrimaryBranchAddress(long instructionAddress) Convenience method used to retrieve the primary target of this branching instruction. If the instruction is not branching, or if the target cannot be determined, -1 is returned. If the instruction has multiple branches, only one is returned.- Parameters:
instructionAddress
- the address of the current instruction- Returns:
- the target address, or -1 on error
-
getDefUse
Determine the variables defined and used by the instruction.- Parameters:
def
- output, the list of variables defined by the instruction.use
- output, the list of variables used by the instructioncontext
- optional context (implementation specific)
-
getDefUse
Determine the variables defined and used by the instruction.- Parameters:
def
- output, the list of variables defined by the instruction.use
- output, the list of variables used by the instruction
-
getDefUseInfo
Determine the variables defined and used by the instruction. This method is an extended version ofgetDefUse(List, List, Object)
.- Parameters:
instructionAddress
- address of the instructionflags
- seeDefUseInfo.XXX
static final flags- Returns:
- Throws:
NotImplementedException
-
getInstructionFlags
Collection<InstructionFlags> getInstructionFlags()- Returns:
- instruction flags, never null
-
canThrow
boolean canThrow()Determine if the instruction can throw an exception.- Returns:
- true if the exception can raise
-
format
Format the instruction for printing- Parameters:
context
- optional context, used to provide a better representation of the instruction (for instance, resolving strings or method names.) The implementor should do its best to return a decent result even if context is null.- Returns:
-
getACS
- Returns:
-