angr.analyses.decompiler.edits.ops¶
The mutating operations of the edit layer.
Every operation re-fetches the decompilation cache by key at the point of mutation rather than
holding a reference: see the note in cache.
- angr.analyses.decompiler.edits.ops.rename_function(project, func, new_name, *, kb=None, hooks=None, flavor='pseudocode', allow_overwrite=True, strict_names=True, rerender=True)¶
Rename a function.
Nothing is invalidated: other functions’ cached ASTs reference the same Function object, so only their rendered text goes stale. That is reported through
Refresh.text_stale_allfor the caller to act on lazily.- Return type:
- Parameters:
- angr.analyses.decompiler.edits.ops.rename_variable(project, func, variable_name, new_name, *, kb=None, hooks=None, flavor='pseudocode', allow_overwrite=True, strict_names=True, rerender=True, codegen=None)¶
Rename a local, an argument, or a global as it appears in a function’s decompilation.
Sets
renamedon the variable, without which a later re-decompilation overwrites the name.
- angr.analyses.decompiler.edits.ops.reflow_types(project, func, *, kb=None, flavor='pseudocode', rerender=True)¶
Re-run type inference over the cached constraints and refresh the rendered code.
Separate from
set_variable_type()so a batch can retype many variables and reflow once; per-variable reflow would re-run Typehoon N times.This is not a re-decompilation: the AST is untouched, so a retype that should change how an access renders (a struct field, an array index) needs a full re-decompilation instead.
- Parameters:
project (Project)
func (Function)
kb (KnowledgeBase | None)
flavor (str)
rerender (bool)
- angr.analyses.decompiler.edits.ops.set_variable_type(project, func, variable_name, c_type, *, kb=None, hooks=None, flavor='pseudocode', reflow=True, rerender=True, allow_prototype_change=True, codegen=None)¶
Change the type of a local, an argument, or a global.
Arguments are retyped by rewriting the function prototype, which requires a re-decompilation – the returned Refresh says so. Pass
allow_prototype_change=Falseto refuse instead.
- angr.analyses.decompiler.edits.ops.set_function_prototype(project, func, prototype, *, kb=None, hooks=None, flavor='pseudocode', invalidate_cache=True, preserve_user_edits=True, redecompile=False)¶
Set a function’s prototype.
The function name inside the signature is ignored; use
rename_function()to rename.Dropping kb.dec_variables is what makes new argument names take effect, but it also discards every rename and manual type for the function. Those are snapshotted and, when this function re-decompiles, restored. Otherwise the snapshot is returned in
detail["user_edits"]so a caller that decompiles asynchronously can restore it once its own job finishes.- Return type:
- Parameters:
project (Project)
func (Function)
prototype (str | SimTypeFunction)
kb (KnowledgeBase | None)
hooks (EditHooks | None)
flavor (str)
invalidate_cache (bool)
preserve_user_edits (bool)
redecompile (bool)
- angr.analyses.decompiler.edits.ops.set_comment(project, addr, comment, *, kind=None, kb=None, hooks=None, flavor='pseudocode', mirror_to_pseudocode=True, snap=True, rerender=True)¶
Set the comment at an address, or clear it with an empty string or None.
The comment goes into kb.comments, which the disassembly renders and which the decompiler reads for the function header. Per-statement pseudocode comments live in codegen.stmt_comments instead, so both are written – except at the function entry, where kb.comments is already what the header renders and mirroring would show the comment twice.
kindsets the comment’s display kind; None keeps whatever kind the comment already has. Clearing a comment always clears its kind.- Return type:
- Parameters:
project (Project)
addr (int)
comment (str | None)
kind (CommentKind | None)
kb (KnowledgeBase | None)
hooks (EditHooks | None)
flavor (str)
mirror_to_pseudocode (bool)
snap (bool)
rerender (bool)
- angr.analyses.decompiler.edits.ops.global_variable_at(kb, addr)¶
The global SimVariable recorded at an address, if variable recovery produced one.
- Parameters:
kb (KnowledgeBase)
addr (int)
- angr.analyses.decompiler.edits.ops.rename_global(project, addr, new_name, *, kb=None, hooks=None, allow_overwrite=True, strict_names=True)¶
Rename a global by address, without needing a function whose decompilation shows it.
- Return type:
- Parameters:
- angr.analyses.decompiler.edits.ops.set_global_type(project, addr, c_type, *, kb=None, hooks=None)¶
Set the type of a global by address.
- Return type:
- Parameters: