Skip to content

Handle cross-file debug locations - #234

Merged
nihalpasham merged 2 commits into
mainfrom
debug-info-cross-file-spans
Jun 16, 2026
Merged

nihalpasham merged 2 commits into
mainfrom
debug-info-cross-file-spans

Conversation

@nihalpasham

@nihalpasham nihalpasham commented Jun 16, 2026 •

Copy link
Copy Markdown
Collaborator

Follow-up to #233. That PR landed the basic line-table/full-debug path; this fixes the remaining cross-file span case properly and documents the new debug-info modes in the book.

What changes

Before, an instruction inside one function only got a debug location if its source span came from the same file as the function scope. That avoided wrong metadata, but dropped useful spans from helpers/macros/inlined code.

This PR keeps those spans by creating a file-specific debug scope first:

kernel.rs function scope
  |
  +-- thread.rs file scope
        |
        +-- line 292, column 19

In LLVM metadata terms, that is:

!thread_scope = !DILexicalBlockFile(scope: !kernel_scope, file: !thread_file, discriminator: 0)
!loc = !DILocation(line: 292, column: 19, scope: !thread_scope)

For explicit Pliron callsite locations, the exporter also emits the call chain:

!call = !DILocation(line: 39, column: 13, scope: !kernel_scope)
!loc = !DILocation(line: 292, column: 19, scope: !thread_scope, inlinedAt: !call)

So cuda-gdb can see: we are at thread.rs:292, reached from kernel.rs:39.

Book docs

Adds user-facing docs for:

  • CUDA_OXIDE_DEBUG=line-tables
  • CUDA_OXIDE_DEBUG=full
  • what source debugging supports today
  • what basic local/argument inspection supports today
  • the simple compiler flow: rustc Span -> Pliron Location -> LLVM !dbg -> PTX/DWARF

Also updates the supported-features matrix so source debugging is marked full, while local/argument inspection is marked partial.

Tests

  • cargo fmt --all -- --check
  • cargo test -p llvm-export
  • cargo check --workspace
  • attempted make -C cuda-oxide-book html, but this local environment does not have sphinx-build installed

Tracker: #226

@nihalpasham nihalpasham added debug info Debug information in generated PTX/IR (line/source maps) codegen Device code-generation pipeline (Rust MIR to IR to PTX) llvm-export Textual LLVM/NVVM IR exporter (llvm-export crate) tests Adds or improves test coverage labels Jun 16, 2026
@nihalpasham
nihalpasham merged commit 3de7133 into main Jun 16, 2026
24 checks passed
@nihalpasham
nihalpasham deleted the debug-info-cross-file-spans branch June 19, 2026 11:30
meefs pushed a commit to meefs/cuda-oxide that referenced this pull request Sep 30, 2026
…ition is the fix (NVIDIA#234)

Signed-off-by: Melih Elibol <elibol@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codegen Device code-generation pipeline (Rust MIR to IR to PTX) debug info Debug information in generated PTX/IR (line/source maps) llvm-export Textual LLVM/NVVM IR exporter (llvm-export crate) tests Adds or improves test coverage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant