Skip to content

cuTile: breakpoint on an inlined helper call slides to the next statement #1476

Closed as not planned
NVIDIA/cuda-gdb
#29

Description

@elibol

A breakpoint on a user-helper call still moves to the following statement after updating to a cuTile revision containing the earlier source-location fix. It previously moved from line 132 to 135; it now stops at 133.

// cutile-examples/examples/debug_kernels.rs
// Inside checked_scale:
validate_scale_factor(factor);                  // 132
let tile_x = load_tile_like(x, out);             // 133
let tile_factor = factor.broadcast(out.shape()); // 134
out.store(tile_x * tile_factor);                // 135

Reported cuda-gdb session:

(cuda-gdb) b 132
No compiled code for line 132 in the current file.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (132) pending.
(cuda-gdb) r
...
CUDA thread hit Breakpoint 1, checked_scale@debug_kernels:127:7<<<(4,1,1),(128,1,1)>>> () at cutile-examples/examples/debug_kernels.rs:133
133             let tile_x = load_tile_like(x, out);

Expected behavior

A breakpoint on the validation call should stop before the validation executes and retain the helper source locations and complete inline backtrace. Breaking inside the helper is a temporary workaround, not the resolution of this issue.

Initial investigation

Debugging work

  • Reproduce with a minimal validation-helper kernel and record compiler/toolkit/debugger versions.
  • Inspect Tile IR/bytecode and cubin DWARF: confirm the validation instructions retain helper locations and the caller is line 132; inspect whether the line table contains executable addresses for 132.
  • Compare a breakpoint on the caller line with a breakpoint on an executable line inside the helper, and inspect the backtrace.
  • Determine whether the remaining gap is frontend metadata, tileiras lowering, or cuda-gdb breakpoint resolution.

The exact commit and complete debug_kernels.rs used by Dmitry were not included in the report. The local reduced reproduction and results are recorded below separately from the reported transcript.

Local reproduction confirmed (2026-10-10)

Reproduced against NVIDIA/cuda-rust commit bafffe45662a5cdc064a1c6674c6c02d466a58e0, which includes the imported #311 fix. Environment: Rust 1.98.0; NVIDIA RTX PRO 2000 Blackwell Generation Laptop GPU (sm_120); driver 610.43.02; tileiras 13.3 V13.3.36; cuda-gdb 13.3 based on GDB 16.3. Explicit DebugInfoLevel::Full.

The reduced kernel has the same four statements at lines 132–135, with validate_scale_factor calling assert_in_range. Passing factor 3.0 keeps the assertions from firing, isolating breakpoint placement from the assertion trap.

  1. Caller-line breakpoint reproduces the report exactly:

    CUDA thread hit Breakpoint 1, checked_scale@main:127:7 ... at src/main.rs:133
    133        let tile_x = load_tile_like(x, out);
    #0  checked_scale@main:127:7 ... at src/main.rs:133
    #1  checked_scale_entry ... at src/main.rs:10
    Line 132 of "src/main.rs" is at address ... but contains no code.
    
  2. A breakpoint inside the helper works and preserves the original caller line:

    CUDA thread hit Breakpoint 1, assert_in_range@main:17:7 () at src/main.rs:18
    18         cuda_tile_assert!(value >= lo, "factor below range");
    #0  assert_in_range@main:17:7 () at src/main.rs:18
    #1  validate_scale_factor@main:13:7 () at src/main.rs:14
    #2  checked_scale@main:127:7 ... at src/main.rs:132
    #3  checked_scale_entry ... at src/main.rs:10
    

    info frame confirms that the helper is inlined. Continuing after disabling the breakpoint completes normally.

  3. The source call location survives the compiler and assembler. The bytecode contains DILoc(..., "src/main.rs":132:8) in the helper's caller chain. The compiled cubin contains a DW_TAG_inlined_subroutine for validate_scale_factor with DW_AT_call_line: 132. Its decoded machine-code line table contains helper-body lines 14, 18, and 19 and the subsequent caller line 133, but no row for line 132.

Diagnosis

The reduced reproduction matches GDB's documented inline-call breakpoint limitation: line 132 exists as inline call-site metadata, not as a separately executable source-line row. The earlier fix makes line 133 available as the next breakpoint location. The caller-line slide does not demonstrate lost helper debug information, and the generated-constant-span fix is not a direct remedy.

For this kernel, set a source breakpoint on an assertion line inside the helper; this was verified to stop with the complete inline backtrace. Use a file-qualified breakpoint to identify the intended source file. The initial pending-breakpoint message occurs for both successful and sliding breakpoints before the JIT kernel loads.

Proper fix: resolve inline call-site breakpoints

There is a concrete debugger-side fix path; the absence of a separate call instruction does not mean that the call cannot be made breakable. Before falling forward to the next source line, cuda-gdb can use the inline instance whose call-site file/line matches the requested breakpoint and resolve its executable entry address. Keep the helper instructions attributed to their own source lines.

Source audit of public NVIDIA/cuda-gdb revision 7690d76395b374432c6750928b0f9db7a88d57e7:

  • decode_digits_ordinary obtains PCs from find_pcs_for_symtab_line, which searches source-line rows.
  • The caller falls forward to best_entry->line when the requested line has no match. It does not consult inline call-site symbols here.
  • The DWARF reader already imports DW_AT_call_line and DW_AT_call_file into inline function symbols. The relevant metadata is available to the debugger.

Entry-address experiment: resolving the reduced kernel's inline range, including CUDA relocation addends, gives checked_scale_entry + 0x270. Setting a breakpoint directly at that address stops at the first validation comparison (FSETP.GE.AND), with the same complete stack shown above: assert_in_range:18 → validate_scale_factor:14 → checked_scale:132 → checked_scale_entry:10. The kernel completes normally after continuing. This verifies a usable entry address for this reproduction; it is not an implemented fix to ordinary b 132 resolution.

  • Implement inline call-site lookup before the next-line fallback in the debugger, with correct source-file matching and loaded-object address relocation.
  • Add regressions for nested and cross-file helpers, multiple instances of a call site, and ordinary source-line breakpoints; verify pending breakpoints before JIT module load with the live cuTile reproduction. Define how to select the executable entry for noncontiguous inline ranges and how to handle eliminated calls.
  • Verify b 132 itself stops before validation, preserving the complete helper stack. Retain the existing assertion SIGTRAP/coredump validation separately under [BUG]: cuTile: at a cuda_tile_assert! trap, cuda-gdb reports the module's first line and drops the inlined helper frames #1379.

Check placement is a separate audit. Full device-debug mode already disables in-kernel check hoisting to loop preheaders. The two existing device_debug_ placement regressions passed on the reproduction revision; they cover placement counts, not location provenance. Wrapper generation, generated assumes, and source origins through injected-check optimization are tracked in #1475.

Reduced runnable kernel (blank line padding and artifact dumping omitted)

Use a standalone Cargo package depending on this repository's cutile-rs/cutile crate by path. Build with the repository's pinned Rust 1.98.0 toolchain. Break on the line containing validate_scale_factor(factor);, then compare with the first cuda_tile_assert! line.

use cutile::prelude::*;
use cutile::tile_kernel::{CompileOptions, DebugInfoLevel};

#[cutile::module]
pub mod kernels {
    use cutile::core::*;

    fn validate_scale_factor(factor: f32) {
        assert_in_range(factor, 0.0f32, 1000.0f32);
    }

    fn assert_in_range(value: f32, lo: f32, hi: f32) {
        cuda_tile_assert!(value >= lo, "factor below range");
        cuda_tile_assert!(value <= hi, "factor above range");
    }

    #[cutile::entry()]
    fn checked_scale<const S: [i32; 1]>(
        out: &mut Tensor<f32, S>,
        x: &Tensor<f32, { [-1] }>,
        factor: f32,
    ) {
        validate_scale_factor(factor);
        let tile_x = load_tile_like(x, out);
        let tile_factor = factor.broadcast(out.shape());
        out.store(tile_x * tile_factor);
    }
}

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let device = Device::new(0)?;
    let stream = device.new_stream()?;
    let x: Arc<Tensor<f32>> = api::arange(512).sync_on(&stream)?.into();
    let out = api::zeros::<f32>(&[512])
        .sync_on(&stream)?
        .partition([128]);

    kernels::checked_scale(out, x, 3.0f32)
        .compile_options(CompileOptions::new().debug_info(DebugInfoLevel::Full))
        .sync_on(&stream)?;
    Ok(())
}

Fix submitted: NVIDIA/cuda-gdb#29. The built debugger resolves the exact pending command break 132 when the JIT module loads and stops at the first validation comparison, with assert_in_range:18 -> validate_scale_factor:14 -> checked_scale:132 -> checked_scale_entry:10 intact. Released CUDA-GDB 13.3 and 13.4 both reproduce the slide to line 133. The PR includes synthetic-DWARF regressions and documents the remaining limitations. This issue remains open pending the debugger fix.

Activity

  1. elibol commented on Oct 26, 2026

    @elibol
    CollaboratorAuthor

    Per Melih's v0.5.0 scope decision, this issue is deferred beyond v0.5.0. The proposed fix is NVIDIA/cuda-gdb#29, a change to NVIDIA's debugger that is still open and is not part of a public CUDA Toolkit release. Removed the v0.5.0 milestone; this is not a release blocker. Keep the issue open and revisit it when the debugger fix is publicly available. Release tracker #1606 and integration PR #1613 have been updated accordingly.

  2. elibol commented on Nov 9, 2026

    @elibol
    CollaboratorAuthor

    Closing this issue; the proposed debugger fix is tracked in NVIDIA/cuda-gdb#29. The bug remains unresolved pending that fix.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions