angr.analyses.forward_analysis.visitors.graph

class angr.analyses.forward_analysis.visitors.graph.GraphVisitor

Bases: Generic

A graph visitor takes a node in the graph and returns its successors. Typically, it visits a control flow graph, and returns successors of a CFGNode each time. This is the base class of all graph visitors.

__init__()
successors(node)

Get successors of a node. The node should be in the graph.

Parameters:

node (TypeVar(NodeType)) – The node to work with.

Returns:

A list of successors.

Return type:

list[TypeVar(NodeType)]

predecessors(node)

Get predecessors of a node. The node should be in the graph.

Parameters:

node (TypeVar(NodeType)) – The node to work with.

Return type:

list[TypeVar(NodeType)]

Returns:

A list of predecessors.

sort_nodes(nodes=None)

Get a list of all nodes sorted in an optimal traversal order.

Parameters:

nodes (Collection[TypeVar(NodeType)] | None) – A collection of nodes to sort. If none, all nodes in the graph will be used to sort.

Return type:

list[TypeVar(NodeType)]

Returns:

A list of sorted nodes.

back_edges()

Get a list of back edges. This function is optional. If not overridden, the traverser cannot achieve an optimal graph traversal order.

Return type:

list[tuple[TypeVar(NodeType), TypeVar(NodeType)]]

Returns:

A list of back edges (source -> destination).

nodes()

Return an iterator of nodes following an optimal traversal order.

Return type:

Iterator[TypeVar(NodeType)]

Returns:

reset()

Reset the internal node traversal state. Must be called prior to visiting future nodes.

Returns:

None

next_node()

Get the next node to visit.

Return type:

Optional[TypeVar(NodeType)]

Returns:

A node in the graph.

all_successors(node, skip_reached_fixedpoint=False)

Returns all successors to the specific node.

Parameters:

node (TypeVar(NodeType)) – A node in the graph.

Returns:

A set of nodes that are all successors to the given node.

Return type:

set[TypeVar(NodeType)]

revisit_successors(node, include_self=True)

Revisit a node in the future. As a result, the successors to this node will be revisited as well.

Parameters:

node (TypeVar(NodeType)) – The node to revisit in the future.

Return type:

None

Returns:

None

revisit_node(node)

Revisit a node in the future. Do not include its successors immediately.

Parameters:

node (TypeVar(NodeType)) – The node to revisit in the future.

Return type:

None

Returns:

None

reached_fixedpoint(node)

Mark a node as reached fixed-point. This node as well as all its successors will not be visited in the future.

Parameters:

node (TypeVar(NodeType)) – The node to mark as reached fixed-point.

Return type:

None

Returns:

None