Skip to content

feat(ghidra): report decompiler warnings and dropped blocks with derived listing ranges - #4237

Open
RishTheFish21 wants to merge 1 commit into
morluto:mainfrom
RishTheFish21:feat/2735-decompiler-completeness
Open

RishTheFish21 wants to merge 1 commit into
morluto:mainfrom
RishTheFish21:feat/2735-decompiler-completeness

Conversation

@RishTheFish21

@RishTheFish21 RishTheFish21 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Ghidra's decompiler sometimes drops blocks it decides are unreachable. Until now, the only sign of this was a header comment inside the pseudocode, so a caller reading the dossier couldn't tell that code was missing, or where it was. #2735 describes an auth comparison sitting entirely in a dropped block.

This is the combined #2735 implementation agreed with @Bobtoshi on #2904. It keeps #2904's observed shape and adds a listing range and instructions as a separate, derived fact. analyze_function dossiers from Ghidra now include decompiler_completeness:

  • status (warnings, no-warnings-reported or unavailable), warnings, warning_count and diagnostic, as Ghidra reported them;
  • dropped_blocks: one entry per Removing unreachable block warning, with Ghidra's raw address_space and reported_offset, the resolved start (or null), its warning_index and end: null;
  • an optional, separately derived listing_block on each dropped block: the listing basic block that contains the reported start (relation: "contains-reported-start"), with its exclusive end and instructions.

Fixes #2735

This is one commit on current main. It no longer depends on #2977.

Problem and expected behavior

Before: a removed block shows up only as /* WARNING: Removing unreachable block (ram,0x...) */ in the pseudocode.

After, for a function whose block at entry+0x10 is removed (AArch64 ELF fixture, real Ghidra 12.2):

{
  "start": "0x100010",
  "end": null,
  "address_space": "ram",
  "reported_offset": "0x00100010",
  "reason": "unreachable",
  "warning_index": 0,
  "listing_block": {
    "provenance": "ghidra-listing-basic-block",
    "relation": "contains-reported-start",
    "start": "0x100010",
    "end": "0x100018",
    "assembly": ["0x100010: mov w0, #0x77", "0x100014: ret"]
  }
}
  • end stays null because Ghidra reports only where a removed block starts.
  • listing_block is derived from the listing, not reported by the decompiler. It can begin before the reported start and isn't claimed to be the whole removed region; its own limitation says so.
  • A start outside the function, or at an address with no listing block, gets no listing_block. An unknown or non-memory space gives start: null.

Change and scope

  • Bridge (analyzeFunctionObservation):
    • Warnings come from typed decompiler comment tokens: complete C comments whose fragments share one memory source address.
    • Analysts' comments stay in the pseudocode, because comment rendering isn't turned off (unlike feat(ghidra)!: preserve paged warnings and require observed comparison coverage #2904). One caller-authored comment with the same text at the same source address is discounted per occurrence, so a real decompiler warning with the same text still counts.
    • Removal coordinates are resolved through the address factory and scaled by the space's addressable unit. This handles overlays and word-addressed spaces (AVR: word 0x0804 → byte 0x1008).
    • Listing blocks come from BasicBlockModel. Their assembly isn't separately bounded: the block lies inside the function, whose full assembly the dossier already carries.
  • Schema: decompilerCompletenessSchema (from feat(ghidra)!: preserve paged warnings and require observed comparison coverage #2904, plus listing_block) is an optional field on the shared dossier. It's required on Ghidra dossiers, and the Ghidra refinement checks provenance, reported offsets and canonical addresses. Every field validates without changing the value, so Hopper's value-keeping reply contracts still hold.
  • Views: new native facets decompiler_completeness (summary), decompiler_warnings and decompiler_dropped_blocks. A pseudocode view adds an unknown when blocks were dropped.
  • Profile: no hand bump. The bridge source is part of the Ghidra producer identity, so snapshots from the previous bridge aren't replayed.
  • Left out, as agreed on feat(ghidra)!: preserve paged warnings and require observed comparison coverage #2904:

Contract and boundary impact

  • Semantic owner and earliest changed stage: Ghidra bridge analyze_function, then functionDossierSchema (src/domain/native/functionDossier.ts) and decompilerCompletenessSchema (src/domain/native/decompilerCompleteness.ts). The native views consume the parsed field.
  • Contribution scope fit and linked maintainer decision: Within existing boundaries (read-only static-analysis output). The design was agreed with feat(ghidra)!: preserve paged warnings and require observed comparison coverage #2904's author on feat(ghidra)!: preserve paged warnings and require observed comparison coverage #2904, following morluto's request to coordinate the two PRs.
  • CLI and MCP/tool-catalog contract: Additive. A new decompiler_completeness dossier field (optional in the shared schema, always present for Ghidra), three native view facets, and one pseudocode-view unknown when blocks were dropped.
  • Provider, bridge, target-format, or platform compatibility: Ghidra only. Hopper and IDA dossiers leave the field absent.
  • Evidence, artifact, provenance, or reconstruction contract: Observed and derived facts are separate fields with their own provenance. The bridge change changes the Ghidra producer identity.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): Not applicable.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: None authored.

Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated:
    • src/ghidra/GhidraFunctionValues.test.ts: accepts a warning with a derived listing block that starts before the reported start, and a dropped block with no listing block. Requires the field on Ghidra dossiers. Rejects foreign provenance, a non-null end, a stale count, a status/warnings mismatch, an out-of-range warning_index, a missing reported offset, a non-canonical start, a listing block without a start, and another relation.
    • src/domain/analysisView/analysisView.test.ts: the three new facets, the pseudocode unknown, and "not recorded" when the field is absent.
    • tests/conformance/ghidra/decompiler-removed-block.S, checked in verify:ghidra:aarch64-jump-table on AArch64 ELF and Mach-O: a single removed block, a dead region spanning several listing blocks (one warning per block, each derived listing block matching its reported start), a reachable control, and a string-literal decoy.
    • scripts/verify-real-ghidra-warning-provenance.mjs, with two probes through the production bridge:
      • ReaDecompilerWarningProvenanceProbe.java: caller-authored entry plate and body comments that spell a removal warning (for an in-body address, or for an unknown space) are not recorded and stay in comments. A plate repeating the real warning leaves exactly one dropped block.
      • ReaDecompilerRemovedBlockCoordinateProbe.java: overlay identity, a colliding offset in an ordinary function, unknown and register spaces (start: null), a start outside the function (no listing block), and an AVR word coordinate.
  • Base reproduction or other evidence: on main, analyze_function for the removed-block fixture returns the warning only inside pseudocode; no field records it.
  • User-visible CLI/MCP output (if applicable): the JSON above, from the real Ghidra 12.2 run.
  • Remaining proof gaps:
    • Checked only on a macOS arm64 host. Linux and Windows hosts weren't run.
    • The coordinate probe feeds one typed header warning token into the production bridge, because Ghidra doesn't emit a removal warning for those synthetic programs. The coordinate resolution and listing lookup are real; the warning token is synthetic.
    • Warning identification relies on Ghidra rendering warnings as comment tokens at a single typed address. The provenance lane would catch a change.
    • The AArch64 lane's host debug native-value CLI/MCP comparison was skipped locally: it fails the same way on plain main with Ghidra 12.2 on this Mac, before any removed-block fixture runs. CI covers it.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

At head ec75e92, macOS arm64, Ghidra 12.2 (decompiler natives built from the release's own source), Temurin 25.0.5.1, Node 24.22.1:

  • npm run check:fast — passed
  • npm run format:check — passed
  • npm run knip — passed
  • npm run docs:check — passed
  • npm run verify:ghidra:bridge-sources — passed (Ghidra 12.2, javac 25)
  • npm run test:focused -- src/ghidra/GhidraFunctionValues.test.ts src/domain/analysisView/analysisView.test.ts src/ghidra/GhidraRawProfileDigest.test.ts src/ghidra/GhidraSnapshotCache.test.ts src/ghidra/GhidraProvider.behavior.test.ts src/application/binary/AnalysisSnapshotCache.test.ts src/hopper/HopperReplyContracts.test.ts — 605 passed
  • npm run test:fast — 33,703 passed; 3 failed in src/desktop/ExportedAppPython.test.ts, which fail the same way on main on this Mac
  • npm run test:mcp — 2,294 passed
  • node scripts/verify-real-ghidra-warning-provenance.mjs — passed: ELF and Mach-O provenance (13 checks each) and the coordinate probe (AVR word 0x0804 → 0x1008)
  • npm run verify:ghidra:aarch64-jump-table — passed for ELF and Mach-O, including the removed-block fixtures; run with this lane's host debug native-value CLI/MCP comparison skipped locally, because it fails identically on plain main with Ghidra 12.2 on this Mac (CLI and MCP trace_native_values evidence IDs differ)

Compatibility, safety, and release

  • Breaking changes or migration steps: None for callers. The field and facets are additive. Cached Ghidra snapshots from the previous bridge aren't replayed.
  • Real Hopper/Ghidra, browser, or OS coverage: Real Ghidra 12.2 on macOS arm64 (AArch64 ELF and Mach-O objects, plus synthetic AArch64 overlay and AVR programs).
  • Package or release metadata impact: None.
  • Security, privacy, process, or containment review: Read-only analysis output. The probes write comments only into their own temporary projects, and every Ghidra process is owned and its cleanup confirmed before the workspace is removed.

Author readiness

Human owner: @RishTheFish21

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Author checklist (completed by the PR author before requesting review)

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.
  • I ran every test, build, or measurement needed to validate this change, reported a browser, GPU, or environment gap only when that runtime or hardware is unavailable, and reported the checks I ran and their results without presenting inferred correctness or speedups as measured.
  • Comments explain constraints or non-obvious decisions; task history and conversations stay out of code and docs.
  • Documentation is concise and factual, without punchy slogans or promotional language.
  • This change fixes the root cause and follows the engineering rules in AGENTS.md.
  • Formatted input is interpreted once at the owning boundary, and consumers use the owner's parsed facts. See Interpret boundary facts once.
  • Combined failures preserve partial observations, remaining resources, and cleanup facts. See Own the lifecycle.
  • A hardcoded limit is an REA_ runtime setting with a default, floor, and maximum, unless a fixed ceiling has a stated reason. See Adding a runtime setting.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-25T01:40:55.501613Z
We couldn’t complete this review. Comment @codex review to try again.
ec75e92 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The PR appears safe to merge; no new blocking issue was found.

Summary

Adds structured reports for blocks Ghidra removes from pseudocode.

  • Ghidra dossiers list blocks the decompiler removed from pseudocode.
  • Native views flag incomplete pseudocode and expose removed blocks.

No new actionable defects or confirmed security issues were found. This was a source review; tests were not run. GitHub access was unavailable, so whether another PR supersedes this one could not be checked.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Ghidra pseudocode] --> B[Read removal-warning headers]
  B --> C[Exclude caller-authored warning lines]
  C --> D{Address maps into function?}
  D -->|Yes| E[Collect listing range and instructions]
  D -->|No| F[Retain unmapped warning]
  E --> G[Function dossier]
  F --> G
  G --> H[Pseudocode unknowns]
  G --> I[Removed-block pages]
Loading

Reviews (7) · Last reviewed commit: "Merge commit 'd0067ba34a39ea47dd7e11bb2e..." · Reviewed by Greptile

Comment thread bridge/ghidra/ReaGhidraBridge.java Resolved
Comment thread scripts/verify-real-ghidra.mjs Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 88f543df89

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread bridge/ghidra/ReaGhidraBridge.java Resolved
Comment thread bridge/ghidra/ReaGhidraBridge.java Resolved
Comment thread bridge/ghidra/ReaGhidraBridge.java Resolved
Comment thread scripts/verify-real-ghidra-function.mjs Resolved
@greptile-apps

greptile-apps Bot commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Want your agent to iterate on Greptile's feedback? Try greploops.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4334dd3c62

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread bridge/ghidra/ReaGhidraBridge.java Resolved
@kaoru0822-kitauji kaoru0822-kitauji added the ci-fix-wip Claimed by the CI-fix track label Oct 16, 2026
@kaoru0822-kitauji

Copy link
Copy Markdown
Collaborator

CI/conflict track: the earlier Static checks failure was format:check, inherited from main's format baseline at the time, not from this PR. This branch passes oxfmt --check . both on its own head and merged with current main. I merged main (42fc6c53a) into the branch (5ddaab794, no conflicts) so CI reruns on the current baseline.

Ran locally on the merged tree: build, npm run check:fast, npm run docs:check, and analysisView, GhidraFunctionValues and GhidraProvider.behavior (207 passed). The 7 cleanup/cancellation test failures currently red on main (#4345) will still show here and are not from this PR.

@kaoru0822-kitauji kaoru0822-kitauji removed the ci-fix-wip Claimed by the CI-fix track label Oct 16, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@baron baron left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed unchanged head ce4e63c92eb37c201452ca055542409a508bbcc8; repository CI, including CI required, is green and human readiness declarations are filled. The capability is ordinary read-only analysis within existing scope, not a new execution or mutation capability.

[P2] The existing decompiler-warning provenance finding remains partially unresolved. This continues the existing thread, rather than adding another inline duplicate. At ReaGhidraBridge.java:3365–3374, restricting the regex to whole lines before { excludes body string literals, but not user-authored function header comments. Ghidra 12.1.4 enables the entry-point plate/header comment by default (DecompileOptions), encodes that plate text as header (DecompileCallback), and prints ordinary headers and warning headers through the same comment renderer before the function declaration (PrintC).

Consequently, an entry plate comment WARNING: Removing unreachable block (ram,0x401010) naming a valid in-body address has the exact accepted rendering even when no block was removed. It becomes a false removed-block record, unrelated listing assembly, and a false pseudocode omission warning. Please keep the decompiler-owned warning provenance at the producing boundary and add a real-provider plate-comment decoy alongside the existing string-literal decoy, without discarding caller comments from retained evidence.

This is source-derived, supported by a synthetic regex-only probe; I did not reproduce it in a running Ghidra instance. The author's real macOS/Ghidra receipts cover actual removals and string decoys, not this header-comment case. No independent source suite ran here (pinned toolchain/locked dependencies unavailable); no dependencies/providers were installed.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@RishTheFish21

Copy link
Copy Markdown
Contributor Author

Thanks, confirmed in a running Ghidra 12.1.4. Ghidra passes the entry plate comment to the decompiler as a "header" comment (DecompileCallback.encodeHeaderComment), and PrintC::emitCommentFuncHeader prints it through the same renderer as warningheader comments, so the rendered text alone can't tell them apart.

Fixed in in the bridge, where the caller-supplied header text is known. When the header comment option is on, the bridge renders the function's entry plate comment the way PrintLanguage::emitLineComment does, collects the removal-warning identities that rendering produces, and discounts one rendered header match per caller-authored line. Only the remainder is decompiler-owned. Pseudocode and the comments facet are unchanged, so the caller's comment stays in the evidence. A plate repeating a real warning renders twice and still yields exactly one removal. With default options, no other caller comment reaches the header (EOL/PRE/POST at the entry are body comments, and unplaced comments are off).

New real-Ghidra lane: node scripts/verify-real-ghidra-warning-provenance.mjs (probe tests/conformance/ghidra/ReaDecompilerWarningProvenanceProbe.java). It adds plate comments to a real analysis database of decompiler-removed-block.S and runs analyze_function through the production bridge in-process, since REA's tools can't set plate comments.

Before the fix (ce4e63c bridge), AArch64 ELF. An entry plate on rea_reachable_block naming its in-body block start becomes a removed block that wasn't removed:

Warning provenance assertion failed: plate_decoy_not_recorded: {"removed_blocks":[{"start":"0x100024","reason":"unreachable","end":"0x10002c","assembly":["0x100024: mov w0, #0x77","0x100028: ret"]}],"unmapped_warnings":[]}

After the fix, macOS arm64, Ghidra 12.1.4, both formats pass:

  • ELF (real removal at 0x100010) and Mach-O (0x10): baseline_real_removal, plate_decoy_rendered_as_header, plate_decoy_not_recorded, plate_decoy_no_omission_limitation, plate_decoy_comment_retained, plate_unmapped_decoy_not_recorded, repeated_warning_rendered_twice, repeated_warning_keeps_real_removal
  • cleanup: complete

Linux and Windows not run.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@RishTheFish21

Copy link
Copy Markdown
Contributor Author

Status update: this is merged with current main, with the two #4650 conflicts resolved in analyzeFunctionObservation, and CI is green.

From my side it’s ready for another look whenever it suits you

@CassieFox23 CassieFox23 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TL;DR: Main does not have this feature, and I found no code defect by reading the diff. A change request from baron still stands on an older head, and the commit that answers it has had no re-review. The body is out of date on two points.

Findings

Should fix

  • The body is out of date. The "Change and scope" text leaves out the plate comment fix from commit ffc09fc. The "Validation performed" list does not name the new real-Ghidra check, scripts/verify-real-ghidra-warning-provenance.mjs. The author's comment lists the results, but the template asks that the body stay current.
  • The body does not say that every native pseudocode view gains a new note when the record is missing. The code adds a "not recorded" note when the field is absent. That covers Hopper and IDA views and older cached Ghidra results. The docs say this and a test checks it. The body says the note appears only when blocks were removed.

Worth knowing

  • baron's change request is on the older head ce4e63c. It says an entry plate comment can fake a removal warning. Commit ffc09fc answers it. I read the new bridge code. It renders the plate comment the way Ghidra does in PrintLanguage::emitLineComment. Then it skips one matching header line for each line the author wrote. I read that Ghidra function at tag Ghidra_12.1.4_build, and the steps match. The author's real-Ghidra results are in the comment above. I did not run them. GitHub still shows the change request, and I saw no newer review from baron.
  • Pull request 2904 is open and also says it relates to the same issue. Its file list includes ReaGhidraBridge.java, hopperValues.ts and nativeFunctionView.ts, which this PR also changes. I did not read its diff. Whichever lands second will need to fit the other. This is a maintainer call.
  • The new real-Ghidra check is not in package.json or any workflow on this head. The README says to run it by hand. The older verify:ghidra:aarch64-jump-table command is not in a workflow either. So the real-Ghidra evidence is the author's own macOS arm64 runs.

Looks good

  • Main does not have the feature. A search of main (e83e3ce) for decompiler_completeness, removed_blocks and Removing unreachable block in src, bridge, docs and scripts found nothing.
  • The bridge only reads warning lines in the header, before the line with the opening brace. A string literal in the body cannot match. See the pattern and header cut. A warning that cannot be mapped into the function goes to unmapped_warnings and is not dropped.
  • The schema is strict. The Ghidra check rejects duplicate starts. It also rejects assembly with no mapped range. It also checks the new addresses are canonical. The cache profile key moves to v2, so old snapshots are not replayed.
  • The unit tests cover bad addresses, unknown reasons and duplicates. They also cover an empty record versus an absent one. All nine bot review threads are resolved and marked outdated. The Codex summary on this head shows no findings. Greptile gave 5/5.
  • Hosted CI is green on this head. That covers the 8 test shards, Static checks and Docs Generation. It also covers Portable tests, the ghidra_bridge compile job and CI required. The PR readiness status passes.
  • The body keeps every template heading, label and box.
  • I tried a merge of this head with main. Nine files changed on both sides since the merge base, and a three-way text merge of each gave no conflict. This is a text merge only. I did not build or type-check the result.

Not run

  • No build and no tests. This is a read-only review of the diff against main.
  • I did not run the real-Ghidra checks. The author reports Linux and Windows were not run either.
  • The author's macOS results and the claim that the check fails on the old bridge are not verified by me.
  • I did not read the full diff of pull request 2904.

Thanks, RishTheFish21, for the feature, and for the fixture and the decoy checks that pin it.

Test setup
  • Box: Nobara 44 (Fedora 44 base), Linux 7.2.11
  • Head / base: f6334dd / e83e3ce (main). Merge base d0067ba.

🤖 Written with Claude Code (Sonnet 5.5, verified by Opus 5.5), posted with my OK 🦊

@morluto

morluto commented Oct 26, 2026

Copy link
Copy Markdown
Owner

Thanks for exposing removed-block observations. #2904 also addresses #2735 and includes warning provenance and comparison coverage, while this PR proposes mapped block ranges and assembly. Could you coordinate on the evidence needed to establish those ranges and keep the distinct supported cases in one review? Both proposals remain open.

@RishTheFish21

Copy link
Copy Markdown
Contributor Author

Thanks @morluto, and cc @Bobtoshi. I went through #2904 in detail. Here's how the two compare, and a concrete proposal for doing #2735 in one review.

What each one covers

#2904 #4237
Observed warnings Every pseudocode WARNING: text, the diagnostic, a status, and dropped_blocks with start, address space, raw offset and warning_index; end is always null Only removal warnings, as removed_blocks, plus unmapped_warnings
Range and instructions of a dropped block Not provided end from the listing block containing the start, and that block's assembly (the "instruction fallback" #2735 asks for)
Keeping caller comments from posing as warnings Turns off PRE/PLATE/POST/EOL/header comments in the decompiler, so analysts' own comments disappear from every pseudocode Keeps them and subtracts matching entry-plate lines
Other scope Paged warning views, workflow limitation plumbing, and a breaking change to function-comparison coverage (fix(comparison)!), across 48 files 15 files

Where #2904 stands

  1. Adopt feat(ghidra)!: preserve paged warnings and require observed comparison coverage #2904's observed envelope as is: status, warnings, diagnostic, dropped_blocks with start, address_space, reported_offset, warning_index and end: null. Bobtoshi gets co-author credit.
  2. Add the derived part separately: an optional listing_block: { start, end, assembly, relation: "contains-reported-start" } per dropped block, with its own limitation, so the observed end stays null.
  3. Keep analysts' comments in pseudocode. Instead of turning comments off, identify decompiler warnings from typed ClangCommentToken runs, the approach feat(ghidra): report computed branches without a recovered jump table #2977 now uses for jump-table warnings. The block address still comes from the warning text, because removal warnings are header warnings attached to the entry. So I'd resolve (space,offset) through the address factory and check it on an overlay and a word-addressed target with feat(ghidra): report computed branches without a recovered jump table #2977's attribution probe.
  4. Leave the comparison-coverage change out. It's a separate breaking decision that feat(ghidra)!: preserve paged warnings and require observed comparison coverage #2904's author can still propose on its own.
  5. Order: after feat(ghidra): report computed branches without a recovered jump table #2977 merges, since this reuses its token handling.
    Evidence for the ranges: the existing AArch64 ELF and Mach-O fixture, plus two new cases. One is a removed region spanning more than one listing block, which should report only the first block and say so. The other is a start with no listing block, which should report no listing_block.

@Bobtoshi

Bobtoshi commented Nov 6, 2026

Copy link
Copy Markdown

Thanks @RishTheFish21 and @morluto. Yes, let’s use #4237 for the combined warning and instruction-fallback work.

I agree with the proposed split: retain #2904’s observed envelope, raw offsets, warning association and end: null; put the listing block and instructions in a separately derived object. contains-reported-start must not imply that the listing block is the complete removed region. The multi-block, missing-block, overlay, word-addressed and warning-provenance cases are useful checks for that boundary.

Preserving analysts’ comments and reusing the typed-token attribution from #2977 is a better direction than carrying over #2904’s comment-rendering toggle. Keep the comparison-coverage change out of the combined PR; it is a separate breaking decision.

Please preserve Bobtoshi’s co-author credit for the incorporated work. The source shape is pinned at a73ec1251. I’ll keep #2904 open as the reference until the combined implementation and attribution are present, so there is no need for competing integrations.

@morluto morluto added area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior enhancement New feature or request provider: ghidra Analysis provider / engine: ghidra labels Nov 23, 2026
@morluto

morluto commented Nov 24, 2026

Copy link
Copy Markdown
Owner

@RishTheFish21 thanks for the PR — this branch has merge conflicts with main. Could you merge or rebase onto the latest main and resolve them? Once it's clean and CI is green we can take another look.
cc @gensokyo-dev @dandgabr

…ved listing ranges

Ghidra analyze_function dossiers now carry decompiler_completeness: the
warnings Ghidra's decompiler rendered, taken from typed comment tokens so
caller-authored comments never count, and one dropped block per "Removing
unreachable block" warning with its raw space and offset, resolved start
and end: null. A dropped block whose start lies in the function also gets a
separately derived listing_block: the listing basic block that contains the
reported start, with its exclusive end and assembly.

Native views add decompiler_completeness, decompiler_warnings and
decompiler_dropped_blocks facets, and the pseudocode view names the
omission. The warning-provenance lane checks caller comment decoys on real
AArch64 objects and removal coordinates on overlay, colliding, unknown,
register and AVR word-addressed spaces.

Fixes morluto#2735

Co-authored-by: Bobtoshi <[email protected]>
@RishTheFish21
RishTheFish21 force-pushed the feat/2735-decompiler-completeness branch from f6334dd to ec75e92 Compare November 25, 2026 01:40
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@RishTheFish21 RishTheFish21 changed the title feat(ghidra): report blocks the decompiler removed as unreachable feat(ghidra): report decompiler warnings and dropped blocks with derived listing ranges Nov 25, 2026
@RishTheFish21

Copy link
Copy Markdown
Contributor Author

@morluto Thanks. I've rebuilt this as one commit on current main (ec75e92e0), so the conflicts are gone and it no longer depends on #2977. It's the combined #2735 implementation agreed with @Bobtoshi on #2904: #2904's observed decompiler_completeness shape (status, warnings, diagnostic, and dropped_blocks with raw offsets, warning_index and end: null), plus a separate, derived listing_block with relation: "contains-reported-start". Bobtoshi is credited as co-author.

On real Ghidra 12.2 (macOS arm64) the warning-provenance lane passes for ELF and Mach-O, including overlay and AVR word-addressed coordinates. The AArch64 lane passes the removed-block fixtures on both formats; its unrelated host native-value comparison fails the same way on plain main here, so I skipped that one step locally. Details are in the description; I'll follow up here once CI finishes.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior enhancement New feature or request provider: ghidra Analysis provider / engine: ghidra

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Structured decompiler-completeness signal in function dossiers (+ optional instruction fallback for dropped blocks)

6 participants