Repository navigation
1after909-doit-73591e: recover break/continue for loop-exit gotos (loopbreak_recovery, DIV-7) - #55
Merged
Merged
Conversation
…t gotos (loopbreak_recovery) angr renders 1after909::doit with 0 gotos; kuna emits 10 (9 are `goto label_239f`, which are really `break;` out of the command loop). Closing this requires porting Ghidra's BlockGraph::scopeBreak (a recorded SEAM stub in blockaction.rs / losses.md) plus a printer change -- S8 structuring, LARGE per Hard Rule 7. Proposal only. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Contributor
Author
|
APPROVE |
…tion loopbreak_recovery, DIV-7) Port Ghidra BlockGraph::scopeBreak into a new s8_structure/kuna_loopbreak_recovery.rs pass: a recursive walk over the structured tree that retags loop-exit (and switch-exit) goto edges f_goto_goto -> f_break_goto, so the printer emits break; instead of `goto <successor-label>;` + a synthesized label. Closes the angr gap on test_decompiling_1after909_doit::doit (10/2 -> 1/1 gotos/labels). Gated by Architecture::recover_loop_break (option loopbreak_recovery, ElementId 4091), called from ActionFinalStructure::apply between finalizePrinting and markUnstructured. Ablation clean (0/675 datatest assertions change; make rust-test green), speed +0.12% -> shipped DIV-7 default-on. The printer already emitted break; for f_break_goto and block.rs already had next_flow_after/get_exit_leaf, so no printc.rs or block.rs edit was needed. Tests: tests/stages/ghangr-1after909-doit-73591e.xml (two-pass off/on), baseline-stages +2; kuna-catalog.xml provenance counts bumped for the new 24th settable. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
mahaloz
marked this pull request as ready for review
June 25, 2026 15:50
Union-resolve the divergence collisions for the loopbreak_recovery structure-recovery option (DIV-7 on the branch, renumbered to DIV-10 since main's max is DIV-9): - divergences.md: keep main's DIV-7..9, add loopbreak as DIV-10 - architecture.rs / seams.rs: union recover_loop_break + fold_call_returns fields/ctors/resets/seam-copies; DIV-7 -> DIV-10 in comments - loopbreakrecovery ElementId 4091 -> 4092 (4091 now held by dedupvardecls) - stages.toml / catalog fixtures / counts: 43 settables, 91 surfaces; catalog provenance counts angr 9, structure-recovery 5 - regenerate assertions.md + baseline-stages.json (165/165) - UPSTREAM.md / PROGRESS.md union Gates: catalog OK, make test PARITY OK (675/675), make test-stages PARITY OK (165/165). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01PBrckq3YYAzBLq5k4KpWac
…3591e (#55) Re-merge after main advanced (PR #67 added the macho-arm64e loader-tier settable). Union the count drift: - 44 settables now (26 stage-model knobs + 15 analysis gates + 3 loader caps: relocobjects/i386_pie_plt/macho-arm64e), surface=91 - kuna_stages/tests.rs + catalog_bytecompat.rs count assertions -> 44; trailing-comma count -> 43 (last row now macho-arm64e) - loopbreak_recovery (DIV-10) provenance unchanged; angr=9, structure-recovery=5 - regenerate stage_catalog fixture, assertions.md, baseline-stages.json (165/165) Gates: catalog OK, make test PARITY OK (675/675), make test-stages PARITY OK (165/165). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01PBrckq3YYAzBLq5k4KpWac
mahaloz
added a commit
that referenced
this pull request
Jun 25, 2026
…57) Union-resolve the registrations for the gotoreduce opt-in option (angr SAILR ReturnDuplicator goto-reduction) against main, which had advanced with the #55 (loopbreak_recovery/DIV-10) and #67 (macho-arm64e) settables: - architecture.rs / seams.rs / options.rs: union reduce_return_gotos with recover_loop_break/fold_call_returns fields, ctors, resets, set_kuna_option arms, KUNA_OPTION_NAMES, seam-copies - s8_structure/mod.rs: union kuna_gotoreduce + kuna_loopbreak_recovery modules - stages.toml: union the gotoreduce settable; 45 settables now (27 stage-model + 15 analysis + 3 loader caps), surface=91 - gotoreduce ElementId 4100 (no collision: dedup 4091, loopbreak 4092) - catalog provenance counts: angr 10, structure-recovery 6 (gotoreduce both) - count assertions (kuna_stages/tests.rs, catalog_bytecompat.rs, xml.rs corpus 137 files) bumped; regenerate stage_catalog fixture, assertions.md, baseline-stages.json (168/168) - gotoreduce is opt-in (default-off) -> no DIV entry Gates: catalog OK, make test PARITY OK (675/675), make test-stages PARITY OK (168/168). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01PBrckq3YYAzBLq5k4KpWac
mahaloz
added a commit
that referenced
this pull request
Jun 25, 2026
Region-structurer foundation (Inc 0) — analysis-only, no new --option. Main had advanced with #55 (loopbreak_recovery/DIV-10), #57 (gotoreduce), #67 (macho-arm64e); the only conflict was docs/baseline-stages.json (data_footer counts), all other region code (s7_regions/kuna_regiongraph.rs, kuna_regionid.rs, kuna_console.rs) and the kuna-regions.xml assertions merged cleanly. Regenerated assertions.md (45 settables, unchanged) and baseline-stages.json (171/171, incl. the 8 KUNA-REGIONS assertions plus main's gotoreduce/loopbreak/catalog ones). Gates: catalog OK, make test PARITY OK (675/675), make test-stages PARITY OK (171/171). Region unit tests: regionid 6/6, regiongraph 18/18 (incl. new build_from_block_graph_*). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01PBrckq3YYAzBLq5k4KpWac
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.
loopbreak_recovery: recoverbreak;for loop-exit gotos (port of GhidrascopeBreak)Closes the angr-vs-kuna gap on
test_decompiling_1after909_doit::doit. angr renders thecommand-processing
whileloop with 0 gotos / 0 labels — every error/quitpath is astructured
break;. kuna emitted 10 gotos / 2 labels, nine of themgoto label_239f;tothe loop's shared cleanup successor (the semantic
break;) plus a synthesizedlabel_239f:.See
analysis.mdand the side-by-sideangr-vs-kuna.txt.Mechanism
angr's Phoenix/SAILR structurer runs loop-successor refinement (break/continue recovery). The
upstream equivalent is Ghidra
BlockGraph::scopeBreak(-1,-1), called inActionFinalStructurebetween
finalizePrintingandmarkUnstructured— which kuna's port had left an explicit SEAMstub (
docs/rust-port/losses.md).This PR ports it as a new module
s8_structure/kuna_loopbreak_recovery.rs: a single recursivewalk over the already-collapsed structured tree (
BlockGraph/BlockGoto/BlockIf/BlockSwitch/BlockWhileDo/BlockDoWhile/BlockInfLoop/BlockMultiGoto/BlockCondition), carryingcurexit(the fall-through block) and
curloopexit(the innermost loop's successor). A goto whose targetequals
curloopexitis retaggedf_goto_goto → f_break_goto. The printer already emitsbreak;for that flag, and
markUnstructured(run after) then suppresses the now-dead successor label.BlockIdequality is the faithful analog of the C++getIndex()identity. It only flipsgototypeflags on already-structured nodes — no CFG/SSA/type change.The whole pass is gated by
Architecture::recover_loop_break, called fromActionFinalStructure::apply; the only ported-core edits are that one gated call plus theflag/option wiring.
Option
option loopbreak_recovery on|off(ElementId 4091). DIV-7 default-on;option loopbreak_recovery offrestores the byte-identical raw-gotorendering.Ablation / parity
make teststays PARITY OKwithout regeneration.
make rust-test(cargo unit + golden differential +.slaparity) green with the flip on.doit, within the 5% budget).scopeBreakunconditionally) ⇒ shipped default-on (DIV-7).
On
doitthe ninegoto label_239f;becomebreak;andlabel_239f:disappears (10/2 → 1/1gotos/labels; the lone remaining
goto label_1dcais a forward jump into the loop head, aseparate structural gap, correctly left untouched).
Stage test:
tests/stages/ghangr-1after909-doit-73591e.xml(two-pass off/on).🤖 Generated with Claude Code
Before / after —
doitin1after909Real captured kuna output on the function this feature was built for, with
option loopbreak_recoveryflipped. Ported from angr — test_decompiling_1after909_doit; Phoenix/SAILR loop-successor break/continue recovery (Ghidra BlockGraph::scopeBreak); doit.loopbreak_recovery offloopbreak_recovery on(default)kuna — before (
option loopbreak_recovery off)kuna — after (
option loopbreak_recovery on)angr reference (the goal, v9.2.213)