angr.analyses.decompiler.structured_codegen

class angr.analyses.decompiler.structured_codegen.BaseStructuredCodeGenerator

Bases: object

__init__(flavor=None, notes=None, expr_comments=None, stmt_comments=None, const_formats=None)
static adjust_mapping_positions(offset, pos_to_node, pos_to_addr, addr_to_pos)

Adjust positions in the mappings to account for the notes that are prepended to the text.

Parameters:
  • offset (int) – The length of the notes to prepend.

  • pos_to_node (PositionMapping) – The position to node mapping.

  • pos_to_addr (PositionMapping) – The position to address mapping.

  • addr_to_pos (InstructionMapping) – The address to position mapping.

Return type:

tuple[PositionMapping, PositionMapping, InstructionMapping]

Returns:

Adjusted mappings.

reapply_options(options)
regenerate_text()
Return type:

None

reload_variable_types()
Return type:

None

next_idx(key)
Return type:

str

Parameters:

key (str)

reset_idx_counters()
Return type:

None

class angr.analyses.decompiler.structured_codegen.CStructuredCodeGenerator

Bases: BaseStructuredCodeGenerator, Analysis

__init__(func, sequence, indent=0, cfg=None, variable_kb=None, func_args=None, binop_depth_cutoff=16, show_casts=True, braces_on_own_lines=True, use_compound_assignments=True, show_local_types=True, comment_gotos=False, cstyle_null_cmp=True, flavor=None, stmt_comments=None, expr_comments=None, show_externs=True, externs=None, const_formats=None, show_demangled_name=True, show_disambiguated_name=True, ail_graph=None, simplify_else_scope=True, cstyle_ifs=True, omit_func_header=False, display_block_addrs=False, display_vvar_ids=False, min_data_addr=4194304, notes=None, display_notes=True, max_str_len=None, prettify_thiscall=False, cstyle_void_param=True)
Parameters:
reapply_options(options)
cleanup()

Remove existing rendering results.

regenerate_text()

Re-render text and re-generate all sorts of mapping information.

Return type:

None

render_text(cfunc)
Return type:

tuple[str, PositionMapping, PositionMapping, InstructionMapping, dict[Any, set[Any]]]

Parameters:

cfunc (CFunction)

render_notes()

Render decompilation notes.

Return type:

str

Returns:

A string containing all notes.

reload_variable_types()
Return type:

None

default_simtype_from_bits(n, signed=True)
Return type:

SimType

Parameters:
variables_unify(v1, v2)
Return type:

bool

Parameters:
class angr.analyses.decompiler.structured_codegen.CStructuredCodeWalker

Bases: object

handle(obj)
handle_default(obj)
handle_CFunction(obj)
handle_CStatements(obj)
handle_CWhileLoop(obj)
handle_CDoWhileLoop(obj)
handle_CForLoop(obj)
handle_CIfElse(obj)
handle_CIfBreak(obj)
handle_CSwitchCase(obj)
handle_CAssignment(obj)
handle_CExpressionStatement(obj)
handle_CFunctionCall(obj)
handle_CReturn(obj)
handle_CGoto(obj)
handle_CIndexedVariable(obj)
handle_CVariableField(obj)
handle_CUnaryOp(obj)
handle_CBinaryOp(obj)
handle_CTypeCast(obj)
handle_CITE(obj)
class angr.analyses.decompiler.structured_codegen.DummyStructuredCodeGenerator

Bases: BaseStructuredCodeGenerator

A dummy structured code generator that only stores user-specified information.

__init__(flavor, expr_comments=None, stmt_comments=None, configuration=None, const_formats=None)
Parameters:

flavor (str)

class angr.analyses.decompiler.structured_codegen.ImportSourceCode

Bases: BaseStructuredCodeGenerator, Analysis

__init__(function, flavor='source', source_root=None, encoding='utf-8')
regenerate_text()
class angr.analyses.decompiler.structured_codegen.InstructionMapping

Bases: object

__init__()
items()
add_mapping(ins_addr, posmap_pos)
get_nearest_pos(ins_addr)
Return type:

int | None

Parameters:

ins_addr (int)

class angr.analyses.decompiler.structured_codegen.InstructionMappingElement

Bases: object

__init__(ins_addr, posmap_pos)
ins_addr: int
posmap_pos: int
class angr.analyses.decompiler.structured_codegen.PositionMapping

Bases: object

DUPLICATION_CHECK = True
__init__()
items()
add_mapping(start_pos, length, obj)
get_node(pos)
Parameters:

pos (int)

get_element(pos)
Return type:

PositionMappingElement | None

Parameters:

pos (int)

class angr.analyses.decompiler.structured_codegen.PositionMappingElement

Bases: object

__init__(start, length, obj)
start: int
length: int
obj
class angr.analyses.decompiler.structured_codegen.RustStructuredCodeGenerator

Bases: BaseStructuredCodeGenerator, Analysis

__init__(func, sequence, indent=0, cfg=None, variable_kb=None, func_args=None, binop_depth_cutoff=16, show_casts=True, braces_on_own_lines=False, use_compound_assignments=True, show_local_types=False, comment_gotos=False, cstyle_null_cmp=True, flavor=None, stmt_comments=None, expr_comments=None, show_externs=False, externs=None, const_formats=None, show_demangled_name=True, show_disambiguated_name=True, ail_graph=None, simplify_else_scope=True, cstyle_ifs=True, omit_func_header=False, display_block_addrs=False, display_vvar_ids=False, min_data_addr=4194304, notes=None, display_notes=True)
Parameters:
reapply_options(options)
cleanup()

Remove existing rendering results.

regenerate_text()

Re-render text and re-generate all sorts of mapping information.

Return type:

None

RENDER_TYPE

alias of tuple[str, PositionMapping, PositionMapping, InstructionMapping, dict[Any, set[Any]]]

render_text(rust_func)
Return type:

RENDER_TYPE

Parameters:

rust_func (RustFunction)

render_notes()

Render decompilation notes.

Return type:

str

Returns:

A string containing all notes.

reload_variable_types()
Return type:

None

default_simtype_from_size(n, signed=True)
Return type:

RustSimTypeInt

Parameters:

Submodules