feat(dwarf): capture per-instruction machine-offset → wasm-op source map (VCR-DBG-001, #242) - #427
Merged
Merged
Conversation
…map (VCR-DBG-001, #242, #394) PR A of the v0.12.0 DWARF `.debug_line` release: close the encoder machine-offset gap so a later step can emit source-line debug info. `compile_wasm_to_arm` now captures a `LineMap = Vec<(machine_offset, wasm_op_index)>` during the encode loop — `code.len()` immediately before each `encode()` is the instruction's final offset within the function's `.text` (the trailing literal pool is appended at the end and the LDR patch is in-place, so earlier offsets never shift). Carried on `CompiledFunction.line_map`. Frozen-safe by construction: the map is captured but NEVER serialized, so the emitted `.text` is byte-identical with or without it. Proven by the existing differential fixtures staying green plus `test_line_map_is_wellformed_dbg001`, which asserts monotonic, in-bounds offsets and that recompilation yields identical code. ARM only; the RISC-V backend carries an empty map (DWARF emit there is a follow-up). Next (PR B): gimli as a production dep (auto-picked up by Bazel via from_cargo, #422), read the input wasm's `.debug_line`, and emit a non-ALLOC `.debug_line` section behind a `--debug-line` flag, gated by an additivity byte-diff oracle. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This was referenced Jun 22, 2026
avrabe
added a commit
that referenced
this pull request
Jun 22, 2026
, #394) (#440) First release of the north-star verified-codegen campaign. Pin sweep 0.11.51 -> 0.12.0 (workspace + all path-dep versions + MODULE.bazel + Cargo.lock), CHANGELOG, and VCR-DBG-001 roadmap status -> implemented. Ships: - VCR-DBG-001 `--debug-line` DWARF emission (PR A #427 / B #429 / C #430): debugger-readable .debug_* mapping ARM .text -> wasm source lines, with .rel.debug_* relocations verified end-to-end against arm-none-eabi-ld. Purely additive; default build bit-identical. - VCR-MEM-001 layer-2 frozen-safe budget decision logic + oracles (#421-#425). - gimli 0.33 adaptation (#439) + wast 252 (#438). Minor bump: new user-facing `--debug-line` feature (semver-correct). Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
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.
What — PR A of v0.12.0 (DWARF
.debug_line)Closes the encoder machine-offset gap that blocked DWARF line emission.
compile_wasm_to_armnow captures aLineMap = Vec<(machine_offset, wasm_op_index)>during the encode loop and carries it onCompiledFunction.line_map.The offset is
code.len()taken immediately before eachencode()— the instruction's final position in the function's.text, because nothing after the loop shifts earlier instructions (the literal pool is appended at the end; the LDR placeholder patch is in-place/length-preserving).Frozen-safe by construction
The map is captured but never serialized in this PR, so the emitted
.textis byte-identical with or without it. Proven by:test_line_map_is_wellformed_dbg001— asserts monotonic, in-bounds offsets and that recompilation yields identical code (the side-table doesn't perturb output).ARM only; the RISC-V backend carries an empty map (its DWARF emit is a VCR-DBG-001 follow-up).
Where this sits
This is the first of two PRs for v0.12.0. Next (PR B):
gimlias a production dep (auto-resolved by Bazel via from_cargo #422), read the input wasm's.debug_line, and emit a non-ALLOC.debug_linesection behind a--debug-lineflag — gated by an additivity byte-diff oracle (flag-on vs flag-off: only.debug_linediffers;.text/.data/.bssidentical).Verification
cargo test -p synth-backend --lib→ 204 pass (incl. the new test); integration fixtures greencargo clippy --all-targets -- -D warningsclean (added aLineMaptype alias for the return tuple);cargo fmt --checkcleanrivet checkzero non-xref errors; roadmap VCR-DBG-001 step-5a progress recordedRefs #242, #394.
🤖 Generated with Claude Code