Repository navigation
Conversation
…witch Add PcodeSerializer.setEmitInstructions and serializeInstructions: one entry per listing instruction keyed by address, after address_ranges, with the disassembly text, the encoded length and the raw P-Code as strings that name registers (Varnode.toString(Language)) instead of (space, offset, size) tuples. Off by default; no CLI flag yet.
The first input of LOAD and STORE is the address space id as a constant; print the space name (STORE ram, RSP, ...) the way Ghidra's listing formatter does, instead of 0x1b1.
…appers Parse --emit-instructions, --no-emit-instructions and --emit-instructions=<bool> in PatchestryDecompileFunctions and pass the switch to PcodeSerializer; forward the flag through decompile-headless.sh and decompile-entrypoint.sh. Off by default. test/ghidra/emit_instructions.c runs the flag end to end through the headless container and checks the x86-64 prologue's readable P-Code.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add an opt-in
--emit-instructionsexport to the Ghidra P-Code serializer:the machine-level view of every function next to the high P-Code, meant as
input for LLM-driven decompilation (the LLM writes the C,
patchir-decomp -from-c -validate-pcodechecks it against this JSON, see #284).With the switch on, every function carries an
instructionsmap right afteraddress_ranges, one entry per listing instruction keyed by address:textis Ghidra's disassembly,lengththe encoded size in bytes, andpcodethe raw (low) P-Code of the instruction, one string per op, renderedwith register names (
Varnode.toString(Language)) instead of(space, offset, size)tuples. Off by default;patchir-decompignores thekey.
Steps
Landed as small verified commits, all pushed:
STORE ram, RSP, ...instead of
STORE 0x1b1, ...), found while inspecting the first output.--emit-instructionsflag inPatchestryDecompileFunctions, forwarding indecompile-headless.shanddecompile-entrypoint.sh, LIT testtest/ghidra/emit_instructions.c.scripts/ghidra/README.md,docs/system_data_flow.md, thepcode-serialization rule and AGENTS.md.
Testing
jars.
gradle buildsucceeds);lit test/ghidra --filter emit_instructionspasses end to end throughdecompile-headless.sh.testEmitInstructionsOffByDefaultandtestEmitInstructionsListsEveryBodyInstructionrun in the CI test container.