Skip to content

gdb/amd-dbgapi-target: add trap-on-entry support - #219

Open
sebdar wants to merge 1 commit into
amd-stagingfrom
users/sdarche/trap-on-entry-support
Open

gdb/amd-dbgapi-target: add trap-on-entry support#219
sebdar wants to merge 1 commit into
amd-stagingfrom
users/sdarche/trap-on-entry-support

Conversation

@sebdar

@sebdar sebdar commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Motivation

This commit introduces interface to the new 'trap-on-entry' feature. Users may now ask the debugger to halt any new wavefront executing on an AMD GPU using:

(gdb) set amdgpu trap-on-entry on

As soon as the inferior runs a compute workload, control is returned to the debugger:

  Thread 15 "kernel" received signal SIGTRAP, Trace/breakpoint trap.
  [Switching to thread 15, lane 0 (AMDGPU Lane 1:2:2:9/0 (0,0,0)[0,0,0])]
  kernel () at /home/sdarche/test-dbg/src/app/long_wave.cpp:12
  12	__global__ void kernel() {
  (gdb)

This feature can be similarly disabled using set amdgpu trap-on-entry off. It is disabled by default.

Tracking

JIRA ID : AIROCGDB-647

Test Plan

New testcases are provided in gdb.rocm/trap-on-entry.exp. These testcases exercise the feature and verify that it disables cleanly.

Test Result

Tests should pass with the new dbgapi. They are unsupported for version < 0.81.

Submission Checklist

@sebdar
sebdar requested a review from lancesix July 17, 2026 14:08
@sebdar
sebdar requested a review from a team as a code owner July 17, 2026 14:08
@sebdar

sebdar commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

Corresponding dbgapi PR : ROCm/rocm-systems#8762

Comment thread gdb/amd-dbgapi-target.c Outdated
Comment thread gdb/amd-dbgapi-target.c Outdated
Comment thread gdb/testsuite/gdb.rocm/trap-on-entry.exp Outdated
Comment thread gdb/testsuite/gdb.rocm/trap-on-entry.exp Outdated
Comment thread gdb/testsuite/gdb.rocm/trap-on-entry.exp
Comment thread gdb/testsuite/gdb.rocm/trap-on-entry.exp Outdated
Comment thread gdb/testsuite/gdb.rocm/trap-on-entry.exp Outdated
@lumachad

Copy link
Copy Markdown
Collaborator

@sebdar Is there a ticket tracking this work? If so, it would be nice to add it to the PR/commit.

@sebdar
sebdar force-pushed the users/sdarche/trap-on-entry-support branch from 30b0af2 to 3a8e4e5 Compare July 22, 2026 14:43
@sebdar

sebdar commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review @aktemur .

In the last push :

  • Addressed some of Baris' comments. Left a few unresolved for further discussion

@sebdar
sebdar force-pushed the users/sdarche/trap-on-entry-support branch from 3a8e4e5 to 2506a8c Compare July 22, 2026 14:48
@sebdar
sebdar requested a review from aktemur July 24, 2026 13:37
Comment thread gdb/testsuite/gdb.rocm/trap-on-entry.exp Outdated
Comment thread gdb/testsuite/gdb.rocm/trap-on-entry.exp Outdated
@sebdar
sebdar force-pushed the users/sdarche/trap-on-entry-support branch 2 times, most recently from d6849ff to ceee9db Compare July 27, 2026 19:05

@lancesix lancesix left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Documentation is missing.

Other bits and bobs comments below.

Comment thread gdb/testsuite/gdb.rocm/trap-on-entry.exp
# Not every architecture supports trap-on-entry. Request the feature before
# the process starts, then let the process attach apply it and report through
# "show" whether it actually became effective.
set trap_on_entry_supported false

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: I think I would make supports_trap_on_entry a function which can be called, rather than inlining it. But this is mostly a me thing.

Comment thread gdb/amd-dbgapi-target.c Outdated
Comment thread gdb/amd-dbgapi-target.c Outdated
static void
set_process_trap_on_entry (amd_dbgapi_inferior_info &info)
{
#if AMD_DBGAPI_VERSION_MAJOR > 0 || AMD_DBGAPI_VERSION_MINOR >= 81

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Ideally, we might want to have a configure test checking if AMD_DBGAPI_WAVE_LAUNCH_TRAP_ON_ENTRY_ENABLED is defined for example, and set a AMD_DBGAPI_SUPPORTS_TRAP_ON_ENTRY. This would remove some ordering issues, as we have quite a few dbgapi things in the pipeline comming, ordering might not guarantee that this feature will be 0.81.

@sebdar
sebdar force-pushed the users/sdarche/trap-on-entry-support branch from ceee9db to 539883b Compare August 3, 2026 20:50
@sebdar

sebdar commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

In the last push :

  • Added documentation
  • Reworked integration with dbgapi to check for the symbol at configure-time instead of checking for a dbgapi version.
  • Misc modifications:
    • copyright year in the testcase
    • forward state to cloned inferiors, just like precise-memory and alu-exceptions

@sebdar
sebdar requested a review from lancesix August 3, 2026 20:53

@lancesix lancesix left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

some minor comments, otherwise LGTM.

Comment thread gdb/doc/gdb.texinfo Outdated
Comment thread gdb/testsuite/gdb.rocm/trap-on-entry.cpp Outdated
@sebdar
sebdar force-pushed the users/sdarche/trap-on-entry-support branch from 539883b to 655de73 Compare August 4, 2026 13:36
@sebdar

sebdar commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

In the last push :

  • Used CHECK in the test case
  • Removed awkward sentence in doc.

@sebdar
sebdar requested a review from lancesix August 4, 2026 13:37
@sebdar
sebdar force-pushed the users/sdarche/trap-on-entry-support branch from 655de73 to eb00ed3 Compare August 10, 2026 18:44
This commit introduces interface to the new 'trap-on-entry' feature. Users may
now ask the debugger to halt any new wavefront executing on an AMD GPU using:

  (gdb) set amdgpu trap-on-entry on

As soon as the inferior runs a compute workload, control is returned to the
debugger:

  Thread 15 "kernel" received signal SIGTRAP, Trace/breakpoint trap.
  [Switching to thread 15, lane 0 (AMDGPU Lane 1:2:2:9/0 (0,0,0)[0,0,0])]
  kernel () at /home/sdarche/test-dbg/src/app/long_wave.cpp:12
  12	__global__ void kernel() {
  (gdb)

This feature can be similarly disabled using `set amdgpu trap-on-entry off`.
It is disabled by default.

New testcases are provided in gdb.rocm/trap-on-entry.exp. These testcases
exercise the feature and verify that it disables cleanly.
@sebdar
sebdar force-pushed the users/sdarche/trap-on-entry-support branch from eb00ed3 to 82392de Compare August 10, 2026 20:37
@lumachad

lumachad commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

New PR is ROCm/rocm-systems#9925. Pre-commit seems unhappy about whitespaces.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants