Session¶
A DecompilerSession owns one native bridge
session and amortizes library initialization, runtime data resolution, and
language/compiler enumeration across multiple calls. Use it as a context
manager for deterministic cleanup, or manage the lifecycle manually with
close().
For one-off operations, the module-level convenience functions create a short-lived session, run one operation, and tear it down immediately.
Session API¶
flatline.DecompilerSession ¶
DecompilerSession(runtime_data_dir: str | Path | None = None, *, _bridge_session: BridgeSession | None = None)
Long-lived decompiler session owning one native bridge session.
A session amortizes startup costs (library initialization, runtime data
resolution, language/compiler enumeration) across calls. Use it as a
context manager for deterministic resource cleanup, or call
close() explicitly when done.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
runtime_data_dir
|
str | Path | None
|
Path to the Ghidra runtime data directory containing
processor |
None
|
Example
Attributes¶
Functions¶
decompile_function ¶
Decompile a single function described by request.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
DecompileRequest
|
A |
required |
Returns:
| Type | Description |
|---|---|
DecompileResult
|
A |
Raises:
| Type | Description |
|---|---|
InvalidArgumentError
|
If the session has been closed or the request contains invalid arguments. |
UnsupportedTargetError
|
If the |
InvalidAddressError
|
If the function address is outside the memory image. |
DecompileFailedError
|
If the decompiler engine fails internally. |
list_language_compilers ¶
Enumerate valid language/compiler pairs available in this session.
Returns only pairs whose backing assets (.sla files and compiler
specs) are present in the session's runtime data directory. Covers
all bundled ISAs including x86, ARM, RISC-V, MIPS, and others.
Returns:
| Type | Description |
|---|---|
list[LanguageCompilerPair]
|
List of |
Raises:
| Type | Description |
|---|---|
InvalidArgumentError
|
If the session has been closed. |
One-Shot Functions¶
flatline.decompile_function ¶
Decompile a single function (one-shot convenience wrapper).
Creates a short-lived DecompilerSession, runs the
decompilation, and closes the session deterministically.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
DecompileRequest
|
A |
required |
Returns:
| Type | Description |
|---|---|
DecompileResult
|
A |
Raises:
| Type | Description |
|---|---|
InvalidArgumentError
|
If the request contains invalid arguments. |
UnsupportedTargetError
|
If the target is not recognized. |
InvalidAddressError
|
If the function address is unmapped. |
DecompileFailedError
|
If decompilation fails internally. |
flatline.list_language_compilers ¶
Enumerate valid language/compiler pairs (one-shot convenience wrapper).
Creates a short-lived DecompilerSession, runs the enumeration,
and closes the session deterministically.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
runtime_data_dir
|
str | Path | None
|
Optional path to the Ghidra runtime data directory.
When |
None
|
Returns:
| Type | Description |
|---|---|
list[LanguageCompilerPair]
|
List of |
flatline.get_version_info ¶
Report runtime version information.
Returns:
| Type | Description |
|---|---|
VersionInfo
|
The installed flatline package version and the underlying Ghidra decompiler engine version. |
Return Types¶
flatline.LanguageCompilerPair
dataclass
¶
One valid language/compiler pair known to the runtime data directory.
Attributes:
| Name | Type | Description |
|---|---|---|
language_id |
str
|
Language identifier (e.g. |
compiler_spec |
str
|
Compiler specification (e.g. |
flatline.VersionInfo
dataclass
¶
Runtime version information.
Attributes:
| Name | Type | Description |
|---|---|---|
flatline_version |
str
|
The installed flatline package version. |
decompiler_version |
str
|
The underlying Ghidra decompiler engine
version (e.g. |