angr.analyses.decompiler.optimization_passes.optimization_pass

class angr.analyses.decompiler.optimization_passes.optimization_pass.BlockCache

Bases: tuple

BlockCache(rd, prop)

static __new__(_cls, rd, prop)

Create new instance of BlockCache(rd, prop)

prop

Alias for field number 1

rd

Alias for field number 0

exception angr.analyses.decompiler.optimization_passes.optimization_pass.MultipleBlocksException

Bases: Exception

An exception that is raised in _get_block() where multiple blocks satisfy the criteria but only one block was requested.

class angr.analyses.decompiler.optimization_passes.optimization_pass.OptimizationPassStage

Bases: Enum

Enums about optimization pass stages.

Note that the region identification pass (RegionIdentifier) may modify existing AIL blocks without updating the topology of the original AIL graph. For example, loop successor refinement may modify create a new AIL block with an artificial address, and alter existing jump targets of jump statements and conditional jump statements to point to this new block. However, loop successor refinement does not update the topology of the original AIL graph, which means this new AIL block does not exist in the original AIL graph. As a result, until this behavior of RegionIdentifier changes in the future, DURING_REGION_IDENTIFICATION optimization passes should not modify existing jump targets.

AFTER_AIL_GRAPH_CREATION = 0
BEFORE_SSA_LEVEL0_TRANSFORMATION = 1
AFTER_SINGLE_BLOCK_SIMPLIFICATION = 2
BEFORE_SSA_LEVEL1_TRANSFORMATION = 3
AFTER_SSA_LEVEL1_TRANSFORMATION = 4
AFTER_MAKING_CALLSITES = 5
AFTER_GLOBAL_SIMPLIFICATION = 6
BEFORE_VARIABLE_RECOVERY = 7
AFTER_VARIABLE_RECOVERY = 8
BEFORE_REGION_IDENTIFICATION = 9
DURING_REGION_IDENTIFICATION = 10
AFTER_STRUCTURING = 11
class angr.analyses.decompiler.optimization_passes.optimization_pass.BaseOptimizationPass

Bases: object

The base class for any optimization pass.

ARCHES = []
PLATFORMS = []
STAGE: OptimizationPassStage
STRUCTURING: list[str] | None = None
NAME = 'N/A'
DESCRIPTION = 'N/A'
__init__(func, manager)
Parameters:

manager (Manager)

property project: Project
property kb
analyze()
class angr.analyses.decompiler.optimization_passes.optimization_pass.OptimizationPass

Bases: BaseOptimizationPass

The base class for any function-level graph optimization pass.

__init__(func, manager, *, graph, blocks_by_addr=None, blocks_by_addr_and_idx=None, variable_kb=None, region_identifier=None, reaching_definitions=None, vvar_id_start=0, entry_node_addr=None, scratch=None, force_loop_single_exit=True, refine_loops_with_single_successor=False, complete_successors=False, fold_expressions=True, avoid_vvar_ids=None, arg_vvars=None, peephole_optimizations=None, stack_pointer_tracker=None, notes=None, **kwargs)
Parameters:
entry_node_addr: tuple[int, int | None]
out_graph: DiGraph | None
stack_items: dict[int, StackItem]
property blocks_by_addr: dict[int, set[Block]]
property blocks_by_addr_and_idx: dict[tuple[int, int | None], Block]
bfs_nodes(depth=None, start_node=None)
Return type:

Generator[Block]

Parameters:
  • depth (int | None)

  • start_node (Block | None)

new_block_addr()

Return a block address that does not conflict with any existing blocks.

Return type:

int

Returns:

The block address.

class angr.analyses.decompiler.optimization_passes.optimization_pass.SequenceOptimizationPass

Bases: BaseOptimizationPass

The base class for any sequence node optimization pass.

__init__(func, manager, seq=None, **kwargs)
class angr.analyses.decompiler.optimization_passes.optimization_pass.StructuringOptimizationPass

Bases: OptimizationPass

The base class for any optimization pass that requires structuring. Optimization passes that inherit from this class should directly depend on structuring artifacts, such as regions and gotos. Otherwise, they should use OptimizationPass. This is the heaviest (computation time) optimization pass class.

By default this type of optimization should work: - on any architecture - on any platform - during region identification (to have iterative structuring) - only with the SAILR structuring algorithm

ARCHES = None
PLATFORMS = None
STRUCTURING: list[str] | None = ['sailr']
STAGE: OptimizationPassStage = 10
__init__(func, manager, require_structurable_graph=True, prevent_new_gotos=True, strictly_less_gotos=False, recover_structure_fails=True, must_improve_rel_quality=True, max_opt_iters=1, simplify_ail=True, require_gotos=True, readd_labels=False, edges_to_remove=None, **kwargs)
Parameters:
analyze()

Wrapper for _analyze() that verifies the graph is structurable before and after the optimization.