Skip to content

Expose decompilation line maps in CLI#212

Merged
mahaloz merged 2 commits into
binsync:mainfrom
subwire:cli-decompile-line-maps
Jul 22, 2026
Merged

Expose decompilation line maps in CLI#212
mahaloz merged 2 commits into
binsync:mainfrom
subwire:cli-decompile-line-maps

Conversation

@subwire

@subwire subwire commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add decompiler decompile --map-lines --json
  • pass the existing map_lines=True request through to the backend
  • serialize backend line maps as deterministic records containing a pseudocode line, sorted integer addresses, and matching hex addresses
  • reject combinations that would silently discard the mapping (--raw or text output)
  • document the contract in the CLI guide and bundled agent skill
  • run test_decompiler_cli.py in the decompiler CI job

Motivation

DecLib already supports Decompilation.line_map across its backends, but the CLI did not expose it. In our ENOWARS 10 agent logs, all 27 IDA decompilation calls requested statement addresses. Agents used those addresses for navigation, comments, and patch analysis, making this one of the most consistently used gaps between the current MCP and DecLib CLI surfaces.

Example output:

"line_map": [
  {"line": 4, "addrs": [1849], "addrs_hex": ["0x739"]}
]

A list-of-records contract avoids JSON's string-only object keys and normalizes backend sets/lists into stable, sorted output. It also preserves multiple instruction addresses for one pseudocode line.

Testing

  • pytest tests/test_decompiler_cli.py::TestCLIFormatters -q — 5 passed
  • pytest tests/test_artifacts.py tests/test_decompiler_cli.py -q -k 'not test_install_skill_default_falls_back_to_claude' — 28 passed, 213 skipped, 1 pre-existing environment-sensitive test deselected
  • documented core suite (tests/test_artifacts.py tests/test_cli.py) — 11 passed
  • end-to-end angr smoke test on a temporary arm64 Mach-O: load, decompile _main --map-lines --json, and stop all succeeded; output included mapped lines with both single and multiple instruction addresses

The backend-parametrized CLI test will exercise angr, Ghidra, IDA, and Binary Ninja where each dependency/license is available in the existing decompiler CI environment.

@mahaloz
mahaloz merged commit 24cae3b into binsync:main Jul 22, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants