Skip to content

Conversation

@djolertrk
Copy link
Contributor

@djolertrk djolertrk commented Dec 9, 2025

This adds sveral features/fixes for improved debugging:

  1. Synthetic source locations: Compiler-generated code (like local
    initialization, ABI transforms) now uses SourceSpan::SYNTHETIC instead
    of UNKNOWN. This differentiates compiler-generated code from truly
    unknown locations and renders as #loc(synthetic) in output.

  2. -Z print-masm-source-locations: New flag to print source locations
    as #loc("file":line:col) annotations in MASM output.

  3. -Z remap-path-prefix=FROM=TO: Remap source path prefixes for resolving
    paths from DWARF when sources are in different locations (e.g., stdlib).

  4. Use current_span to have more real source locations attached --
    currently we used Default locations a lot - for example, each
    operator would start with it.

  5. Fix wasm component-level DWARF parsing

Requires miden-vm with SourceSpan::SYNTHETIC debug type.

To check locations on masm level, use:

$ ./bin/midenc examples/assert-debug-test/target/wasm32-unknown-unknown/release/assert_debug_test.wasm \
    --entrypoint=assert_debug_test::test_assert \
    -Ztrim-path-prefix=examples/assert-debug-test \
    -Zprint-masm-source-locations \
    --debug full --emit=masm=-

This adds sveral features/fixes for improved debugging:

1. Synthetic source locations: Compiler-generated code (like local
   initialization, ABI transforms) now uses SourceSpan::SYNTHETIC instead
   of UNKNOWN. This differentiates compiler-generated code from truly
   unknown locations and renders as #loc(synthetic) in output.

2. -Z print-masm-source-locations: New flag to print source locations
   as #loc("file":line:col) annotations in MASM output.

3. -Z remap-path-prefix=FROM=TO: Remap source path prefixes for resolving
   paths from DWARF when sources are in different locations (e.g., stdlib).

4. Use current_span to have more real source locations attached --
   currently we used Default locations a lot - for example, each
   operator would start with it.

5. Fix wasm component-level DWARF parsing

Requires miden-vm with SourceSpan::SYNTHETIC debug type.
@djolertrk djolertrk marked this pull request as draft December 9, 2025 18:50
@djolertrk
Copy link
Contributor Author

cc @greenhat @bitwalker

@djolertrk
Copy link
Contributor Author

This one depends on 0xMiden/miden-vm#2443 (the miden-vm implementation for the debug type) and goes on top of #810 -- where it improves a lot the situation with source locations because of this https://github.com/walnuthq/compiler/blob/pr/synthetic-source-locations-clean/frontend/wasm/src/module/func_translator.rs#L247, and with that we do have source locations attached to ub.unreachable, but the when an assert is triggered, miden-debug still prints in the stack trace.

@djolertrk djolertrk changed the title Add synthetic source locations clean Add synthetic source locations Dec 9, 2025
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