public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@efficios.com>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>,
	Lancelot SIX <lancelot.six@amd.com>
Subject: [PATCH 10/12] gdb/solib-svr4: don't disable probes interface if probe not found
Date: Tue,  6 Dec 2022 08:57:27 -0500	[thread overview]
Message-ID: <20221206135729.3937767-11-simon.marchi@efficios.com> (raw)
In-Reply-To: <20221206135729.3937767-1-simon.marchi@efficios.com>

In ROCm-GDB, we install an solib provider for the GPU code objects on
top of the svr4 provider for the host, in order to add solibs
representing the GPU code objects to the solib list containing the host
process' shared libraries.  We override the target_so_ops::handle_event
function pointer with our own, in which we call svr4_so_ops.handle_event
(which contains svr4_handle_solib_event) manually.  When the host
(un)loads a library, the ROCm part of handle_event is a no-op.  When the
GPU (un)loads a code object, we want the host side (svr4) to be a no-op.

The problem is that when handle_event is called because of a GPU event,
svr4_handle_solib_event gets called while not stopped at an svr4
probe.  It then assumes this means there's a problem with the probes
interface and disables it through the following sequence of events:

  - solib_event_probe_at return nullptr
  - svr4_handle_solib_event returns early
  - the make_scope_exit callback calls disable_probes_interface

We could fix that by making the ROCm handle_event callback check if an
svr4 probe is that the stop address, and only call
svr4_so_ops.handle_event if so.  However, it doesn't feel right to
include some svr4 implementation detail in the ROCm event handler.

Instead, this patch changes svr4_handle_solib_event to not assume it is
an error if called while not at an svr4 probe location, and therefore
not disable the probes interface.  That just means moving the
make_scope_exit call below where we lookup the probe by pc.

Change-Id: Ie8ddf5beffa2e92b8ebfdd016454546252519244
Co-Authored-By: Lancelot SIX <lancelot.six@amd.com>
---
 gdb/solib-svr4.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index 63baaf80921..9fc68c11a0e 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -1977,6 +1977,16 @@ svr4_handle_solib_event (void)
   if (info->probes_table == NULL)
     return;
 
+  pc = regcache_read_pc (get_current_regcache ());
+  pa = solib_event_probe_at (info, pc);
+  if (pa == nullptr)
+    {
+      /* When some solib ops sits above us, it can respond to a solib event
+	 by calling in here.  This is done assuming that if the current event
+	 is not an SVR4 solib event, calling here should be a no-op.  */
+      return;
+    }
+
   /* If anything goes wrong we revert to the original linker
      interface.  */
   auto cleanup = make_scope_exit ([info] ()
@@ -1984,11 +1994,6 @@ svr4_handle_solib_event (void)
       disable_probes_interface (info);
     });
 
-  pc = regcache_read_pc (get_current_regcache ());
-  pa = solib_event_probe_at (info, pc);
-  if (pa == NULL)
-    return;
-
   action = solib_event_probe_action (pa);
   if (action == PROBES_INTERFACE_FAILED)
     return;
-- 
2.38.1


  parent reply	other threads:[~2022-12-06 13:58 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-06 13:57 [PATCH 00/12] Initial support for ROCm platform (AMDGPU) debugging Simon Marchi
2022-12-06 13:57 ` [PATCH 01/12] gdb: add supports_arch_info callback to gdbarch_register Simon Marchi
2022-12-06 16:45   ` Andrew Burgess
2022-12-06 13:57 ` [PATCH 02/12] gdb: make install_breakpoint return a non-owning reference Simon Marchi
2022-12-06 16:46   ` Andrew Burgess
2022-12-06 13:57 ` [PATCH 03/12] gdbsupport: add type definitions for pid, lwp and tid Simon Marchi
2022-12-06 16:36   ` Andrew Burgess
2022-12-07  2:55     ` Simon Marchi
2022-12-06 13:57 ` [PATCH 04/12] gdb: add inferior_pre_detach observable Simon Marchi
2022-12-06 16:39   ` Andrew Burgess
2022-12-06 13:57 ` [PATCH 05/12] gdb: make gdbarch_alloc take ownership of the tdep Simon Marchi
2022-12-06 17:06   ` Andrew Burgess
2022-12-06 13:57 ` [PATCH 06/12] gdb: add gdbarch_up Simon Marchi
2022-12-06 17:07   ` Andrew Burgess
2022-12-06 13:57 ` [PATCH 07/12] gdbsupport: move libxxhash configure check to gdbsupport Simon Marchi
2022-12-06 17:19   ` Andrew Burgess
2022-12-06 13:57 ` [PATCH 08/12] gdbsupport: move fast_hash to gdbsupport/common-utils.h Simon Marchi
2022-12-06 17:19   ` Andrew Burgess
2022-12-06 13:57 ` [PATCH 09/12] gdbsupport: add gdb::string_view_hash Simon Marchi
2022-12-06 17:19   ` Andrew Burgess
2022-12-06 13:57 ` Simon Marchi [this message]
2022-12-06 13:57 ` [PATCH 11/12] gdb: make gdb_printing_disassembler::stream public Simon Marchi
2022-12-06 17:38   ` Andrew Burgess
2022-12-06 13:57 ` [PATCH 12/12] gdb: initial support for ROCm platform (AMDGPU) debugging Simon Marchi
2022-12-06 15:00   ` Eli Zaretskii
2022-12-06 15:10     ` Simon Marchi
2022-12-06 15:42   ` Eli Zaretskii
2022-12-07  2:17     ` Simon Marchi
2022-12-07 13:29       ` Eli Zaretskii
2022-12-16 17:37         ` Simon Marchi
2023-01-05 19:41 ` [PATCH 00/12] Initial " Simon Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221206135729.3937767-11-simon.marchi@efficios.com \
    --to=simon.marchi@efficios.com \
    --cc=gdb-patches@sourceware.org \
    --cc=lancelot.six@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).