Skip to content

feat(dwarf): internal functions get their real names from the wasm name section (#394) - #565

Merged
avrabe merged 1 commit into
mainfrom
feat/394-dwarf-internal-names
Jul 2, 2026
Merged

feat(dwarf): internal functions get their real names from the wasm name section (#394)#565
avrabe merged 1 commit into
mainfrom
feat/394-dwarf-internal-names

Conversation

@avrabe

@avrabe avrabe commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

What

Tier-1.x follow-up to #557 (#394): DW_TAG_subprogram DW_AT_name for internal (non-exported) functions was the synthetic func_N, because the wasm name custom section (function-names subsection) was never parsed. A backtrace through a panic helper showed func_7 instead of the real developer-facing name.

Before → after (msgq_put_359.wasm, --relocatable --debug-line, subprogram DW_AT_names):

func idx before after
6 (exported) z_impl_k_msgq_put z_impl_k_msgq_put
7 (internal) func_7 core::panicking::panic_const::panic_const_add_overflow::hacec966df230a78f
8 (internal) func_8 gale::msgq::put_decide::h36409b4bbfd25a9a
9 (exported) gale_k_msgq_put_decide gale_k_msgq_put_decide
10 (internal) func_10 core::panicking::panic_fmt::h6651313c3e2c6c2f

How

  • wasm_decoder.rs: parse the name custom section (KnownCustom::NameName::Function map) into a new FunctionOps.debug_name, applied after the parse loop (the custom section trails the code section). Best-effort by design — debug metadata must never fail a compile. Both decode_wasm_module and decode_wasm_functions.
  • synth-cli/main.rs: thread debug_name through ElfFunction into the subprogram compose. Name priority: name-section > export name > func_N. DWARF-only — the symbol table and relocation labels keep using the export-name-or-func_N name, so linkability is untouched.
  • dwarf_line.rs: doc-only (the priority contract on SubprogramInfo.name).

Oracle (RED → GREEN)

New Oracle G in dwarf_debug_line_emit_394.rs (emitted_subprogram_names_use_name_section_for_internal_functions_394): ground truth (name section + export section) parsed from the fixture at runtime with wasmparser directly (non-circular). Asserts (a) ≥1 compiled internal function's DIE carries its real name-section name, and (b) zero synthetic func_N names remain (the fixture names every function). RED before — the pre-change binary emits func_7/func_8/func_10 and none of the internal real names appear anywhere in the object; GREEN after.

Gates (exit-code-verified)

  • DWARF oracles A–G: 8/8 pass
  • frozen_codegen_bytes: 3/3.text byte-identical (purely additive DWARF metadata; .symtab unchanged)
  • cargo test --workspace --exclude synth-verify: 90 suites, 1677 passed, 0 failed (exit 0)
  • cargo fmt --check: exit 0
  • cargo clippy --workspace --all-targets -- -D warnings: exit 0 (full workspace incl. synth-verify)

🤖 Generated with Claude Code

…me section (#394)

Tier-1.x follow-up to #557: DW_TAG_subprogram DW_AT_name for INTERNAL
(non-exported) functions was the synthetic func_N because the wasm
`name` custom section (function-names subsection) was never parsed.
A backtrace through a panic showed `func_7` instead of
`core::panicking::panic_const::panic_const_add_overflow::h...`.

- wasm_decoder: parse the `name` custom section (KnownCustom::Name →
  Name::Function map, best-effort — debug metadata must not fail a
  compile) into a new `FunctionOps.debug_name`, applied after the parse
  loop (the section trails the code section). Both decode_wasm_module
  and decode_wasm_functions.
- CLI: thread `debug_name` through ElfFunction into the subprogram
  compose. Name priority: name-section > export name > func_N.
  DWARF-only — the symbol table and relocation labels keep using the
  export-name-or-func_N `name`, so linkability and emitted bytes are
  unchanged.
- Oracle G (dwarf_debug_line_emit_394): ground truth parsed from the
  fixture at runtime; asserts ≥1 internal function's DIE carries its
  real name-section name and zero synthetic func_N names remain
  (msgq_put_359 names every function). RED before (func_7/8/10),
  GREEN after.

Frozen-safe: purely additive DWARF metadata — frozen_codegen_bytes 3/3,
.text byte-identical.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@avrabe
avrabe merged commit 38a5386 into main Jul 2, 2026
43 of 44 checks passed
@avrabe
avrabe deleted the feat/394-dwarf-internal-names branch July 2, 2026 04:29
avrabe added a commit that referenced this pull request Jul 2, 2026
…tooling (#567)

Early cut per the release-early directive: #565 (internal functions get
their real wasm name-section names in DW_TAG_subprogram — gdb backtraces
show core::panicking::… instead of func_7) is merged downstream-facing
value; ship it now rather than batch it behind the allocator spike.
VCR-RA-001 re-scoped to v0.22.0 (rivet release status v0.21.0: no blocking
artifacts). Pin sweep 0.20.0 -> 0.21.0 + MODULE.bazel + lock; CHANGELOG.

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