angr.annocfg

class angr.annocfg.AnnotatedCFG

Bases: object

AnnotatedCFG is a control flow graph with statement whitelists and exit whitelists to describe a slice of the program.

__init__(project, cfg=None, detect_loops=False)

Constructor.

Parameters:
  • project – The angr Project instance

  • cfg – Control flow graph.

  • detect_loops

from_digraph(digraph)

Initialize this AnnotatedCFG object with a networkx.DiGraph consisting of the following form of nodes:

Tuples like (block address, statement ID)

Those nodes are connected by edges indicating the execution flow.

Parameters:

digraph (networkx.DiGraph) – A networkx.DiGraph object

get_addr(run)
add_block_to_whitelist(block)
add_statements_to_whitelist(block, stmt_ids)
add_exit_to_whitelist(run_from, run_to)
set_last_statement(block_addr, stmt_id)
add_loop(loop_tuple)

A loop tuple contains a series of IRSB addresses that form a loop. Ideally it always starts with the first IRSB that we meet during the execution.

should_take_exit(addr_from, addr_to)
should_execute_statement(addr, stmt_id)
get_run(addr)
get_whitelisted_statements(addr)
Return type:

list[int] | None

Returns:

True if all statements are whitelisted

get_last_statement_index(addr)

Get the statement index of the last statement to execute in the basic block specified by addr.

Parameters:

addr (int) – Address of the basic block.

Returns:

The statement index of the last statement to be executed in the block. Usually if the default exit is taken, it will be the last statement to execute. If the block is not in the slice or we should never take any exit going to this block, None is returned.

Return type:

int or None

get_loops()
get_targets(source_addr)
dbg_repr()
dbg_print_irsb(irsb_addr, project=None)

Pretty-print an IRSB with whitelist information

keep_path(path)

Given a path, returns True if the path should be kept, False if it should be cut.

merge_points(path)
successor_func(path)

Callback routine that takes in a path, and returns all feasible successors to path group. This callback routine should be passed to the keyword argument “successor_func” of PathGroup.step().

Parameters:

path – A Path instance.

Returns:

A list of all feasible Path successors.