Skip to content

No debug information in the generated PTX #105

Closed

Description

@Barrow099

When building a CUDA kernel with cuda-oxide, the resulting PTX (and complete program does not contain any debugging information for the device code, thus making debugging with cuda-gdb pretty hard.

Activity

  1. Barrow099 commented on Jun 3, 2026

    @Barrow099
    Author

    My attempt to add this information is ongoing in #106.

  2. added
    enhancementNew feature or request
    debug infoDebug information in generated PTX/IR (line/source maps)
    on Jun 6, 2026
  3. fbrv commented on Jun 12, 2026

    @fbrv
    Contributor

    Hey - funny timing, I was poking at this on a private branch over the last couple weeks and landed somewhere a bit different on the first step. Wanted to compare notes before either of us pushes further.
    What I did as step 1: just LineTablesOnly, gated behind a debug_level flag on ExportBackendConfig that defaults to None. Reasoning is that it's what cuda-gdb line stepping and Nsight source-view actually consume - turns out you get ~all of the practical debugging value from just DIFile + DICompileUnit(emissionKind: LineTablesOnly) + DISubprogram + DILocation, no DISubroutineType, no types, no locals, way smaller surface for a first cut. The off-by-default config gate also means existing snapshot tests stay byte-identical, so it can land without coordinating with anyone else's work, and we get to iterate on the DI shape without flipping it on for every consumer.
    Two structural things fell out of doing it that way, curious whether you'd push back. First, I put the builder + current scope on ModuleExportState (state.debug: Option) rather than threading (scope_ref, registry) through export_function → export_block → export_op — mostly because as soon as we add locals in a later phase, I didn't want to touch every emit helper's signature again. Second, I changed export_op to return whether it emitted an instruction and the caller appends !dbg !N, so the per-helper writeln!s stay intact - avoids the "clone output and diff" thing, which yeah, you flagged yourself. If you want, happy to chat about this

  4. nihalpasham commented on Jun 15, 2026

    @nihalpasham
    Collaborator

    I opened #225 for the first useful piece of this: line-table debug metadata for device code.

    The PR does not try to do full local-variable/type debug info yet. It focuses on making source-line mapping work end to end: Rust span -> LLVM !dbg -> PTX .file / .loc -> cuda-gdb source breakpoints and backtraces.

    Quick manual smoke on vecadd is already working: cuda-gdb stops in device code and shows frames for both cuda-device/src/thread.rs and the user kernel in src/main.rs.

  5. nihalpasham commented on Jun 15, 2026

    @nihalpasham
    Collaborator

    Quick update: PR #225 should close the line-table/source-mapping part of this.

    It makes cuda-oxide emit real device debug metadata when debug is enabled:

    • LLVM !dbg, DICompileUnit, DISubprogram, DILocation
    • PTX .target ..., debug, .file, and .loc
    • cuda-gdb source breakpoints and basic device backtraces

    This does not try to solve full variable/type inspection yet, so things like info locals / print x are tracked separately in #226.

  6. added
    llvm-exportTextual LLVM/NVVM IR exporter (llvm-export crate)
    codegenDevice code-generation pipeline (Rust MIR to IR to PTX)
    on Jun 15, 2026
  7. fbrv commented on Jun 15, 2026

    @fbrv
    Contributor
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

    codegenDevice code-generation pipeline (Rust MIR to IR to PTX)debug infoDebug information in generated PTX/IR (line/source maps)enhancementNew feature or requestllvm-exportTextual LLVM/NVVM IR exporter (llvm-export crate)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions