From patchwork Tue Dec 6 13:57:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 61560 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 60D8438469B2 for ; Tue, 6 Dec 2022 14:00:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 60D8438469B2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1670335236; bh=oFy9+R+yWvPjjgET9ndvYfItLGWDIM+Cd9lxDoJmhJg=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=lxx0I2mQ7EZnPcB4q88EDkdTtRmBIz9zLjImfNIonBl+v6XgNeYv7DAS+RlddI9MP D7qUDaDNhTx46sqRBf3tfc9jtS68XTGHpjKhaARXn0cPj2HHhB8cW59VNmzN3gb9vq Dbwz0qZHv7wod5Csqx0tWGe9Bu4YjKh2hHNjyB/k= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id 1E2F53848E30 for ; Tue, 6 Dec 2022 13:58:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1E2F53848E30 X-ASG-Debug-ID: 1670335113-0c856e762a1bc10001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id unqNKzZsBL9jQ45T (version=TLSv1 cipher=AES128-SHA bits=128 verify=NO); Tue, 06 Dec 2022 08:58:33 -0500 (EST) X-Barracuda-Envelope-From: simon.marchi@efficios.com X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from epycamd.internal.efficios.com (192-222-180-24.qc.cable.ebox.net [192.222.180.24]) by smtp.ebox.ca (Postfix) with ESMTP id 32147441B21; Tue, 6 Dec 2022 08:58:33 -0500 (EST) X-Barracuda-RBL-IP: 192.222.180.24 X-Barracuda-Effective-Source-IP: 192-222-180-24.qc.cable.ebox.net[192.222.180.24] X-Barracuda-Apparent-Source-IP: 192.222.180.24 To: gdb-patches@sourceware.org Cc: Simon Marchi , Lancelot SIX 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 X-ASG-Orig-Subj: [PATCH 10/12] gdb/solib-svr4: don't disable probes interface if probe not found Message-Id: <20221206135729.3937767-11-simon.marchi@efficios.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221206135729.3937767-1-simon.marchi@efficios.com> References: <20221206135729.3937767-1-simon.marchi@efficios.com> MIME-Version: 1.0 X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1670335113 X-Barracuda-Encrypted: AES128-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-Scan-Msg-Size: 2844 X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=5.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.102645 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-Spam-Status: No, score=-3498.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_SOFTFAIL, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Simon Marchi via Gdb-patches From: Simon Marchi Reply-To: Simon Marchi Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" 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 --- 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;