Skip to content

feat(dwarf): capture per-instruction machine-offset → wasm-op source map (VCR-DBG-001, #242) - #427

Merged
avrabe merged 1 commit into
mainfrom
vcr-dbg-001-linemap-capture
Jun 22, 2026
Merged

feat(dwarf): capture per-instruction machine-offset → wasm-op source map (VCR-DBG-001, #242)#427
avrabe merged 1 commit into
mainfrom
vcr-dbg-001-linemap-capture

Conversation

@avrabe

@avrabe avrabe commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

What — PR A of v0.12.0 (DWARF .debug_line)

Closes the encoder machine-offset gap that blocked DWARF line emission. compile_wasm_to_arm now captures a LineMap = Vec<(machine_offset, wasm_op_index)> during the encode loop and carries it on CompiledFunction.line_map.

The offset is code.len() taken immediately before each encode() — 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 .text is byte-identical with or without it. Proven by:

  • existing differential/golden fixtures staying green (output unchanged), and
  • 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): gimli as a production dep (auto-resolved 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 (flag-on vs flag-off: only .debug_line differs; .text/.data/.bss identical).

Verification

  • cargo test -p synth-backend --lib → 204 pass (incl. the new test); integration fixtures green
  • cargo clippy --all-targets -- -D warnings clean (added a LineMap type alias for the return tuple); cargo fmt --check clean
  • rivet check zero non-xref errors; roadmap VCR-DBG-001 step-5a progress recorded

Refs #242, #394.

🤖 Generated with Claude Code

…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>
@avrabe
avrabe merged commit b267d54 into main Jun 22, 2026
13 checks passed
@avrabe
avrabe deleted the vcr-dbg-001-linemap-capture branch June 22, 2026 19:34
@codecov

codecov Bot commented Jun 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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>
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