Skip to content

[FEA]: Debugger pretty-printers: cuda::annotated_ptr #10100#10232

Open
iakshayubale wants to merge 2 commits into
NVIDIA:mainfrom
iakshayubale:add-annotated-ptr-pretty-printers
Open

[FEA]: Debugger pretty-printers: cuda::annotated_ptr #10100#10232
iakshayubale wants to merge 2 commits into
NVIDIA:mainfrom
iakshayubale:add-annotated-ptr-pretty-printers

Conversation

@iakshayubale

@iakshayubale iakshayubale commented Jul 26, 2026

Copy link
Copy Markdown

Description

This PR adds comprehensive debugger pretty-printer support for cuda::annotated_ptr<_Tp, _Property> types to libcudacxx, enabling developers to inspect pointer values and access properties in both GDB and LLDB debuggers with enhanced readability.

Changes

GDB Pretty-Printer (libcudacxx/share/libcudacxx/gdb/annotated_ptr.py)

  • Type detector that identifies cuda::annotated_ptr types by examining template arguments
  • Printer class that extracts template arguments (_Tp and _Property)
  • Safe access to the __repr member containing the wrapped pointer value
  • Null pointer handling that displays "nullptr" instead of "0x0"
  • Exception-based error handling: gracefully falls back to type-only display on read failures
  • Output format: cuda::annotated_ptr<Type, Property> -> 0xaddress
  • ABI namespace stripping for clean type name display

LLDB Pretty-Printer (libcudacxx/share/libcudacxx/lldb/annotated_ptr.py)

  • Regex-based type detection requiring exactly 2 template arguments
  • Safe member access using LLDB SBValue API (GetChildMemberWithName, GetValueAsUnsigned)
  • Robust null pointer detection: distinguishes between real null pointers (value = 0) and read errors
  • Graceful degradation: falls back to type-only description when pointer value cannot be read
  • Exception handling for edge cases (missing fields, invalid pointers)
  • Identical output format to GDB for consistency across debuggers
  • Integration with LLDB's type summary system

Test Suite (libcudacxx/test/debugging/annotated_ptr/)

  • C++ test source with 3 inspection scenarios covering different access properties:
    • streaming_annotated_int with cuda::access_property::streaming
    • persisting_annotated_int with cuda::access_property::persisting
    • global_annotated_float with cuda::access_property::global
    • streaming_annotated_int with nullptr to validate null pointer handling
  • Const-correct test data: all test storage declared const to follow CCCL coding guidelines
  • Keep-for-debugger breakpoint hooks using inline assembly
  • CMake integration using standard libcudacxx_add_pretty_printer_test macro
  • Expected output validation files for both GDB and LLDB

Registrations

  • Updated libcudacxx/share/libcudacxx/gdb/__init__.py to import and register the new pretty-printer
  • Updated libcudacxx/share/libcudacxx/lldb/__init__.py to import and register the new formatter
  • Updated libcudacxx/test/debugging/CMakeLists.txt to include annotated_ptr tests in the test suite

Closes #10100

Checklist

  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@iakshayubale
iakshayubale requested review from a team as code owners July 26, 2026 19:58
@iakshayubale
iakshayubale requested a review from wmaxey July 26, 2026 19:58
@github-project-automation github-project-automation Bot moved this to Todo in CCCL Jul 26, 2026
@copy-pr-bot

copy-pr-bot Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@cccl-authenticator-app cccl-authenticator-app Bot moved this from Todo to In Review in CCCL Jul 26, 2026
@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: a2be55de-f33b-41ae-98d9-6d278c58d36e

📥 Commits

Reviewing files that changed from the base of the PR and between b3f7119 and 3f6d208.

📒 Files selected for processing (1)
  • libcudacxx/share/libcudacxx/gdb/annotated_ptr.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • libcudacxx/share/libcudacxx/gdb/annotated_ptr.py

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added debugger pretty-printer support for cuda::annotated_ptr in both GDB and LLDB.
    • Annotated pointers now show the annotated type plus access property, and render the wrapped pointer as an address or nullptr.
  • Tests

    • Added debugging coverage for annotated pointers, including streaming, persisting, global, and nullptr cases, with expected output verified for both GDB and LLDB.

Walkthrough

Added GDB and LLDB pretty-printers for cuda::annotated_ptr, registered them through existing debugger entry points, and added CUDA debugging tests covering streaming, persisting, global, and null pointer cases with expected output fixtures.

Changes

annotated_ptr debugging support

Layer / File(s) Summary
GDB annotated_ptr printer
libcudacxx/share/libcudacxx/gdb/...
Recognizes cuda::annotated_ptr, removes ABI namespaces from displayed types, formats pointer addresses or nullptr, and registers the printer.
LLDB annotated_ptr formatter
libcudacxx/share/libcudacxx/lldb/...
Recognizes annotated pointer types, reads the non-synthetic __repr value, formats summaries, and registers the callbacks.
Debugger test coverage
libcudacxx/test/debugging/...
Adds streaming, persisting, global, and null pointer test cases with GDB and LLDB expected output.

Assessment against linked issues

Objective Addressed Explanation
Implement GDB and LLDB pretty-printers under the specified libcudacxx/share/libcudacxx/<debugger>/annotated_ptr.py paths [#10100]
Add exhaustive debugging tests under libcudacxx/test/debugging/annotated_ptr [#10100]

Possibly related PRs

  • NVIDIA/cccl#10229: Updates the same GDB and LLDB registration tuples for another pretty-printer module.

Suggested reviewers: wmaxey


Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
libcudacxx/test/debugging/annotated_ptr/source.cu (2)

42-44: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

suggestion: Resolve the constness of the test storage. These locals are never assigned after initialization; if the cuda::annotated_ptr<int/float> constructors accept const pointees, declare them const. Otherwise, document why mutable storage is required rather than silently violating the repository rule.

As per coding guidelines, all variables that are not modified must be declared const.

Source: Coding guidelines


41-56: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

suggestion: Add a null-pointer case to this debugger test matrix. Both printers have a dedicated nullptr path, but the current source only constructs non-null pointers, so regressions there will not be caught. Add the corresponding case in libcudacxx/test/debugging/annotated_ptr/CMakeLists.txt and both expected fixtures.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 16d578af-bd9e-450c-bb12-40cc5a546ad6

📥 Commits

Reviewing files that changed from the base of the PR and between 45b8bb9 and 4c689b3.

📒 Files selected for processing (9)
  • libcudacxx/share/libcudacxx/gdb/__init__.py
  • libcudacxx/share/libcudacxx/gdb/annotated_ptr.py
  • libcudacxx/share/libcudacxx/lldb/__init__.py
  • libcudacxx/share/libcudacxx/lldb/annotated_ptr.py
  • libcudacxx/test/debugging/CMakeLists.txt
  • libcudacxx/test/debugging/annotated_ptr/CMakeLists.txt
  • libcudacxx/test/debugging/annotated_ptr/gdb.expected
  • libcudacxx/test/debugging/annotated_ptr/lldb.expected
  • libcudacxx/test/debugging/annotated_ptr/source.cu

Comment thread libcudacxx/share/libcudacxx/lldb/annotated_ptr.py
@iakshayubale iakshayubale changed the title feat: Add debugger pretty-printers for cuda::annotated_ptr #10100 [FEA]: Debugger pretty-printers: cuda::annotated_ptr #10100 Jul 26, 2026
@iakshayubale
iakshayubale marked this pull request as draft July 26, 2026 20:11
@cccl-authenticator-app cccl-authenticator-app Bot moved this from In Review to In Progress in CCCL Jul 26, 2026
@iakshayubale iakshayubale changed the title [FEA]: Debugger pretty-printers: cuda::annotated_ptr #10100 [FEA]: Debugger pretty-printers: cuda::annotated_ptr Jul 26, 2026
@iakshayubale iakshayubale changed the title [FEA]: Debugger pretty-printers: cuda::annotated_ptr [FEA]: Debugger pretty-printers: cuda::annotated_ptr #10100 Jul 26, 2026
@iakshayubale
iakshayubale force-pushed the add-annotated-ptr-pretty-printers branch from 4c689b3 to 4e126e5 Compare July 26, 2026 20:24
> Add GDB pretty-printer for cuda::annotated_ptr<_Tp, _Property>
  * Detects annotated_ptr types with 2 template arguments
  * Extracts pointee type and access property information
  * Displays dereferenced pointer value
  * Formats output as: cuda::annotated_ptr<PointeeType, PropertyType> -> 0xaddress

> Add LLDB pretty-printer with equivalent functionality
  * Uses LLDB SBValue API for safe member and pointer access
  * Regex pattern matching for robust type detection
  * Handles edge cases (nullptr, invalid pointers)

> Add comprehensive test suite
  * Test source with three access property scenarios (streaming, persisting, global)
  * Two inspection points for each property type
  * Expected output validation files for both GDB and LLDB
  * CMake integration with test discovery and execution

Fixes NVIDIA#10100
@iakshayubale
iakshayubale force-pushed the add-annotated-ptr-pretty-printers branch from 4e126e5 to b3f7119 Compare July 26, 2026 20:37
@iakshayubale
iakshayubale marked this pull request as ready for review July 26, 2026 20:37
@cccl-authenticator-app cccl-authenticator-app Bot moved this from In Progress to In Review in CCCL Jul 26, 2026
@iakshayubale

Copy link
Copy Markdown
Author

pre-commit.ci autofix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

[FEA]: Debugger pretty-printers: cuda::annotated_ptr

1 participant