Repository navigation
Reliable cuda-gdb local/argument inspection: full-debug as a -G build + rich DWARF types - #241
Merged
Merged
Conversation
Baseline of the pairing-session work continued from debug-info-cross-file-spans: - full-debug mode now always runs pliron mem2reg - MirStoreOp/MirLoadOp PromotableOpInterface salvage promoted slots into mir.dbg_value (new dialect-mir op) -> llvm.dbg.value - rustc source-scope sidecar threaded through so inlined helpers get the callee DISubprogram + inlinedAt; cross-file lexical blocks - cargo oxide debug gains --arch / GPU auto-detect
dbg.value-based debug info is fundamentally lossy: a value is only inspectable while its register is live, which is far narrower than the variable's scope. GPU-verified that even at -O0 a plain scalar kernel arg shows <optimized out> under the promote+dbg.value path. Full-debug now follows the nvcc -G model so cuda-gdb can read every local from a stable memory location for its whole scope: - skip pliron mem2reg (keep source locals in their stack slots) - skip opt -O2 (slot promotion would collapse live ranges) - run llc at -O0 (its own mem2reg/SROA would do the same) - locals/args described by llvm.dbg.declare The promotion-aware mir.dbg_value salvage stays in place as the mechanism for a future optimized-debug tier; it is just not what full-debug uses. GPU-verified on RTX 5090 (sm_120): info args -> val=0, info locals -> out_elem shown, correct cross-file inlined backtrace.
Audit follow-ups (all principled, no behavior change on the happy path): - resolve_debug_source_scope / source_scope_depth: only follow strictly smaller parent ids, matching rustc's scope-tree invariant and guaranteeing termination on a malformed (cyclic) deserialized map instead of overflowing. - set_debug_source_scope_map: debug_assert scope ids are dense 0..len, so a future sparse/reordered producer fails loudly rather than silently mislabeling parent/scope links the reader reconstructs by index. - debug_value_for_promoted_slot: skip salvaging the synthesized undef default-def into dbg.value(undef) (keeps the optimized-tier salvage honest). - mir-lower: move test-only combine dependency to [dev-dependencies].
Aggregate locals/args were previously invisible (only scalars and pointers
had DILocalVariables). Now full-debug describes composites so cuda-gdb can
show their fields.
- DebugLocalTypeKind gains Struct (with DebugTypeMember) and Array variants;
the whole type tree is serialized into one length-prefixed, escape-safe
attr blob (replaces the 4 flat type attrs) so nested/odd type names
round-trip. Unit-tested incl. truncation rejection.
- ensure_debug_type recurses, emitting DICompositeType + DW_TAG_member
(struct/tuple) and DW_TAG_array_type + DISubrange (arrays).
- The importer builds members from rustc's real layout offsets (honoring
repr(Rust) field reordering), skipping zero-sized (PhantomData) and
not-yet-describable members. Enums/unions remain deferred.
GPU-verified on RTX 5090: info args shows
out = DisjointSlice {ptr: 0x..., len: 1}
info locals shows idx = ThreadIndex {raw: 0}; ptype prints field types.
Drives cuda-gdb in batch mode against a full-debug build and asserts that a source breakpoint binds, the device PTX JITs, the backtrace is correct, and info args/locals show real values (scalars, pointers, struct fields). This validates debugger *consumption* of the emitted DWARF, closing the audit gap where only IR emission was tested. Skips cleanly (exit 0) without a GPU.
Rewrite the debug-info sections to match the implementation: - full = -G-style (mem2reg/opt off, locals in memory via dbg.declare); this is why locals stay inspectable instead of going <optimized out>. - document rich-type support (structs/tuples/arrays show their fields) and the explicit not-yet list (enums, ABI-split bare slices, closures, projections). - clarify the mir.dbg_value salvage is groundwork for a future optimized tier, not what full uses today. - note end-to-end validation via scripts/debug-smoketest.sh.
…ection # Conflicts: # crates/llvm-export/src/lib.rs # crates/llvm-export/tests/export_test.rs # crates/mir-importer/src/pipeline.rs # crates/mir-importer/src/translator/body.rs # crates/mir-lower/src/convert/ops/memory.rs # crates/rustc-codegen-cuda/src/device_codegen.rs
meefs
pushed a commit
to meefs/cuda-oxide
that referenced
this pull request
Sep 30, 2026
* fix: version persisted tuning cache keys Persist the L2 key encoding alongside each tuning-record digest so key-preimage migrations are distinguishable from workspace drift. Keep legacy bare-string records wire-compatible and preserve strict verification whenever stored and current keys are comparable. Signed-off-by: Sam, Joochul Chang <[email protected]> * test: pin the l2 key preimage to L2_KEY_SCHEMA The schema bump was enforced by convention only; nothing failed when the preimage changed, which is exactly how NVIDIA#236 changed every key without a test noticing. This asserts one exact digest from fixed inputs, so any preimage change fails loudly with instructions: bump L2_KEY_SCHEMA, update the digest, extend the schema history. Signed-off-by: Melih Elibol <[email protected]> --------- Signed-off-by: Sam, Joochul Chang <[email protected]> Signed-off-by: Melih Elibol <[email protected]> Co-authored-by: Melih Elibol <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Makes
CUDA_OXIDE_DEBUG=full cargo oxide debug <example>give reliableinfo locals/info argsin cuda-gdb. GPU-verified on an RTX 5090(sm_120a, cuda-gdb 13.3):
Why full-debug is now a
-G/-O0builddbg.value-based debug info is inherently lossy: a promoted value only has amachine location while its register is live, which is narrower than the
variable's scope, so an in-scope local reads
<optimized out>even at-O0(confirmed on GPU). Every debug build solves this by keeping locals in memory:
gcc/clang
-O0 -g, nvcc-G.So
fullnow follows that model: skip Plironmem2reg, skipopt -O2, runllc -O0, describe locals withllvm.dbg.declare.line-tablesstays on theoptimized pipeline (line info survives optimization; locals do not).
The
PromotableOpInterface/mir.dbg_valuesalvage (a port of LLVM'sConvertDebugDeclareToDebugValue) is kept as groundwork for a futureoptimized-debug tier (
-O2 -g-style); it just isn't whatfulluses today.What's in here
full=-G/-O0tier (reliable in-memory locals)DICompositeTypewith reallayout offsets (honors
repr(Rust)reordering); recursive type modelserialized as one length-prefixed attr blob (unit-tested)
undef-salvage guard,
combinemoved to dev-dependenciesscripts/debug-smoketest.sh: GPU-gated cuda-gdb end-to-end test (breakpointbinds +
info args/info localsshow real values); skips cleanly w/o a GPU-Gmodel honestlyDeferred (documented)
enums (
Option/Result), ABI-split bare&[T]args, closures, projections(
x.0), and the optimized-debug tier itself.Validation
cargo test --workspacegreen (GPU present);cargo fmt/clippy/cargo docclean
scripts/debug-smoketest.shPASS on sm_120vecaddunchanged (gating only touchesfull)