gdb: Implement stop-on-solib-events for GPU code objects - #235
gdb: Implement stop-on-solib-events for GPU code objects#235amd-bfilipov wants to merge 1 commit into
Conversation
f665745 to
335c12d
Compare
|
Does this need a review? If so, we need to flip it to review. |
Wanted to check some things first, it's ready for review now. |
czidev-amd
left a comment
There was a problem hiding this comment.
IMHO, you need to check bs->print_it assign. Any other comment is non blocking.
| bs->stop = stop_on_solib_events != 0; | ||
| bs->print = stop_on_solib_events != 0; | ||
| /* Set print_it to normal so that print_it() method is called. */ | ||
| bs->print_it = print_it_normal; |
There was a problem hiding this comment.
"Set print_it to normal so that print_it() method is called." explains the mechanism rather than the intent. A clearer wording would be "Allow print_it() to print the GPU code object event message."
There was a problem hiding this comment.
Fixed. Changed comment to: "Allow print_it () to print the GPU code object event message."
| for {set i 0} {$i < 20} {incr i} { | ||
| set test "continue and check for GPU code object event" | ||
| gdb_test_multiple "continue" $test { | ||
| -re "Stopped due to GPU code object event.*Inferior loaded.*\r\n$::gdb_prompt $" { |
There was a problem hiding this comment.
The test name is a fixed string reused for all 20 iterations of the loop. DejaGnu records each pass and fail by name, so duplicates make the log ambiguous and can hide regressions. Appending $i to the name would fix this, e.g. "continue and check for GPU code object event (iter $i)".
There was a problem hiding this comment.
Fixed. Changed test names to be unique per iteration AND per result type using $gdb_test_name
| } | ||
| -re ".*\r\n$::gdb_prompt $" { | ||
| # Some other stop reason, keep going. | ||
| pass $test |
There was a problem hiding this comment.
The catch-all pattern calls pass for any unrecognised output, including unexpected errors or unknown stop reasons. That means a broken stop reason would be silently recorded as a pass. Consider using fail here instead, or at least adding a timeout arm.
There was a problem hiding this comment.
Fixed. Removed the catch-all pattern entirely and added explicit timeout arm that fails
335c12d to
9dd1ab3
Compare
GDB's "set stop-on-solib-events 1" setting was not working for GPU code objects loaded by the AMD ROCm runtime. While CPU shared library events correctly triggered stops when this setting was enabled, GPU code object load events were silently ignored. The root cause was in amd_dbgapi_target_breakpoint::check_status(), which unconditionally set bs->stop = 0 and bs->print_it = print_it_noop, regardless of the stop_on_solib_events setting. This is in contrast to internal_breakpoint::check_status() for CPU shared libraries, which respects the setting by checking the stop_on_solib_events global variable. The fix adds: 1. A code_object_list_updated flag to amd_dbgapi_inferior_info to track when AMD_DBGAPI_EVENT_KIND_CODE_OBJECT_LIST_UPDATED events are seen during process_event_queue(). 2. Logic in check_status() to check this flag after processing events, and update bs->stop, bs->print, and bs->print_it based on stop_on_solib_events. 3. A print_it() override to display "Stopped due to GPU code object event" to distinguish GPU events from CPU shared library events. This makes GPU code object load events behave consistently with CPU shared library events, allowing users to stop execution when GPU code objects are loaded for inspection and breakpoint placement. A test is included in gdb.rocm/solib-event.exp.
9dd1ab3 to
79095ea
Compare
|
@amd-bfilipov When force-pushing, please make a comment clarifying what it is that you changed. Or go through the review comments and clarify for each of those what you've done. |
@lumachad Understood. Replied to comments. |
GDB's set stop-on-solib-events 1 setting allows users to stop execution when shared libraries are loaded or
unloaded, enabling inspection and breakpoint placement before library code executes. This feature works for CPU
shared libraries but was not working for GPU code objects loaded by the AMD ROCm runtime.
This PR implements stop-on-solib-events support for GPU code objects, making GPU code object load/unload events
behave consistently with CPU shared library events.
Related: AIROCGDB-589
Root Cause
The amd_dbgapi_target_breakpoint::check_status() function unconditionally set bs->stop = 0 and bs->print_it =
print_it_noop, regardless of the stop_on_solib_events setting. This is in contrast to
internal_breakpoint::check_status() for CPU shared libraries, which respects the setting.
Changes
Implementation:
AMD_DBGAPI_EVENT_KIND_CODE_OBJECT_LIST_UPDATED events occur
bs->print_it based on stop_on_solib_events
Custom message printing:
object events from CPU shared library events
library event"
Testing:
Example output with fix applied: