angr.analyses.decompiler.known_patterns.templates¶
KnownPatternTemplate: a single, context-parameterized definition of an
idiom that instantiates itself into a concrete KnownPattern for a
target’s PatternContext.
One template replaces the per-architecture / per-runtime copies of a pattern:
its build(ctx) computes the concrete field offsets, load sizes, and return
types from the context, so the same definition covers 32- and 64-bit,
libstdc++ and MSVC, and so on.
- class angr.analyses.decompiler.known_patterns.templates.KnownPatternTemplate¶
Bases:
objectA context-aware pattern definition.
- Variables:
call_name (
str) – The synthesized call name (unique across templates).build (
Callable[[PatternContext],KnownPattern|None]) –build(ctx) -> KnownPattern | None; emits the concrete pattern forctx(None if it cannot).arches (
frozenset[str] |None) – AllowedArch.namevalues; None = any.languages (
frozenset[str] |None) – Allowed languages ({“c”,”cpp”}); None = any.runtimes (
frozenset[str] |None) – Allowed C++ runtimes ({“libstdcxx”,”msvc”}); None = any.platforms (
frozenset[str] |None) – Allowed platforms ({“linux”,”windows”}); None = any.default_enabled (
bool) – Whether the template is used when the caller does not explicitly select patterns.gate – Optional
PatternGatethat turns an opt-in template on for targets (or functions) where the evidence says the idiom is real; seegating. A gate can only open a template, never close a default-on one.
- call_name: str
- build: Callable[[PatternContext], KnownPattern | None]
- gate: PatternGate | None = None¶
- enabled_for(gate_ctx)¶
- Return type:
- Parameters:
gate_ctx (GateContext)
- applicable(ctx)¶
- Return type:
- Parameters:
ctx (PatternContext)
- instantiate(ctx)¶
The concrete pattern for
ctx, or None if this template does not apply there. Memoized: a KnownPattern is a frozen tree that depends on nothing but the context, and callers treat it read-only.- Return type:
- Parameters:
ctx (PatternContext)
- __init__(call_name, build, arches=None, languages=None, runtimes=None, platforms=None, default_enabled=False, name='', gate=None, _cache=<factory>)¶
- Parameters:
- Return type:
None
- angr.analyses.decompiler.known_patterns.templates.make_template(call_name, build, *, arches=None, languages=None, runtimes=None, platforms=None, default_enabled=False, name='', gate=None)¶
- Return type:
- Parameters:
call_name (str)
build (Callable[[PatternContext], KnownPattern | None])
default_enabled (bool)
name (str)
gate (PatternGate | None)