Skip to content

Debug info: keep #[kernel] prologue instructions off the attribute line #1117

Closed

Description

@nihalpasham

Description

Breaking on a kernel by name can present the #[kernel] attribute as the first
executable source line. The exact visible stop is debugger/environment
dependent, but the underlying compiler defect remains on current main: emitted
PTX maps executable macro-injected entry work to the attribute line.

This is a related follow-up to the line-table work in #224/#225. It should not
be a native child of #226 because that tracker explicitly excludes line-table
source mapping.

Minimal reproducer

Compile a #[kernel] function with full device debug information, set a
cuda-gdb breakpoint on its source/export name, and inspect the first stop and
the entry .loc directives. The cuda-devtools T01 assessment is the current
integration reproducer.

Expected behavior

Synthetic entry/prologue work must not claim the attribute as an executable
user line. Rewritten thread-index expressions should retain their original
source spans, and the first user-visible stop should be a real body expression.

Actual behavior

On baseline 6c5458fe, the local cuda-gdb run happened to select the first body
statement rather than the attribute, but PTX still contains an attribute-line
.loc on the injected make_kernel_scope / thread-index prologue. The old T01
stop is therefore not reliably reproduced, but the bad line mapping is not
fixed.

The proc macro currently gives the synthetic scope binding an ordinary
call-site span chosen for diagnostics, and parse_quote! rebuilding of index
calls loses the original expression span.

Acceptance criteria

  • Kernel-name breakpoints never present #[kernel] as an executable user line.
  • LLVM/PTX regression coverage proves the entry prologue has no executable
    location for the attribute line.
  • Rewritten thread-index expressions retain their original source spans.
  • Tests cover doc comments and multiple attributes rather than relying on a
    fixed line offset.
  • Existing macro diagnostics remain useful.
  • Full-debug, line-table-only, and debug-off output remain valid.

Environment

  • Baseline: 6c5458fe991bbde32c5bee74d87822aef1b5a691
  • CUDA/cuda-gdb: 13.3
  • GPU: RTX 5090 (sm_120)

Activity

  1. added
    bugSomething isn't working
    debug infoDebug information in generated PTX/IR (line/source maps)
    codegenDevice code-generation pipeline (Rust MIR to IR to PTX)
    on Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcodegenDevice code-generation pipeline (Rust MIR to IR to PTX)debug infoDebug information in generated PTX/IR (line/source maps)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions