From patchwork Thu Jan 5 20:02:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 62763 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 522CD3858C39 for ; Thu, 5 Jan 2023 20:13:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 522CD3858C39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1672949612; bh=yNHUs/JRTYepKeOkols3MTdpodTfVh82la1+2F/KI4M=; 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=fNx1BHWXRtxAF7CrNKWggK7YLd6DfRXqB+CSJO+s03m2aoyjFVecm7JWySSGoY5gc V9dWJM8FvD8IVifrSeaOB/x9vl1zx+vQFtGek4Xg6G6RwoB07Hau3HbA6yiYjQ6UJZ 6ajiB3t2TAJFu0fkL7val0pkHej/Q1gLx9iiVv4A= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id BBCF73858D39 for ; Thu, 5 Jan 2023 20:12:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BBCF73858D39 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 305KCUpx015471 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 5 Jan 2023 15:12:35 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 305KCUpx015471 Received: from simark.localdomain (unknown [217.28.27.60]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 9D5A61E9EE; Thu, 5 Jan 2023 15:02:41 -0500 (EST) To: gdb-patches@sourceware.org Cc: Simon Marchi , Lancelot SIX Subject: [PATCH v2 6/8] gdb/solib-svr4: don't disable probes interface if probe not found Date: Thu, 5 Jan 2023 15:02:35 -0500 Message-Id: <20230105200237.987771-7-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230105200237.987771-1-simon.marchi@polymtl.ca> References: <20230105200237.987771-1-simon.marchi@polymtl.ca> MIME-Version: 1.0 X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Thu, 5 Jan 2023 20:12:30 +0000 X-Spam-Status: No, score=-3189.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, 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" From: Simon Marchi 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 fe009a1581d8..33577b7ddd2b 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;