Skip to content

Add create-type, retype, and sync to the decompiler CLI#195

Merged
mahaloz merged 1 commit into
mainfrom
feat/dec-sync
Jun 3, 2026
Merged

Add create-type, retype, and sync to the decompiler CLI#195
mahaloz merged 1 commit into
mainfrom
feat/dec-sync

Conversation

@mahaloz

@mahaloz mahaloz commented Jun 3, 2026

Copy link
Copy Markdown
Member

Feature 1 (retyping):

  • create-type "<C def>" parses a C struct/enum/typedef into a libbs artifact (new libbs/api/type_definition_parser.py, pycparser-based with natural-alignment offsets) and applies it across any backend.
  • retype <func> <var> <type> sets a local variable's or argument's type.

Feature 2 (syncing):

  • sync <func> --from-id <src> [dest filters] copies a function's name, return/arg types, stack-variable names+types, and referenced user types from one running server into another for the same binary. Addresses and stack offsets are canonical, so artifacts re-key across decompilers.

Underlying fixes required for cross-decompiler (IDA->Ghidra) sync:

  • ghidra headless: force -Djava.awt.headless=true so a stale DISPLAY no longer crashes the JVM with an X11 AWTError.
  • Function.setstate: initialize the dec_obj slot so access after a deserialization round-trip (get_dependencies, rename) doesn't raise.
  • IDA headless DummyIDACodeView: implement real set_lvar_type/rename_lvar via modify_user_lvar_info/rename_lvar so retypes persist headlessly.
  • ghidra typestr_to_gtype: resolve a pointer-to-user-struct (e.g. "Point *") by building the pointer from the looked-up base type.

Tests (tests/test_decompiler_cli.py): parser unit tests, create-type/retype across angr/Ghidra/IDA, and IDA->Ghidra sync of both names and types. SKILL.md documents the three new commands.

Demo

libbs-demo

Feature 1 (retyping):
- `create-type "<C def>"` parses a C struct/enum/typedef into a libbs
  artifact (new libbs/api/type_definition_parser.py, pycparser-based with
  natural-alignment offsets) and applies it across any backend.
- `retype <func> <var> <type>` sets a local variable's or argument's type.

Feature 2 (synching):
- `sync <func> --from-id <src> [dest filters]` copies a function's name,
  return/arg types, stack-variable names+types, and referenced user types
  from one running server into another for the same binary. Addresses and
  stack offsets are canonical, so artifacts re-key across decompilers.

Underlying fixes required for cross-decompiler (IDA->Ghidra) sync:
- ghidra headless: force -Djava.awt.headless=true so a stale DISPLAY no
  longer crashes the JVM with an X11 AWTError.
- Function.__setstate__: initialize the dec_obj slot so access after a
  deserialization round-trip (get_dependencies, rename) doesn't raise.
- IDA headless DummyIDACodeView: implement real set_lvar_type/rename_lvar
  via modify_user_lvar_info/rename_lvar so retypes persist headlessly.
- ghidra typestr_to_gtype: resolve a pointer-to-user-struct (e.g. "Point *")
  by building the pointer from the looked-up base type.

Tests (tests/test_decompiler_cli.py): parser unit tests, create-type/retype
across angr/Ghidra/IDA, and IDA->Ghidra sync of both names and types. SKILL.md
documents the three new commands.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mahaloz mahaloz merged commit f913991 into main Jun 3, 2026
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.

1 participant