Skip to content

Conversation

@jiel-nv
Copy link
Contributor

@jiel-nv jiel-nv commented Jan 28, 2026

Fixes nvbug5811432.

When stepping through code in cuda-gdb, the debugger would jump to unrelated lines (where variables were last assigned) before reaching the continue statement when the condition is TURE. For example, with this code snippet:

for i in range(5):
    if i == 3:        # line 280
        continue      # line 281
    ...
    x = x + i         # line 295

The debugger would step: 280 → 295 → 281, instead of the expected 280 → 281.

The root cause is during stripping off PHI nodes and creating exporters, a uniformed rhs.loc (the location where the RHS variable was last assigned) is used as the source location. Despite of the existing WITH and WITHOUT assignments cases already handing the place to insert the exporters, the location info are not well handled.

The fix is to conditionally set the loc for PHI exporter assignments:
If the variable is assigned in the current block: Use rhs.loc to preserve the assignment site's location.
If the variable is NOT assigned in the current block (pass-through in continue/break): Use term_loc (the block terminator's location, i.e., the continue/break statement's line number).

Also adds a test test_terminator_line_number into test_debuginfo.

@copy-pr-bot
Copy link

copy-pr-bot bot commented Jan 28, 2026

Auto-sync is disabled for ready for review pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 28, 2026

Greptile Overview

Greptile Summary

Fixes debugger stepping behavior in cuda-gdb by correctly setting location info for PHI node exporters. Previously, the debugger would jump to unrelated lines where variables were last assigned before reaching continue/break statements. The fix conditionally uses either the assignment site location (when variable is assigned in the block) or the terminator location (for pass-through variables in continue/break blocks). Includes comprehensive test coverage verifying the continue statement line numbers appear correctly in LLVM debug info.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The change is well-targeted and addresses a specific debugger stepping issue with a logical fix. The implementation correctly handles edge cases (undefined variables, unterminated blocks) and includes comprehensive test coverage that validates the fix works as intended.
  • No files require special attention

Important Files Changed

Filename Overview
numba_cuda/numba/cuda/core/typed_passes.py Conditionally sets location info for PHI exporter assignments based on whether variable was assigned in current block
numba_cuda/numba/cuda/tests/cudapy/test_debuginfo.py Adds test to verify continue statement line numbers appear correctly in debug info via LLVM IR inspection

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

2 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

2 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@jiel-nv
Copy link
Contributor Author

jiel-nv commented Jan 28, 2026

/ok to test 5e4aef0

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

2 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

2 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@jiel-nv
Copy link
Contributor Author

jiel-nv commented Jan 29, 2026

/ok to test 69f94c2

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

2 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@jiel-nv
Copy link
Contributor Author

jiel-nv commented Jan 29, 2026

/ok to test 2b13798

@jiel-nv jiel-nv added the 3 - Ready for Review Ready for review by team label Jan 29, 2026
@jiel-nv jiel-nv requested review from cpcloud and gmarkall January 29, 2026 20:00
@jiel-nv
Copy link
Contributor Author

jiel-nv commented Feb 3, 2026

Gentle ping @gmarkall @cpcloud

@cpcloud cpcloud enabled auto-merge (squash) February 3, 2026 17:40
@cpcloud cpcloud merged commit 197f56f into NVIDIA:main Feb 3, 2026
204 of 208 checks passed
@cpcloud
Copy link
Contributor

cpcloud commented Feb 3, 2026

Thanks @jiel-nv!

gmarkall added a commit to gmarkall/numba-cuda that referenced this pull request Feb 5, 2026
- Add CUDA FP8 type + conversion bindings (E5M2/E4M3/E8M0), HW-accel detection, and comprehensive tests (NVIDIA#686)
- fix: fix boolean return type mismatch in C ABI wrapper (NVIDIA#770)
- Remove unused `rtapi.py`  (NVIDIA#773)
- feat: Add documentation for debugging Numba CUDA programs with CUDA GDB and VSCode (NVIDIA#665)
- Move `CallConv` from `CUDAContext` to `FunctionDescriptor` (NVIDIA#717)
- Generate line info for PHI exporters in terminator block (NVIDIA#756)
- Add `cuda-core` to `oldest` tests (NVIDIA#769)
- build(deps): bump actions/setup-python from 6.1.0 to 6.2.0 in the actions-monthly group across 1 directory (NVIDIA#768)
- Enable apt proxy caching; skip hosted Windows builds (NVIDIA#766)
- Disable automatic review trigger for Greptile (NVIDIA#743)
- test(refactor): clean up `run_in_subprocess` (NVIDIA#762)
- remove super args (NVIDIA#763)
@gmarkall gmarkall mentioned this pull request Feb 5, 2026
kkraus14 pushed a commit that referenced this pull request Feb 5, 2026
- Add CUDA FP8 type + conversion bindings (E5M2/E4M3/E8M0), HW-accel
detection, and comprehensive tests (#686)
- fix: fix boolean return type mismatch in C ABI wrapper (#770)
- Remove unused `rtapi.py`  (#773)
- feat: Add documentation for debugging Numba CUDA programs with CUDA
GDB and VSCode (#665)
- Move `CallConv` from `CUDAContext` to `FunctionDescriptor` (#717)
- Generate line info for PHI exporters in terminator block (#756)
- Add `cuda-core` to `oldest` tests (#769)
- build(deps): bump actions/setup-python from 6.1.0 to 6.2.0 in the
actions-monthly group across 1 directory (#768)
- Enable apt proxy caching; skip hosted Windows builds (#766)
- Disable automatic review trigger for Greptile (#743)
- test(refactor): clean up `run_in_subprocess` (#762)
- remove super args (#763)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3 - Ready for Review Ready for review by team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants