angr.analyses.decompiler.decompiler¶
- class angr.analyses.decompiler.decompiler.ConstantCollector¶
Bases:
SequenceWalkerCollect the values of all integer constants in a structured sequence, including the constants inside expressions and statements that structuring lifts out of blocks and onto the nodes themselves.
- __init__()¶
- class angr.analyses.decompiler.decompiler.Decompiler¶
Bases:
AnalysisThe decompiler analysis.
Run this on a Function object for which a normalized CFG has been constructed. The fully processed output can be found in result.codegen.text
AIL graphs exposed on the result (both on a fresh run and on a cache hit, including caches reloaded from angrdb or the runtime-db spill):
ail_graph(=clinic.cc_graph): the simplified graph before region identification.clinic.graph: the final graph after region identification and region simplification.unoptimized_ail_graph(=clinic.unoptimized_graph): a snapshot before the first structure-altering optimization pass; use it for an exact instruction-to-AIL mapping. Only built whensave_unoptimized_graph=Trueis passed; otherwise this attribute is None on both fresh runs and cache hits.
Complexity guard: pathologically large functions (e.g. packer filler that linear disassembly turns into thousands of blocks) can keep the pipeline busy indefinitely, so two size limits are checked before the expensive work starts.
max_function_blocks(default 50000,DEFAULT_MAX_FUNCTION_BLOCKS) bounds the number of CFG basic blocks and is checked before any AIL is built;max_ail_statements(default 1000000,DEFAULT_MAX_AIL_STATEMENTS) bounds the number of AIL statements and is checked right after the AIL graph is built. Both are ~10x the largest function in angr’s test binary corpus. Either limit can be changed through the decompilation option of the same name, and setting one to 0 disables it. When a limit is exceeded, decompilation stops with anAngrDecompilationComplexityErrornaming the limit and the actual size: withfail_fast=Trueit is raised, otherwise it is recorded inself.errors(and inkb.decompilations[...].errors) and exposed ascomplexity_error, andcodegenstays None.The optimization passes come from
preset(a name or a DecompilationPreset), or from an explicitoptimization_passeslist when no preset is given.disable_optsdrops individual passes from the preset’s list, which is how a caller asks for “this preset, minus that one pass” without restating it.- __init__(func, cfg=None, options=None, preset=None, optimization_passes=None, disable_opts=None, sp_tracker_track_memory=True, peephole_optimizations=None, vars_must_struct=None, flavor=Flavors.DEFAULT_FLAVOR, expr_comments=None, stmt_comments=None, ite_exprs=None, binop_operators=None, decompile=True, regen_clinic=False, inline_functions=None, desired_variables=None, update_memory_data=True, want_full_graph=False, generate_code=True, use_cache=True, update_cache=True, expr_collapse_depth=16, clinic_graph=None, clinic_arg_vvars=None, clinic_start_stage=None, clinic_end_stage=None, clinic_skip_stages=(), static_vvars=None, static_buffers=None, codegen_cls=<class 'angr.analyses.decompiler.structured_codegen.c.CStructuredCodeGenerator'>, save_unoptimized_graph=False, go_sigs_rerun=True)¶
- Parameters:
preset (str | DecompilationPreset | None)
peephole_optimizations (_PEEPHOLE_OPTIMIZATIONS_TYPE)
flavor (str)
update_memory_data (bool)
want_full_graph (bool)
generate_code (bool)
use_cache (bool)
update_cache (bool)
expr_collapse_depth (int)
static_vvars (dict | None)
static_buffers (dict | None)
save_unoptimized_graph (bool)
go_sigs_rerun (bool)
- property complexity_error: AngrDecompilationComplexityError | None¶
The complexity-limit violation that aborted this decompilation, or None if no limit was exceeded. Inspect
limit_name,limit, andactualon it to decide whether to raise the limit or skip the function.
- reflow_variable_types(cache)¶
Re-run type inference on an existing variable recovery result, then rerun codegen to generate new results.
- Returns:
- Parameters:
cache (DecompilationCache)
- find_data_references_and_update_memory_data(seq_node)¶
- Parameters:
seq_node (SequenceNode)
- transform_graph_from_ssa(ail_graph)¶
Translate an SSA AIL graph out of SSA form. This is useful for producing a non-SSA AIL graph for displaying in angr management.
- Parameters:
ail_graph (
DiGraph) – The AIL graph to transform out of SSA form.- Return type:
DiGraph- Returns:
The translated AIL graph.
- transform_seqnode_from_ssa(seq_node)¶
- Return type:
- Parameters:
seq_node (SequenceNode)
- llm_refine()¶
Use the configured LLM to suggest improved variable names, function names, and variable types. Returns True if any changes were made.
- Return type:
- llm_suggest_variable_names(llm_client=None, code_text=None, raise_exc=False)¶
Ask the LLM to suggest better variable names for the decompiled code. Returns True if any variables were renamed.
- llm_suggest_function_name(llm_client=None, code_text=None, raise_exc=False)¶
Ask the LLM to suggest a better function name. Only suggests rename for auto-generated names (starting with
sub_orfcn.). Returns True if the function was renamed.
- llm_suggest_variable_types(llm_client=None, code_text=None, raise_exc=False)¶
Ask the LLM to suggest better C types for variables. Returns True if any variable types were changed.
- llm_summarize_function(llm_client=None, code_text=None, raise_exc=False)¶
Ask the LLM to produce a natural-language summary of what the decompiled function does. The summary is stored in the DecompilationCache and returned.
Returns the summary string, or None if summarization failed.