Skip to content

Request & Result

DecompileRequest is the input payload for one function decompilation. DecompileResult is the output, carrying decompiled C code, structured function data, warnings, and an optional error descriptor.

Request and Result

flatline.DecompileRequest dataclass

DecompileRequest(memory_image: bytes, base_address: int, function_address: int, language_id: str, compiler_spec: str | None = None, runtime_data_dir: str | None = None, function_size_hint: int | None = None, analysis_budget: AnalysisBudget | None = None, enriched: bool = False, tail_padding: bytes | None = b'\x00')

Input payload for one function decompilation.

The caller provides a flat memory image covering the relevant address space. The library does not perform binary format parsing; callers working with binary files must extract memory content first.

Attributes:

Name Type Description
memory_image bytes

Byte content of the target memory region. Must be non-empty bytes or bytearray.

base_address int

Virtual address of the start of memory_image.

function_address int

Entry point virtual address of the function to decompile, within the memory image.

language_id str

Target architecture identifier (e.g. "x86:LE:64:default"). Use list_language_compilers() to discover valid values.

compiler_spec str | None

Compiler specification (e.g. "gcc"). When None, the default compiler for the language is used.

runtime_data_dir str | None

Explicit path to the Ghidra runtime data directory. When None, auto-discovered from ghidra-sleigh.

function_size_hint int | None

Optional advisory size hint in bytes for the function body.

analysis_budget AnalysisBudget | None

Resource limits for this decompilation. Accepts an AnalysisBudget or a dict with a "max_instructions" key. Defaults to AnalysisBudget(max_instructions=100000).

enriched bool

When True, the result includes an Enriched companion payload with post-simplification pcode and varnode graph data. Defaults to False.

tail_padding bytes | None

Optional byte pattern used to satisfy decoder lookahead reads that start within memory_image but extend past its tail. Defaults to b"\x00" so exact function slices decompile without manual caller padding. Non-empty padding is repeated as needed. Set to None or b"" to preserve strict tail-boundary failures.

Raises:

Type Description
InvalidArgumentError

If memory_image is empty or not bytes, language_id is empty, or analysis_budget is invalid.

flatline.DecompileResult dataclass

DecompileResult(c_code: str | None, function_info: FunctionInfo | None, warnings: list[WarningItem], error: ErrorItem | None, metadata: dict[str, Any], enriched: Enriched | None = None)

Output payload from one function decompilation.

On success, c_code and function_info are populated. On failure, error describes the problem and the other fields may be None.

Attributes:

Name Type Description
c_code str | None

Decompiled C source code, or None on error.

function_info FunctionInfo | None

Structured function data, or None on error.

warnings list[WarningItem]

Decompiler warnings emitted during processing.

error ErrorItem | None

Structured error descriptor if decompilation failed, otherwise None.

metadata dict[str, Any]

Additional metadata with stable keys: "decompiler_version", "language_id", "compiler_spec", and "diagnostics".

enriched Enriched | None

Optional Enriched companion payload, populated only when DecompileRequest.enriched is True and decompilation succeeds. None otherwise.

flatline.AnalysisBudget dataclass

AnalysisBudget(max_instructions: int = DEFAULT_MAX_INSTRUCTIONS)

Deterministic per-request resource limits.

Attributes:

Name Type Description
max_instructions int

Maximum number of p-code instructions the decompiler will process before stopping. Defaults to 100000. Must be a positive integer.

Raises:

Type Description
InvalidArgumentError

If max_instructions is not a positive integer.

Example
budget = AnalysisBudget(max_instructions=500_000)
request = DecompileRequest(..., analysis_budget=budget)

Diagnostics

flatline.WarningItem dataclass

WarningItem(code: str, message: str, phase: str)

One decompiler warning.

Attributes:

Name Type Description
code str

Warning identifier string.

message str

Human-readable warning message.

phase str

Decompiler phase that produced the warning. One of VALID_WARNING_PHASES ("init", "analyze", "emit").

flatline.ErrorItem dataclass

ErrorItem(category: str, message: str, retryable: bool)

Structured error descriptor returned in DecompileResult.error.

Attributes:

Name Type Description
category str

Error category string from ERROR_CATEGORIES.

message str

Human-readable error message.

retryable bool

True if the operation might succeed on retry.