Basic Blocks
basic_blocks
Classes:
-
BasicBlocks
–Interface for working with basic blocks in functions.
BasicBlocks
BasicBlocks(database: Database)
Bases: DatabaseEntity
Interface for working with basic blocks in functions.
Basic blocks are sequences of instructions with a single entry point and single exit point, used for control flow analysis and optimization.
Args: database: Reference to the active IDA database.
Methods:
-
get_between
–Retrieves the basic blocks within a given address range.
-
get_from_function
–Retrieves the basic blocks within a given function.
-
get_instructions
–Retrieves the instructions within a given basic block.
Attributes:
-
database
(Database
) –Get the database reference, guaranteed to be non-None when called from
-
m_database
–
database
property
database: Database
Get the database reference, guaranteed to be non-None when called from methods decorated with @check_db_open.
Returns: The active database instance.
Note: This property should only be used in methods decorated with @check_db_open, which ensures m_database is not None.
m_database
instance-attribute
m_database = database
get_between
get_between(
start_ea: ea_t, end_ea: ea_t, flags: int = 0
) -> _FlowChart
Retrieves the basic blocks within a given address range.
Args: start_ea: The start address of the range. end_ea: The end address of the range. flags: Optional qflow_chart_t flags for flowchart generation (default: 0).
Returns: An iterable flowchart containing the basic blocks within the specified range.
Raises: InvalidEAError: If the effective address is not in the database range. InvalidParameterError: If the input range is invalid.
get_from_function
get_from_function(
func: func_t, flags: int = 0
) -> _FlowChart
Retrieves the basic blocks within a given function.
Args: func: The function to retrieve basic blocks from. flags: Optional qflow_chart_t flags for flowchart generation (default: 0).
Returns: An iterable flowchart containing the basic blocks of the function.
get_instructions
get_instructions(
block: qbasic_block_t,
) -> Optional[Iterator[insn_t]]
Retrieves the instructions within a given basic block.
Args: block: The basic block to analyze.
Returns: An instruction iterator for the block.