From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1879) id 80B453858430; Thu, 2 Feb 2023 15:08:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 80B453858430 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1675350537; bh=ibviT+D6V1zKlUqMx5sIvXyrJF+ktCZroDnPln8lgKA=; h=From:To:Subject:Date:From; b=Q15tEoIcuvySmwe5/ZL6r78kos6U3YZ6z4L7LdHgJ2+9Nk2YTQ5HOqn3rf2KBTQ24 MF+Jy8Pbhr9hXhoDkeKlwYy7CKxox1GjVhRGGwquD/9aI0baGlVRuIg9OV3J7X/NYj 2wTR62/0tmZFIga1X94yGF3/857d0Y2FHoJusi44= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Simon Marchi To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb/solib-svr4: don't disable probes interface if probe not found X-Act-Checkin: binutils-gdb X-Git-Author: Simon Marchi X-Git-Refname: refs/heads/master X-Git-Oldrev: d246d904adf3e338c731c123219a8246281002e2 X-Git-Newrev: 17467c103073ae0ec7bc43ffa35cb488cd2a97ed Message-Id: <20230202150857.80B453858430@sourceware.org> Date: Thu, 2 Feb 2023 15:08:57 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D17467c103073= ae0ec7bc43ffa35cb488cd2a97ed commit 17467c103073ae0ec7bc43ffa35cb488cd2a97ed Author: Simon Marchi Date: Tue Nov 22 13:18:43 2022 -0500 gdb/solib-svr4: don't disable probes interface if probe not found =20 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. =20 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: =20 - solib_event_probe_at return nullptr - svr4_handle_solib_event returns early - the make_scope_exit callback calls disable_probes_interface =20 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. =20 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. =20 Change-Id: Ie8ddf5beffa2e92b8ebfdd016454546252519244 Co-Authored-By: Lancelot SIX Diff: --- 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 fe009a1581d..33577b7ddd2 100644 --- a/gdb/solib-svr4.c +++ b/gdb/solib-svr4.c @@ -1977,6 +1977,16 @@ svr4_handle_solib_event (void) if (info->probes_table =3D=3D NULL) return; =20 + pc =3D regcache_read_pc (get_current_regcache ()); + pa =3D solib_event_probe_at (info, pc); + if (pa =3D=3D 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 =3D make_scope_exit ([info] () @@ -1984,11 +1994,6 @@ svr4_handle_solib_event (void) disable_probes_interface (info); }); =20 - pc =3D regcache_read_pc (get_current_regcache ()); - pa =3D solib_event_probe_at (info, pc); - if (pa =3D=3D NULL) - return; - action =3D solib_event_probe_action (pa); if (action =3D=3D PROBES_INTERFACE_FAILED) return;