Skip to content

Commit

Permalink
testsuite: avoid leftover process from gdb.rocm/gcore-after-attach
Browse files Browse the repository at this point in the history
The gcore-after-attach process does start a process outside of the
debugger, attach to it, generate a core dump of the process and then
restarts GDB to load the core dump back.

The restart part is done using clean_restart, which kills GDB and
restarts a new session.  Because we attached to the process, GDB is not
using the PTRACE_O_EXITKILL option, so when we kill the debugger, the
process is free to continue execution.  Since the process has an
infinite loop (to make it easier to ensure GPU activity at the moment we
attach), it continues execution until runtest eventually completes and
kills it.  A consequence is that the gcore-after-attach processes are
going to be present when running any test after the
gcore-after-attach.exp, which is not the intent.

This patch makes sure that no process is left over after running the
gcore-after-attach.exp testcase by explicitly killing and reaping the
process.

Bug: SWDEV-469646
Change-Id: I70c923004f70ef200ee4be825d2d4a6b48dbc123
(cherry picked from commit 851c124)
  • Loading branch information
lancesix committed Aug 8, 2024
1 parent 7ba4b4f commit cd98ea7
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions gdb/testsuite/gdb.rocm/gcore-after-attach.exp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@ proc do_test {debug_enabled} {
return
}

# Since we attached to the process, GDB is not using PTRACE_O_EXITKILL,
# so when we later call clean_restart, we kill GDB and the spawned process
# is free to go again. However, because this process uses an infinite loop,
# it will remain around using GPU resources until the runtest execution has
# completed, which could affect other tests executed later in the session.
# To avoid this, be sure to kill the process, and have TCL reap the wait
# status.
kill_wait_spawned_process $spawn_id

# Reload the corefile.
clean_restart $::binfile
gdb_test "core-file $corefile_path" "Core was generated by.*" \
Expand Down

0 comments on commit cd98ea7

Please sign in to comment.