java.lang.Object | |
↳ | com.pnfsoftware.jeb.core.units.code.asm.cfg.BasicBlock<InsnType extends com.pnfsoftware.jeb.core.units.code.IInstruction> |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
BasicBlock(long base)
Create a new empty basic block.
| |||||||||||
BasicBlock(long base, List<InsnType> insns, List<Long> dstOffsets, List<Long> irrdstOffsets, boolean unknownDst)
Create a new basic block.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
void |
add(int index, InsnType insn)
DANGEROUS METHOD.
| ||||||||||
void |
add(InsnType insn)
DANGEROUS METHOD.
| ||||||||||
void |
addAll(Collection<InsnType> coll)
DANGEROUS METHOD.
| ||||||||||
void |
addAll(int index, Collection<InsnType> coll)
DANGEROUS METHOD.
| ||||||||||
Iterable<AddressableInstruction<InsnType>> | addressableInstructions() | ||||||||||
int |
allinsize()
Get the total number of input edges to this block.
| ||||||||||
int | alloutsize() | ||||||||||
boolean | canThrow() | ||||||||||
int | compareTo(BasicBlock<InsnType> o) | ||||||||||
InsnType |
get(int index)
Get the instruction at the specified index.
| ||||||||||
AddressableInstruction<InsnType> |
get2(int index)
Get the instruction at the specified index, in an addressable form.
| ||||||||||
long | getAddressOfInstruction(int index) | ||||||||||
long[] |
getAddresses()
Get a list of the addresses of each instruction in the block.
| ||||||||||
List<BasicBlock<InsnType>> | getAllInputBlocks() | ||||||||||
Iterable<BasicBlock<InsnType>> |
getAllInputs()
Retrieve a read-only iterable of regular and irregular input blocks.
| ||||||||||
List<BasicBlock<InsnType>> |
getAllOutputBlocks()
Get regular and irregular output blocks.
| ||||||||||
Iterable<BasicBlock<InsnType>> |
getAllOutputs()
Retrieve a read-only iterable of regular and irregular output blocks.
| ||||||||||
long |
getBase()
Address of first instruction in the block.
| ||||||||||
AddressableInstruction<InsnType> |
getBranchingInstruction2(boolean includeBreaking, boolean includeCalling)
Retrieve the branching instruction, if any.
| ||||||||||
AddressableInstruction<InsnType> |
getBranchingInstruction2()
Same as
getBranchingInstruction2(true,
true) . | ||||||||||
Object |
getData(String name)
May return null if the custom object does not exist.
| ||||||||||
long |
getEndAddress()
Address following the last instruction of the block (ie, last exclusive address).
| ||||||||||
long |
getFirstAddress()
Address of first instruction in the block.
| ||||||||||
int |
getIndexOfInstruction(InsnType insn)
Locate an instruction in the block.
| ||||||||||
int | getIndexOfInstruction(long address) | ||||||||||
BasicBlock<InsnType> |
getInputBlock(int index)
Get a regular input block.
| ||||||||||
List<BasicBlock<InsnType>> |
getInputBlocks()
Get the regular input blocks.
| ||||||||||
List<Long> | getInputOffsets() | ||||||||||
List<BasicBlock<InsnType>> |
getInputs()
Retrieve a read-only list of input blocks (regular).
| ||||||||||
InsnType |
getInstruction(long address)
Get the instruction located at the exact address.
| ||||||||||
List<InsnType> |
getInstructions()
Get a copy of the list of instructions that make up this basic block.
| ||||||||||
BasicBlock<InsnType> |
getIrregularInputBlock(int index)
Get an irregular input block.
| ||||||||||
List<BasicBlock<InsnType>> | getIrregularInputBlocks() | ||||||||||
List<Long> | getIrregularInputOffsets() | ||||||||||
List<BasicBlock<InsnType>> |
getIrregularInputs()
Retrieve a read-only list of irregular input blocks.
| ||||||||||
BasicBlock<InsnType> |
getIrregularOutputBlock(int index)
Get an irregular output block.
| ||||||||||
List<BasicBlock<InsnType>> |
getIrregularOutputBlocks()
Get irregular output blocks.
| ||||||||||
List<Long> | getIrregularOutputOffsets() | ||||||||||
List<BasicBlock<InsnType>> |
getIrregularOutputs()
Retrieve a read-only list of irregular output blocks.
| ||||||||||
InsnType |
getLast()
Get the last instruction of the block.
| ||||||||||
AddressableInstruction<InsnType> |
getLast2()
Get the last instruction of the block, in an addressable form.
| ||||||||||
long |
getLastAddress()
Address of last instruction in the block.
| ||||||||||
BasicBlock<InsnType> |
getOutputBlock(int index)
Get a regular output block.
| ||||||||||
List<BasicBlock<InsnType>> |
getOutputBlocks()
Get the regular output blocks.
| ||||||||||
List<Long> | getOutputOffsets() | ||||||||||
List<BasicBlock<InsnType>> |
getOutputs()
Retrieve a read-only list of output blocks (regular).
| ||||||||||
int | getSizeOfInstructions() | ||||||||||
boolean | hasUnknownDst() | ||||||||||
int |
insize()
Get the number of regular input edges to this block.
| ||||||||||
int |
irrinsize()
Get the number of irregular input edges to this block.
| ||||||||||
int | irroutsize() | ||||||||||
boolean |
isEmpty()
Determine if the block has 0 instruction.
| ||||||||||
boolean |
isInfiniteLoop()
Check if the block has a single regular out-edge which points to itself.
| ||||||||||
boolean |
isSelfReferencing()
Check if the block has at least one regular out-edge pointing to itself.
| ||||||||||
Iterator<InsnType> | iterator() | ||||||||||
int | outsize() | ||||||||||
boolean |
remove(int index)
Remove an instruction from the block as well as associated chains.
| ||||||||||
boolean | removeData(String name) | ||||||||||
InsnType |
set(int index, InsnType insn)
DANGEROUS METHOD.
| ||||||||||
void |
setData(String name, Object object)
Custom data is reset when a DFA is invalidated.
| ||||||||||
InsnType | setLast(InsnType insn) | ||||||||||
void | setUnknownDst(boolean unknownDst) | ||||||||||
BasicBlock<InsnType> |
shallowCopy(boolean copyBlockReferences)
Shallow duplication of a basic block.
| ||||||||||
int |
size()
Get the number of instructions in the block.
| ||||||||||
String | toString() |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
com.pnfsoftware.jeb.core.units.code.IBasicBlock
| |||||||||||
From interface
java.lang.Comparable
| |||||||||||
From interface
java.lang.Iterable
|
Create a new empty basic block.
Create a new basic block.
DANGEROUS METHOD. Add an instruction into the block.
DANGEROUS METHOD. Append an instruction to the block.
The instruction is appended to the block. The edges are not updated.
The caller is responsible for verifying the instruction (no null, no dup., etc.).
The caller is responsible for maintaining the consistency of the block and of the CFG.
insn | the instruction to be appended |
---|
DANGEROUS METHOD. Append instructions to the block.
The instructions are appended to the block. The edges are not updated.
The caller is responsible for verifying the instructions (no null, no dup., etc.).
The caller is responsible for maintaining the consistency of the block and of the CFG.
DANGEROUS METHOD. Add instructions into the block.
Get the total number of input edges to this block.
Get the instruction at the specified index.
Get the instruction at the specified index, in an addressable form.
Get a list of the addresses of each instruction in the block.
Retrieve a read-only iterable of regular and irregular input blocks.
NOTE: This method is faster than getAllInputBlocks()
since it does not provide
a copy of the list.
Get regular and irregular output blocks.
Retrieve a read-only iterable of regular and irregular output blocks.
NOTE: This method is faster than getAllOutputBlocks()
since it does not
provide a copy of the list.
Address of first instruction in the block.
Retrieve the branching instruction, if any. In the general case, it should not be assumed that the branching instruction must be the last instruction of a block. Example: on delay-slot architectures, a number of instructions may follow the branching instructions. They are included in the block. That means that the branching instruction, when there is one, may be the one/two/Nth-before-last.
Same as getBranchingInstruction2(true,
true)
.
May return null if the custom object does not exist.
Address following the last instruction of the block (ie, last exclusive address).
Address of first instruction in the block.
Locate an instruction in the block. Comparison is done by identity.
Get a regular input block.
index | block index |
---|
Get the regular input blocks.
Retrieve a read-only list of input blocks (regular).
NOTE: This method is faster than getInputBlocks()
since it does not provide a copy
of the list.
Get the instruction located at the exact address.
Get a copy of the list of instructions that make up this basic block.
Get an irregular input block.
index | block index |
---|
Retrieve a read-only list of irregular input blocks.
NOTE: This method is faster than getIrregularInputBlocks()
since it does not provide
a copy of the list.
Get irregular output blocks.
Retrieve a read-only list of irregular output blocks.
NOTE: This method is faster than getIrregularOutputBlocks()
since it does not
provide a copy of the list.
Get the last instruction of the block.
Keep in mind that a branching instruction may NOT be the last instruction of a basic block if it supports delay-slots.
Get the last instruction of the block, in an addressable form.
Keep in mind that a branching instruction may NOT be the last instruction of a basic block if it supports delay-slots.
Address of last instruction in the block.
Get the regular output blocks.
Retrieve a read-only list of output blocks (regular).
NOTE: This method is faster than getOutputBlocks()
since it does not provide a copy
of the list.
Get the number of regular input edges to this block.
Get the number of irregular input edges to this block.
Determine if the block has 0 instruction.
Check if the block has a single regular out-edge which points to itself.
Check if the block has at least one regular out-edge pointing to itself.
Remove an instruction from the block as well as associated chains. Usage is not recommended for public clients.
This method may have the nasty side-effect of making the block empty. In that case, it returns true, and it is the caller's responsibility to refresh the CFG at their earliest convenience.
Another issue the client needs to take care of is the removal of the last instruction, which should only happen on very specific conditions, since the trailing instruction typically conditions the out-edges of the block.
DANGEROUS METHOD. Replace an instruction. Sizes must match.
Edges are not updated.
The caller is responsible for maintaining the consistency of the block and of the CFG.
insn | the instruction |
---|
Custom data is reset when a DFA is invalidated.
Shallow duplication of a basic block. USE THE RESULTING BLOCK WITH CAUTION. - Instructions
references are copied
- Block references (edges) are optionally copied (the blocks are not)
- DFA data is not copied
Get the number of instructions in the block.