From 86e751f51e687b88e0c39333c34fed59da893d15 Mon Sep 17 00:00:00 2001 From: Laurent Morichetti Date: Sat, 21 Dec 2019 21:07:31 -0800 Subject: [PATCH] Fix test failures (timeout) The following tests: - gdb.base/catch-fork-kill.exp - gdb.base/coredump-filter.exp - gdb.base/corefile.exp - gdb.base/multi-forks.exp - gdb.multi/watchpoint-multi-exit.exp - gdb.threads/fork-plus-threads.exp - gdb.threads/gcore-thread.exp - gdb.threads/process-dies-while-detaching.exp timeout after a target, for which amd_dbgapi_process_attach failed, terminates. When amd_dbgapi_process_attach fails, the notifier file desriptor is left uninitialized, and rocm_target_inferior_exit ends up closing stdin. Without stdin, gdb no longer receives any input and hangs. amd_dbapi_notifier should have a default value of -1 (not a valid file descriptor), and rocm_target_inferior_exit should test the notifier file descriptor before closing it. gdb/ChangeLog: * rocm-tdep.c (rocm_inferior_info::process_id): Initialize. (rocm_inferior_info::notifier): Initialize. (rocm_target_inferior_exit): Test notifier before closing. Change-Id: Ib7e2404440cb377a1e5235d24844aab70f801eb7 --- gdb/rocm-tdep.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gdb/rocm-tdep.c b/gdb/rocm-tdep.c index 2989a82081..06153eeda0 100644 --- a/gdb/rocm-tdep.c +++ b/gdb/rocm-tdep.c @@ -76,10 +76,10 @@ struct rocm_notify_shared_library_info struct rocm_inferior_info { /* The amd_dbgapi_process_id for this inferior. */ - amd_dbgapi_process_id_t process_id; + amd_dbgapi_process_id_t process_id{ AMD_DBGAPI_PROCESS_NONE }; /* The amd_dbgapi_notifier_t for this inferior. */ - amd_dbgapi_notifier_t notifier; + amd_dbgapi_notifier_t notifier{ -1 }; /* True if commit_resume should all-start the GPU queues. */ bool commit_resume_all_start; @@ -1210,7 +1210,8 @@ rocm_target_inferior_exit (struct inferior *inf) amd_dbgapi_deactivated.notify (); - delete_file_handler (info->notifier); + if (info->notifier != -1) + delete_file_handler (info->notifier); amd_dbgapi_process_detach (info->process_id); -- 2.34.1