Interface IControlFlowGraph<InsnType extends IInstruction,Block extends IBasicBlock<InsnType>>
- Type Parameters:
InsnType- instruction typeBlock- basic block type
- All Superinterfaces:
Iterable<Block>
public interface IControlFlowGraph<InsnType extends IInstruction,Block extends IBasicBlock<InsnType>>
extends Iterable<Block>
Generic interface for control flow graph (CFG) objects.
-
Method Summary
Modifier and TypeMethodDescriptionGet an instruction-with-address iterator.get(int index) Retrieve a basic block.getBlock(int index) Get a basic block.getBlockAt(long address) Get the basic block that starts at the provided address or offset.getBlockByLastAddress(long address) Get the basic block whose last address is the provided address.getBlockContaining(long address) Get the basic block that contains the provided address.getBlockEndingAt(long address) Get the basic block that ends on the provided address.Get a copy of the block list of the CFG.Get a read-only view of the list of blocks for this CFG.intCalculate the 'effective' size of this CFG, that is, the sum of the size of each basic block.longRoutine highest address (exclusive).longRoutine entry-point address.Get the entry block.Get the ordered list of exit blocks.longRoutine lowest address (inclusive).voidgetGraphRepresentation(List<int[]> edges, List<int[]> irregularEdges) Get the a graph representation of the CFG.getInstruction(long address) Get the instruction located at the exact address.intGet the total number of instructions in the CFG.getInstructionLocation(long address) Locate an instruction.Get the instruction list of this CFG by aggregating each instruction of every block.getLast()Get the last block.longRoutine highest address (inclusive).intGet the index of a basic block.Get an instruction iterator.intsize()Get the number of blocks.Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Method Details
-
size
int size()Get the number of blocks.- Returns:
- block count
-
get
Retrieve a basic block.- Parameters:
index- block index- Returns:
- basic block
-
indexOf
Get the index of a basic block.- Parameters:
b- basic block- Returns:
- block index, or -1
-
getLast
Block getLast()Get the last block.- Returns:
- last block
-
getEntryAddress
long getEntryAddress()Routine entry-point address. Note that this address may not be the lowest one in the CFG.- Returns:
- the address of the entry block
-
getFirstAddress
long getFirstAddress()Routine lowest address (inclusive). Note that this address may not be the entry-point address for this routine.- Returns:
- first address
-
getLastAddress
long getLastAddress()Routine highest address (inclusive).- Returns:
- last address
-
getEndAddress
long getEndAddress()Routine highest address (exclusive).- Returns:
- end address
-
getEffectiveSize
int getEffectiveSize()Calculate the 'effective' size of this CFG, that is, the sum of the size of each basic block.- Returns:
- the CFG size
-
getBlock
Get a basic block.- Parameters:
index- block index- Returns:
- basic block
-
getBlocks
Get a copy of the block list of the CFG. The list is ordered by ascending block address. Modifying the list does not impact the CFG.- Returns:
- a copy of the list of blocks
-
getBlocksView
Get a read-only view of the list of blocks for this CFG. The list is ordered by ascending block address.- Returns:
- the list of blocks
-
getBlockAt
Get the basic block that starts at the provided address or offset.- Parameters:
address- the block address/offset- Returns:
- basic block, or null if none starts at that address
-
getBlockEndingAt
Get the basic block that ends on the provided address.- Parameters:
address- wanted block end address (exclusive)- Returns:
- basic block, or null if none ends at that address
-
getBlockContaining
Get the basic block that contains the provided address.Note that the address just needs to be in the block address range; it does not need to point to the beginning of an instruction within the block
- Parameters:
address- an address within the block- Returns:
- containing block, or null
-
getBlockByLastAddress
Get the basic block whose last address is the provided address.- Parameters:
address- last instruction address- Returns:
- basic block, or null
-
getEntryBlock
Block getEntryBlock()Get the entry block. The entry block is unique.- Returns:
- never null; the method throws on error
-
getExitBlocks
Get the ordered list of exit blocks. A CFG may have zero or more exit blocks; CFG representing standard routines will have at least one (generally one) exit block.- Returns:
- a collection of blocks, possibly empty
-
getInstructionCount
int getInstructionCount()Get the total number of instructions in the CFG. This method sums the number of instructions of each block of the CFG.- Returns:
- instruction count
-
instructions
Get an instruction iterator. Also seeaddressableInstructions().- Returns:
- an iterator (not supporting
remove)
-
addressableInstructions
Iterable<AddressableInstruction<InsnType>> addressableInstructions()Get an instruction-with-address iterator. Also seeinstructions().- Returns:
- an iterator (not supporting
remove)
-
getInstructions
Get the instruction list of this CFG by aggregating each instruction of every block. The list is ordered by ascending address/offset.- Returns:
- instruction list
-
getInstruction
Get the instruction located at the exact address.- Parameters:
address- instruction address- Returns:
- an instruction, null if none
-
getInstructionLocation
Locate an instruction.- Parameters:
address- instruction address- Returns:
- a couple (basic block, instruction index within that block); null on error
-
getGraphRepresentation
Get the a graph representation of the CFG. The list of edges use a 1-based node numbering scheme.- Parameters:
edges- (output) array of regular edges, eg: {{1,2},{1,3},{2,3}}irregularEdges- (output) array of irregular edges
-