From patchwork Sun Feb 18 01:10:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 85933 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 8B75F386074C for ; Sun, 18 Feb 2024 01:14:53 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta36.uswest2.a.cloudfilter.net (omta36.uswest2.a.cloudfilter.net [35.89.44.35]) by sourceware.org (Postfix) with ESMTPS id 5E45D3860001 for ; Sun, 18 Feb 2024 01:10:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5E45D3860001 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5E45D3860001 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708218616; cv=none; b=Qz2Lx3DW2d73zp7oQZnm5yyGfS5tMsnft1pgkLHlQ/7LbiKJF7IA5CBGaJrhg7U6518yZZxJ9W5WCCECXtPmbtjN+koH9PWXsKRBqgB6zX91H32FQSrqgHI+KxpBDadtrJyPUe/DzcepsENzejdwKtktwt/hqHLNM4DJHFVXWsw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708218616; c=relaxed/simple; bh=zPukWj8LRFiJofWPQwbTPWj9hwqH6CHxQ2piALDJoXg=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=p8qqtDuVSNRsYamr4TIm8jqLrQM9uUQdyHxEUyJP4+IfkEJ7lYtyvm8UBelkVzcODfEaoGnSB0TomyEgeIxCwfNHQvlzj1igXH2I39o2PG3d+AtK8VW0zueDFvy2MFqxpTkDAPSM4Zh++FJKcEp1gS71NT5KlBTp1pda+2DSraQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6003a.ext.cloudfilter.net ([10.0.30.151]) by cmsmtp with ESMTPS id bMcarmWKSCF6GbVgzrOG1v; Sun, 18 Feb 2024 01:10:05 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id bVgyryVeobssWbVgyrpfMR; Sun, 18 Feb 2024 01:10:04 +0000 X-Authority-Analysis: v=2.4 cv=IaAkWnqa c=1 sm=1 tr=0 ts=65d158ec a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=IkcTkHD0fZMA:10 a=k7vzHIieQBIA:10 a=Qbun_eYptAEA:10 a=43yMY_HhHjItmh1-C9QA:9 a=QEXdDO2ut3YA:10 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=a19cNqhkQYh6BDgDiM9uF7BkqhvuVq5BpBBNl63qts4=; b=EGN0c840T+dh0eZdAv3ud2DwSl H8odihiU3WqGK2whKa4gxlrmDZOyeIt9idr3H3AoppWm/D94WLTgJILLWBQ6XOeKzSDjuhMz/263/ SCCqlwLgLIJpwdyAVgc89GKsZ; Received: from 71-211-170-195.hlrn.qwest.net ([71.211.170.195]:49770 helo=[192.168.0.21]) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1rbVgy-003IPy-0u for gdb-patches@sourceware.org; Sat, 17 Feb 2024 18:10:04 -0700 From: Tom Tromey Date: Sat, 17 Feb 2024 18:10:02 -0700 Subject: [PATCH 1/7] Compare section index in lookup_minimal_symbol_by_pc_section MIME-Version: 1.0 Message-Id: <20240217-dwarf-race-relocate-v1-1-d3d2d908c1e8@tromey.com> References: <20240217-dwarf-race-relocate-v1-0-d3d2d908c1e8@tromey.com> In-Reply-To: <20240217-dwarf-race-relocate-v1-0-d3d2d908c1e8@tromey.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.4 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 71.211.170.195 X-Source-L: No X-Exim-ID: 1rbVgy-003IPy-0u X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 71-211-170-195.hlrn.qwest.net ([192.168.0.21]) [71.211.170.195]:49770 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfFNdJCHv/Xw9ryREtcW854VoX/APfWCAxUSMtvUcZgKUgqquayTTjlwivVK4lrA+VH/EuYhDaFBqjLDxlJA+313rn71d29JC4+UdkX4oR1byHAoBgBHH l/zllz3kP8Mb0ENWkE2fMa1HklUpG4fNzCUHOpf3TzOdMXDmpoablBlMzELcubYqtMAv28KF2nWBtRO4O3cdHLIItQbKQXku77s= X-Spam-Status: No, score=-3022.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org This changes lookup_minimal_symbol_by_pc_section to compare the section index when comparing two symbols. This is ok because the symbols in question always come from the same objfile. The motivation for this is to simplify a refactoring in a subsequent patch; but it is also more efficient. --- gdb/minsyms.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gdb/minsyms.c b/gdb/minsyms.c index 1b85424586f..ffded3781c4 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -901,8 +901,8 @@ lookup_minimal_symbol_by_pc_section (CORE_ADDR pc_in, struct obj_section *sectio && (msymbol[hi].size () == msymbol[hi - 1].size ()) && (msymbol[hi].unrelocated_address () == msymbol[hi - 1].unrelocated_address ()) - && (msymbol[hi].obj_section (objfile) - == msymbol[hi - 1].obj_section (objfile))) + && (msymbol[hi].section_index () + == msymbol[hi - 1].section_index ())) { hi--; continue; From patchwork Sun Feb 18 01:10:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 85927 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 829763857011 for ; Sun, 18 Feb 2024 01:11:25 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta034.useast.a.cloudfilter.net (omta034.useast.a.cloudfilter.net [44.202.169.33]) by sourceware.org (Postfix) with ESMTPS id DC82F385E839 for ; Sun, 18 Feb 2024 01:10:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DC82F385E839 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org DC82F385E839 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708218613; cv=none; b=hzyH1veI6lx64cy36dzNVMoSfSW2VIyBVJQVegZgLAhGGwdp+AvIazems/mlvU1fCI/Uiou9Lvmak7/P4S24EwX1ggPyOi4886GyET1a/6kLH1+N7iL7DrrlmD6d/dPO19VY4N/19twY9rgu/8IFrvL5cxjLJ5PTGZ/9pTmQSfw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708218613; c=relaxed/simple; bh=c0Mef6NiKZg4mUEk/VvMtwh3Bs3gnsvF9gb63VGy7+k=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=vzeVNIg2A+cm71PHs7Tk/if870pXac9LfGBzd/8ZdOYQFSmKrrNC4XBkGkqtSNfhK1zZkP/AtOGkljUAuc6I2Ht6FylLe1rK6w9UXU0AviBIDDoiJoAPVs1aA2/WOfqYu9gHMUK+o4mK3z4hqt/kOI6RK72tT8gwEnLS2WzTCTo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5002a.ext.cloudfilter.net ([10.0.29.215]) by cmsmtp with ESMTPS id bU6urkwlUAxAkbVgzrxkoJ; Sun, 18 Feb 2024 01:10:05 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id bVgyr2qyR1SqmbVgzrfYv5; Sun, 18 Feb 2024 01:10:05 +0000 X-Authority-Analysis: v=2.4 cv=BeF70at2 c=1 sm=1 tr=0 ts=65d158ed a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=IkcTkHD0fZMA:10 a=k7vzHIieQBIA:10 a=Qbun_eYptAEA:10 a=shbjjGfoNgC23kRWVzQA:9 a=QEXdDO2ut3YA:10 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=qRMDOa6yD8JHmbl6uW0KT3xxOVQG+Z2ceIdPVSC6j5M=; b=bXcI4IFBZkLuT8tZtGTm5JtiMM 5eBidIUXQE2ojWk84u5AQ9lEl0r7fbLgE0Oxp3N9IByLv1XEOWQz/NzYdPP/Zvg9JoI7S9iDpTj+T 4zinYuopJif7Oliexnw7L55Hl; Received: from 71-211-170-195.hlrn.qwest.net ([71.211.170.195]:49770 helo=[192.168.0.21]) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1rbVgy-003IPy-1e for gdb-patches@sourceware.org; Sat, 17 Feb 2024 18:10:04 -0700 From: Tom Tromey Date: Sat, 17 Feb 2024 18:10:03 -0700 Subject: [PATCH 2/7] Remove unnecessary null check in lookup_minimal_symbol_by_pc_section MIME-Version: 1.0 Message-Id: <20240217-dwarf-race-relocate-v1-2-d3d2d908c1e8@tromey.com> References: <20240217-dwarf-race-relocate-v1-0-d3d2d908c1e8@tromey.com> In-Reply-To: <20240217-dwarf-race-relocate-v1-0-d3d2d908c1e8@tromey.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.4 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 71.211.170.195 X-Source-L: No X-Exim-ID: 1rbVgy-003IPy-1e X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 71-211-170-195.hlrn.qwest.net ([192.168.0.21]) [71.211.170.195]:49770 X-Source-Auth: tom+tromey.com X-Email-Count: 3 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfKxDFP8Wvdg1hWnFxk0fHUtc5K9/CrdAElfMEo9uNlYgMHCJYHlZJDG0vEONTwmSSY6Sg1zr52jwuMJ+rGOnSAx/p9nBvJ/30jejbHKPIaYinN7BwvH+ 68jz6fH6KZMNN/bBUa+eR/MBiwVLwRLcgUcG+B/4NHFQCr26bV+s2Np5sBQ10JR3ZibLwTNj+fU9GRNK5oOwqklBT8Gn6TaKuzk= X-Spam-Status: No, score=-3022.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org lookup_minimal_symbol_by_pc_section asserts that section != NULL early in the function, rendering a later check (and comment) unnecessary. --- gdb/minsyms.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/gdb/minsyms.c b/gdb/minsyms.c index ffded3781c4..f63d0f4af61 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -876,13 +876,11 @@ lookup_minimal_symbol_by_pc_section (CORE_ADDR pc_in, struct obj_section *sectio continue; } - /* If SECTION was specified, skip any symbol from - wrong section. */ - if (section - /* Some types of debug info, such as COFF, + /* Skip any symbol from wrong section. */ + if (/* Some types of debug info, such as COFF, don't fill the bfd_section member, so don't throw away symbols on those platforms. */ - && msymbol[hi].obj_section (objfile) != nullptr + msymbol[hi].obj_section (objfile) != nullptr && (!matching_obj_sections (msymbol[hi].obj_section (objfile), section))) From patchwork Sun Feb 18 01:10:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 85929 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 608003860753 for ; Sun, 18 Feb 2024 01:12:57 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta034.useast.a.cloudfilter.net (omta034.useast.a.cloudfilter.net [44.202.169.33]) by sourceware.org (Postfix) with ESMTPS id 14F16385ED4B for ; Sun, 18 Feb 2024 01:10:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 14F16385ED4B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 14F16385ED4B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708218615; cv=none; b=W8gVCMx+FEG3HPQbRQE4gpuGUAbp5T9wmFiRKdQteS+Ha2/gOr7CUyoySyWJYPLAtla0aFGtzQSQ3S6aKLvATJ3Oq1OD9r8pcMlyohcIBCU53r7wUyIQS/Z22N/MsVDGwrf123mrlHt2hJ6q4Obw8vZ8AC+kUZp6wv5PYpGsRtg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708218615; c=relaxed/simple; bh=lizhWgahU4qLvHYdnrqZQEscYU/2qnRauk+PIUvighM=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=u7FA//xv+DU+2IsiCvxDomSCSnZIG0yyFQjUnUyhImBB168QWfVBmxLIqB4xNTo4YAPV3ApEMWdeHaN/a33YvMYo1FxfC0zydrCFxmpGgEA10XvRx2jyWnF7TMepYQq9SJ9hyUB58OEbTz4S21HKMsjXDVD6zB5S1I489GYK56A= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5001a.ext.cloudfilter.net ([10.0.29.139]) by cmsmtp with ESMTPS id bRbyrkaScAxAkbVgzrxkoT; Sun, 18 Feb 2024 01:10:05 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id bVgzrEAywkGzYbVgzrvmyQ; Sun, 18 Feb 2024 01:10:05 +0000 X-Authority-Analysis: v=2.4 cv=Up/ANPwB c=1 sm=1 tr=0 ts=65d158ed a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=IkcTkHD0fZMA:10 a=k7vzHIieQBIA:10 a=Qbun_eYptAEA:10 a=RsZJF8UNYu-G7OIRRzcA:9 a=QEXdDO2ut3YA:10 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=WtM6DeFN42thof8PonVhHf6u6YPS4xnI2BQlclBg1aM=; b=J2kva4WXFaKvjiisHvsJMMj0fi CXiSX888alBQH5URISFwEQILllaRkwxHqbaBuhPt+5FnBDnME7GBL8bmmPuBweBNUDs09mh5stqq9 VoXpHdftr0A7b7fj+ZVcs9Ox9; Received: from 71-211-170-195.hlrn.qwest.net ([71.211.170.195]:49770 helo=[192.168.0.21]) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1rbVgy-003IPy-2U for gdb-patches@sourceware.org; Sat, 17 Feb 2024 18:10:04 -0700 From: Tom Tromey Date: Sat, 17 Feb 2024 18:10:04 -0700 Subject: [PATCH 3/7] Hoist a call to frob_address MIME-Version: 1.0 Message-Id: <20240217-dwarf-race-relocate-v1-3-d3d2d908c1e8@tromey.com> References: <20240217-dwarf-race-relocate-v1-0-d3d2d908c1e8@tromey.com> In-Reply-To: <20240217-dwarf-race-relocate-v1-0-d3d2d908c1e8@tromey.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.4 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 71.211.170.195 X-Source-L: No X-Exim-ID: 1rbVgy-003IPy-2U X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 71-211-170-195.hlrn.qwest.net ([192.168.0.21]) [71.211.170.195]:49770 X-Source-Auth: tom+tromey.com X-Email-Count: 4 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfMaer/DMmvHEU1g9n2cjvNaUhRMzGESAHQq1dE8sqmhZzOjnYTN4zZL8ctXBCwSAao9CS7xLDrRezQb6ybwdBEiULwZE/XpE/V51nrfF5h+ubfwfNuud b7gVv138fkz0AuI9O2oDu/yqIFwL0zWs0czO6WxDQrUSnShKGljRS0x3Z7W4xPmH7uQVxi2A1Ml5wuHPD6klEzsqOPQRnLWlnkY= X-Spam-Status: No, score=-3022.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org This hoists the call to frob_address in lookup_minimal_symbol_by_pc_section, so that it now appears earlier in the loop. This is useful to help with a refactoring in the next patch. Making this change also made it clear that 'pc' is not used, so this removes the local variable as well. --- gdb/minsyms.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gdb/minsyms.c b/gdb/minsyms.c index f63d0f4af61..36ca11a0b94 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -796,7 +796,9 @@ lookup_minimal_symbol_by_pc_section (CORE_ADDR pc_in, struct obj_section *sectio for (objfile *objfile : section->objfile->separate_debug_objfiles ()) { - CORE_ADDR pc = pc_in; + unrelocated_addr unrel_pc; + if (!frob_address (objfile, pc_in, &unrel_pc)) + continue; /* If this objfile has a minimal symbol table, go search it using a binary search. */ @@ -827,9 +829,7 @@ lookup_minimal_symbol_by_pc_section (CORE_ADDR pc_in, struct obj_section *sectio Warning: this code is trickier than it would appear at first. */ - unrelocated_addr unrel_pc; - if (frob_address (objfile, pc, &unrel_pc) - && unrel_pc >= msymbol[lo].unrelocated_address ()) + if (unrel_pc >= msymbol[lo].unrelocated_address ()) { while (msymbol[hi].unrelocated_address () > unrel_pc) { From patchwork Sun Feb 18 01:10:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 85928 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 40F2A386076C for ; Sun, 18 Feb 2024 01:12:17 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta36.uswest2.a.cloudfilter.net (omta36.uswest2.a.cloudfilter.net [35.89.44.35]) by sourceware.org (Postfix) with ESMTPS id 60B873860007 for ; Sun, 18 Feb 2024 01:10:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 60B873860007 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 60B873860007 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708218615; cv=none; b=cW3lALlwAhjPagBPINftLp2920+bDY0Cp8DrxV+LRlGxrR6xvR3d3FeLlQHyvHcSs9F3y+M1Zhe4aGNM/6T4mW9RKZ9iMgAchZnp4PYM3Oz/CxTQAdVR7dRMX2qY6xponKpRjrUFincj/CB5P989g6daHJ98eIAgM9dV157v6Rc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708218615; c=relaxed/simple; bh=uf+uoRPqnmRIRoW2jS0n/VHDTDjMJD2Fc9LDEHOmX9E=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=eBgzvtQqZ1gCVR4XyfI2Fqhdw3/9cbuJzRn62OBnwfxyP4a6C5C8KVFl1C05UIXKeibg0ZtlVRxPnWAJULHUfgfj6S8OogS0mQSyMsN5RolULSiIdOELppLqMwwdmKnclZa6v+jWcrA0gABjauYzwPrNEpiCSwwSEsgi0x0bkts= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5007a.ext.cloudfilter.net ([10.0.29.141]) by cmsmtp with ESMTPS id bU6lrnibxCF6GbVh0rOG2A; Sun, 18 Feb 2024 01:10:06 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id bVgzr8rMuZ4fIbVgzrKoP4; Sun, 18 Feb 2024 01:10:06 +0000 X-Authority-Analysis: v=2.4 cv=OPqE3jaB c=1 sm=1 tr=0 ts=65d158ee a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=IkcTkHD0fZMA:10 a=k7vzHIieQBIA:10 a=Qbun_eYptAEA:10 a=Pn5-7-ASx1INwsF6yocA:9 a=UzzNDi2jNRczGI5y:21 a=QEXdDO2ut3YA:10 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=3aF3v6Jrn11Uw6jhttHSLRI4sA5dS0nlkzNgOmr91cc=; b=qdRNAkh+Ar/f2NgqR6u2KQLG86 wtc7eLX16avbagpkrBkddJmlQtnc6e12/d1DAirPbfj7cVTBxe8wUBp33hcetwo3b1qBzaM67bPnc Yax9bHXX6LQ/jR022HWqgDSkG; Received: from 71-211-170-195.hlrn.qwest.net ([71.211.170.195]:49770 helo=[192.168.0.21]) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1rbVgz-003IPy-03 for gdb-patches@sourceware.org; Sat, 17 Feb 2024 18:10:05 -0700 From: Tom Tromey Date: Sat, 17 Feb 2024 18:10:05 -0700 Subject: [PATCH 4/7] Add unrelocated overload of lookup_minimal_symbol_by_pc_section MIME-Version: 1.0 Message-Id: <20240217-dwarf-race-relocate-v1-4-d3d2d908c1e8@tromey.com> References: <20240217-dwarf-race-relocate-v1-0-d3d2d908c1e8@tromey.com> In-Reply-To: <20240217-dwarf-race-relocate-v1-0-d3d2d908c1e8@tromey.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.4 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 71.211.170.195 X-Source-L: No X-Exim-ID: 1rbVgz-003IPy-03 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 71-211-170-195.hlrn.qwest.net ([192.168.0.21]) [71.211.170.195]:49770 X-Source-Auth: tom+tromey.com X-Email-Count: 5 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfBEvvTH1dpy+P1RhVlNSSKuaFkrUsiA4uzQaNBCNzNNrI+KL2v68kqdhoM70wtxXDbrU74QRq8b8lL9nf2lN0tbYEyWDnG44DUa6+CcWrGRr4Kty7JcY X6yU0zYcPmKn3qgooamNAgk76xON1FjhZIt0JMLS4mvqpEXHHLqT3yjv1+A6yC68u5Vq/9mkRcWxcBgiOj4d74J1pZryGm5TQRA= X-Spam-Status: No, score=-3022.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_MSPIKE_H2, SCC_5_SHORT_WORD_LINES, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org This refactors lookup_minimal_symbol_by_pc_section, pulling out the inner loop into a separate function. This function also does all its work using only the per-BFD object -- not the objfile. This overload is used in the next patch, but it seemed simpler to review as its own patch. --- gdb/minsyms.c | 437 ++++++++++++++++++++++++++++++++-------------------------- gdb/minsyms.h | 7 + 2 files changed, 250 insertions(+), 194 deletions(-) diff --git a/gdb/minsyms.c b/gdb/minsyms.c index 36ca11a0b94..2c8bf2a9f0b 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -747,6 +747,214 @@ msym_prefer_to_msym_type (lookup_msym_prefer prefer) gdb_assert_not_reached ("unhandled lookup_msym_prefer"); } +/* Worker function for the various public overloads. Looks in PER_BFD + for a symbol at UNREL_PC. PREVIOUS is an out parameter that is set + to the closest symbol appearing before UNREL_PC. WANT_TYPE + indicates which sections to look for. WRONG_SECTION is a predicate + that is passed a symbol to decide if it is in the wrong section for + some reason other than not matching WANT_TYPE. */ + +static minimal_symbol * +lookup_minimal_symbol_by_pc + (objfile_per_bfd_storage *per_bfd, + unrelocated_addr unrel_pc, + minimal_symbol **previous, + minimal_symbol_type want_type, + gdb::function_view wrong_section) +{ + /* If there is a minimal symbol table, go search it using a binary + search. */ + if (per_bfd->minimal_symbol_count == 0) + return nullptr; + + int best_zero_sized = -1; + minimal_symbol *best_symbol = nullptr; + + minimal_symbol *msymbol = per_bfd->msymbols.get (); + int lo = 0; + int hi = per_bfd->minimal_symbol_count - 1; + + /* This code assumes that the minimal symbols are sorted by + ascending address values. If the pc value is greater than or + equal to the first symbol's address, then some symbol in this + minimal symbol table is a suitable candidate for being the + "best" symbol. This includes the last real symbol, for cases + where the pc value is larger than any address in this vector. + + By iterating until the address associated with the current + hi index (the endpoint of the test interval) is less than + or equal to the desired pc value, we accomplish two things: + (1) the case where the pc value is larger than any minimal + symbol address is trivially solved, (2) the address associated + with the hi index is always the one we want when the iteration + terminates. In essence, we are iterating the test interval + down until the pc value is pushed out of it from the high end. + + Warning: this code is trickier than it would appear at first. */ + + if (unrel_pc >= msymbol[lo].unrelocated_address ()) + { + while (msymbol[hi].unrelocated_address () > unrel_pc) + { + /* pc is still strictly less than highest address. */ + /* Note "new" will always be >= lo. */ + int newobj = (lo + hi) / 2; + if ((msymbol[newobj].unrelocated_address () >= unrel_pc) + || (lo == newobj)) + { + hi = newobj; + } + else + { + lo = newobj; + } + } + + /* If we have multiple symbols at the same address, we want + hi to point to the last one. That way we can find the + right symbol if it has an index greater than hi. */ + while (hi < per_bfd->minimal_symbol_count - 1 + && (msymbol[hi].unrelocated_address () + == msymbol[hi + 1].unrelocated_address ())) + hi++; + + /* Skip various undesirable symbols. */ + while (hi >= 0) + { + /* Skip any absolute symbols. This is apparently + what adb and dbx do, and is needed for the CM-5. + There are two known possible problems: (1) on + ELF, apparently end, edata, etc. are absolute. + Not sure ignoring them here is a big deal, but if + we want to use them, the fix would go in + elfread.c. (2) I think shared library entry + points on the NeXT are absolute. If we want + special handling for this it probably should be + triggered by a special mst_abs_or_lib or some + such. */ + + if (msymbol[hi].type () == mst_abs) + { + hi--; + continue; + } + + /* Skip any symbol from the wrong section. */ + if (wrong_section (&msymbol[hi])) + { + hi--; + continue; + } + + /* If we are looking for a trampoline and this is a + text symbol, or the other way around, check the + preceding symbol too. If they are otherwise + identical prefer that one. */ + if (hi > 0 + && msymbol[hi].type () != want_type + && msymbol[hi - 1].type () == want_type + && (msymbol[hi].size () == msymbol[hi - 1].size ()) + && (msymbol[hi].unrelocated_address () + == msymbol[hi - 1].unrelocated_address ()) + && (msymbol[hi].section_index () + == msymbol[hi - 1].section_index ())) + { + hi--; + continue; + } + + /* If the minimal symbol has a zero size, save it + but keep scanning backwards looking for one with + a non-zero size. A zero size may mean that the + symbol isn't an object or function (e.g. a + label), or it may just mean that the size was not + specified. */ + if (msymbol[hi].size () == 0) + { + if (best_zero_sized == -1) + best_zero_sized = hi; + hi--; + continue; + } + + /* If we are past the end of the current symbol, try + the previous symbol if it has a larger overlapping + size. This happens on i686-pc-linux-gnu with glibc; + the nocancel variants of system calls are inside + the cancellable variants, but both have sizes. */ + if (hi > 0 + && msymbol[hi].size () != 0 + && unrel_pc >= msymbol[hi].unrelocated_end_address () + && unrel_pc < msymbol[hi - 1].unrelocated_end_address ()) + { + hi--; + continue; + } + + /* Otherwise, this symbol must be as good as we're going + to get. */ + break; + } + + /* If HI has a zero size, and best_zero_sized is set, + then we had two or more zero-sized symbols; prefer + the first one we found (which may have a higher + address). Also, if we ran off the end, be sure + to back up. */ + if (best_zero_sized != -1 + && (hi < 0 || msymbol[hi].size () == 0)) + hi = best_zero_sized; + + /* If the minimal symbol has a non-zero size, and this + PC appears to be outside the symbol's contents, then + refuse to use this symbol. If we found a zero-sized + symbol with an address greater than this symbol's, + use that instead. We assume that if symbols have + specified sizes, they do not overlap. */ + + if (hi >= 0 + && msymbol[hi].size () != 0 + && unrel_pc >= msymbol[hi].unrelocated_end_address ()) + { + if (best_zero_sized != -1) + hi = best_zero_sized; + else + { + /* If needed record this symbol as the closest + previous symbol. */ + if (*previous == nullptr + || (msymbol[hi].unrelocated_address () + > (*previous)->unrelocated_address ())) + *previous = &msymbol[hi]; + } + /* Done. */ + return best_symbol; + } + + if (hi >= 0 + && (best_symbol == nullptr + || (best_symbol->unrelocated_address () + < msymbol[hi].unrelocated_address ()))) + best_symbol = &msymbol[hi]; + } + + return best_symbol; +} + +/* See minsyms.h. */ + +minimal_symbol * +lookup_minimal_symbol_by_pc (objfile_per_bfd_storage *per_bfd, + unrelocated_addr addr) +{ + minimal_symbol *ignore = nullptr; + return lookup_minimal_symbol_by_pc (per_bfd, addr, &ignore, mst_text, + [] (minimal_symbol *msym) + { + return msym->type () != mst_text; + }); +} + /* See minsyms.h. Note that we need to look through ALL the minimal symbol tables @@ -760,10 +968,6 @@ lookup_minimal_symbol_by_pc_section (CORE_ADDR pc_in, struct obj_section *sectio lookup_msym_prefer prefer, bound_minimal_symbol *previous) { - int lo; - int hi; - int newobj; - struct minimal_symbol *msymbol; struct minimal_symbol *best_symbol = NULL; struct objfile *best_objfile = NULL; struct bound_minimal_symbol result; @@ -800,199 +1004,44 @@ lookup_minimal_symbol_by_pc_section (CORE_ADDR pc_in, struct obj_section *sectio if (!frob_address (objfile, pc_in, &unrel_pc)) continue; - /* If this objfile has a minimal symbol table, go search it - using a binary search. */ - - if (objfile->per_bfd->minimal_symbol_count > 0) + minimal_symbol *this_previous = nullptr; + minimal_symbol *minsym + = lookup_minimal_symbol_by_pc (objfile->per_bfd, unrel_pc, + &this_previous, want_type, + [&] (minimal_symbol *check_sym) + { + /* Some types of debug info, such as COFF, don't fill the + bfd_section member, so don't throw away symbols on those + platforms. */ + return (check_sym->obj_section (objfile) != nullptr + && !matching_obj_sections (check_sym->obj_section (objfile), + section)); + }); + + /* If needed record this symbol as the closest previous + symbol. */ + if (previous != nullptr) { - int best_zero_sized = -1; - - msymbol = objfile->per_bfd->msymbols.get (); - lo = 0; - hi = objfile->per_bfd->minimal_symbol_count - 1; - - /* This code assumes that the minimal symbols are sorted by - ascending address values. If the pc value is greater than or - equal to the first symbol's address, then some symbol in this - minimal symbol table is a suitable candidate for being the - "best" symbol. This includes the last real symbol, for cases - where the pc value is larger than any address in this vector. - - By iterating until the address associated with the current - hi index (the endpoint of the test interval) is less than - or equal to the desired pc value, we accomplish two things: - (1) the case where the pc value is larger than any minimal - symbol address is trivially solved, (2) the address associated - with the hi index is always the one we want when the iteration - terminates. In essence, we are iterating the test interval - down until the pc value is pushed out of it from the high end. - - Warning: this code is trickier than it would appear at first. */ - - if (unrel_pc >= msymbol[lo].unrelocated_address ()) + if (previous->minsym == nullptr + || (this_previous->unrelocated_address () + > previous->minsym->unrelocated_address ())) { - while (msymbol[hi].unrelocated_address () > unrel_pc) - { - /* pc is still strictly less than highest address. */ - /* Note "new" will always be >= lo. */ - newobj = (lo + hi) / 2; - if ((msymbol[newobj].unrelocated_address () >= unrel_pc) - || (lo == newobj)) - { - hi = newobj; - } - else - { - lo = newobj; - } - } - - /* If we have multiple symbols at the same address, we want - hi to point to the last one. That way we can find the - right symbol if it has an index greater than hi. */ - while (hi < objfile->per_bfd->minimal_symbol_count - 1 - && (msymbol[hi].unrelocated_address () - == msymbol[hi + 1].unrelocated_address ())) - hi++; - - /* Skip various undesirable symbols. */ - while (hi >= 0) - { - /* Skip any absolute symbols. This is apparently - what adb and dbx do, and is needed for the CM-5. - There are two known possible problems: (1) on - ELF, apparently end, edata, etc. are absolute. - Not sure ignoring them here is a big deal, but if - we want to use them, the fix would go in - elfread.c. (2) I think shared library entry - points on the NeXT are absolute. If we want - special handling for this it probably should be - triggered by a special mst_abs_or_lib or some - such. */ - - if (msymbol[hi].type () == mst_abs) - { - hi--; - continue; - } - - /* Skip any symbol from wrong section. */ - if (/* Some types of debug info, such as COFF, - don't fill the bfd_section member, so don't - throw away symbols on those platforms. */ - msymbol[hi].obj_section (objfile) != nullptr - && (!matching_obj_sections - (msymbol[hi].obj_section (objfile), - section))) - { - hi--; - continue; - } - - /* If we are looking for a trampoline and this is a - text symbol, or the other way around, check the - preceding symbol too. If they are otherwise - identical prefer that one. */ - if (hi > 0 - && msymbol[hi].type () != want_type - && msymbol[hi - 1].type () == want_type - && (msymbol[hi].size () == msymbol[hi - 1].size ()) - && (msymbol[hi].unrelocated_address () - == msymbol[hi - 1].unrelocated_address ()) - && (msymbol[hi].section_index () - == msymbol[hi - 1].section_index ())) - { - hi--; - continue; - } - - /* If the minimal symbol has a zero size, save it - but keep scanning backwards looking for one with - a non-zero size. A zero size may mean that the - symbol isn't an object or function (e.g. a - label), or it may just mean that the size was not - specified. */ - if (msymbol[hi].size () == 0) - { - if (best_zero_sized == -1) - best_zero_sized = hi; - hi--; - continue; - } - - /* If we are past the end of the current symbol, try - the previous symbol if it has a larger overlapping - size. This happens on i686-pc-linux-gnu with glibc; - the nocancel variants of system calls are inside - the cancellable variants, but both have sizes. */ - if (hi > 0 - && msymbol[hi].size () != 0 - && unrel_pc >= msymbol[hi].unrelocated_end_address () - && unrel_pc < msymbol[hi - 1].unrelocated_end_address ()) - { - hi--; - continue; - } - - /* Otherwise, this symbol must be as good as we're going - to get. */ - break; - } - - /* If HI has a zero size, and best_zero_sized is set, - then we had two or more zero-sized symbols; prefer - the first one we found (which may have a higher - address). Also, if we ran off the end, be sure - to back up. */ - if (best_zero_sized != -1 - && (hi < 0 || msymbol[hi].size () == 0)) - hi = best_zero_sized; - - /* If the minimal symbol has a non-zero size, and this - PC appears to be outside the symbol's contents, then - refuse to use this symbol. If we found a zero-sized - symbol with an address greater than this symbol's, - use that instead. We assume that if symbols have - specified sizes, they do not overlap. */ - - if (hi >= 0 - && msymbol[hi].size () != 0 - && unrel_pc >= msymbol[hi].unrelocated_end_address ()) - { - if (best_zero_sized != -1) - hi = best_zero_sized; - else - { - /* If needed record this symbol as the closest - previous symbol. */ - if (previous != nullptr) - { - if (previous->minsym == nullptr - || (msymbol[hi].unrelocated_address () - > previous->minsym->unrelocated_address ())) - { - previous->minsym = &msymbol[hi]; - previous->objfile = objfile; - } - } - /* Go on to the next object file. */ - continue; - } - } - - /* The minimal symbol indexed by hi now is the best one in this - objfile's minimal symbol table. See if it is the best one - overall. */ - - if (hi >= 0 - && ((best_symbol == NULL) || - (best_symbol->unrelocated_address () < - msymbol[hi].unrelocated_address ()))) - { - best_symbol = &msymbol[hi]; - best_objfile = objfile; - } + previous->minsym = this_previous; + previous->objfile = objfile; } + /* Go on to the next object file. */ + continue; + } + + /* MINSYM now is the best one in this objfile's minimal symbol + table. See if it is the best one overall. */ + if (minsym != nullptr + && ((best_symbol == NULL) || + (best_symbol->unrelocated_address () + < minsym->unrelocated_address ()))) + { + best_symbol = minsym; + best_objfile = objfile; } } diff --git a/gdb/minsyms.h b/gdb/minsyms.h index d44f281939b..df77977538f 100644 --- a/gdb/minsyms.h +++ b/gdb/minsyms.h @@ -301,6 +301,13 @@ struct bound_minimal_symbol lookup_minimal_symbol_by_pc_section struct bound_minimal_symbol lookup_minimal_symbol_by_pc (CORE_ADDR); +/* Overload of lookup_minimal_symbol_by_pc that only references the + (unrelocated) per-BFD object and only searches the text + section. */ + +minimal_symbol *lookup_minimal_symbol_by_pc (objfile_per_bfd_storage *per_bfd, + unrelocated_addr addr); + /* Iterate over all the minimal symbols in the objfile OBJF which match NAME. Both the ordinary and demangled names of each symbol are considered. The caller is responsible for canonicalizing NAME, From patchwork Sun Feb 18 01:10:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 85932 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 41A903860C2B for ; Sun, 18 Feb 2024 01:14:23 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta40.uswest2.a.cloudfilter.net (omta40.uswest2.a.cloudfilter.net [35.89.44.39]) by sourceware.org (Postfix) with ESMTPS id 020CE385C6E8 for ; Sun, 18 Feb 2024 01:10:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 020CE385C6E8 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 020CE385C6E8 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.39 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708218618; cv=none; b=Api8RzIeqZkfiAxCL+e41Sn+39GBOhEwr0BoAbgLdgGYIo0oOnRe3FFTlGSxHVNyst96Qhbxoa0AlFhaxvQLBGbTmeX/zrBzlqmNjTqWukG6b3+kfkvagjIcCpi0EkgoDFA4cwoC/sZt/qaeZg97PReXD4z7N/eHbtcbQdXZhdc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708218618; c=relaxed/simple; bh=4oONb1xk8uXItiSLdqU51sYfHXaLFmws+RXpAAmMtDo=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=n7UzwcKWOpweuKoDPO+CmLY+TrunyKJwEd4OKCXg1R4WeMpGNdGbeh2B+57wbpfX7jOkgroh22PLQUxggZrOr2WcxnIDtDQRcQpy8JKthQC+aMgOgnzyM0jDAmlsV/rsfcjOC73fmLZes8X4AYt1sBrRRC5ZMSBCTLaMJbQ0Nl0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6010a.ext.cloudfilter.net ([10.0.30.248]) by cmsmtp with ESMTPS id bRcBrFDFy80oibVh1rX0kD; Sun, 18 Feb 2024 01:10:07 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id bVgzr6ShCrLNabVgzrj1Gg; Sun, 18 Feb 2024 01:10:06 +0000 X-Authority-Analysis: v=2.4 cv=MNnDm9Zl c=1 sm=1 tr=0 ts=65d158ee a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=IkcTkHD0fZMA:10 a=k7vzHIieQBIA:10 a=Qbun_eYptAEA:10 a=CCpqsmhAAAAA:8 a=qFjlajEAVd0_sq2azYkA:9 a=QEXdDO2ut3YA:10 a=ul9cdbp4aOFLsgKbc677:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=Ct4IUt32FMIQHJwLuUuc9/lJNUKB/vRgfvzKP341Pn8=; b=kulzEzdae+ToBOrN8QXgRLZBTI cFBvAAuvFvyA0CzUGm/MO03MHJijsKGHc7nMgKDMKbIgEcQMHlmqqWVZjcnjTPZtaCyT3xHKIalKI IFOd8G9rV0S0XwIlZJpx6VfZz; Received: from 71-211-170-195.hlrn.qwest.net ([71.211.170.195]:49770 helo=[192.168.0.21]) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1rbVgz-003IPy-0w for gdb-patches@sourceware.org; Sat, 17 Feb 2024 18:10:05 -0700 From: Tom Tromey Date: Sat, 17 Feb 2024 18:10:06 -0700 Subject: [PATCH 5/7] Fix race in background DWARF indexer MIME-Version: 1.0 Message-Id: <20240217-dwarf-race-relocate-v1-5-d3d2d908c1e8@tromey.com> References: <20240217-dwarf-race-relocate-v1-0-d3d2d908c1e8@tromey.com> In-Reply-To: <20240217-dwarf-race-relocate-v1-0-d3d2d908c1e8@tromey.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.4 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 71.211.170.195 X-Source-L: No X-Exim-ID: 1rbVgz-003IPy-0w X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 71-211-170-195.hlrn.qwest.net ([192.168.0.21]) [71.211.170.195]:49770 X-Source-Auth: tom+tromey.com X-Email-Count: 6 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfACFUsbkwWRIYLPZ59BYbJhBAYqNKS7kXNTmn4Qf64z9WQ7BNZ8CU7zBwm2QOIkwH7FxSnw3Y9k/fs2T5Y4QHFzC7y5XWrhSXiD4a8dajFaaiStA9sKU znMzKnC+WsK5eOJl8PawQ5FsF8j2oxychAnB4hDaZnWtfk4tTap5Jy/T6CDdPCV87uiT+IWOURX6c4ei5U1qjT3dFQ4mbpb8pfY= X-Spam-Status: No, score=-3022.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org PR gdb/31261 points out a race in the background DWARF indexer. Looking into it, the problem is in dwarf2_per_objfile::adjust, which does: CORE_ADDR baseaddr = objfile->text_section_offset (); CORE_ADDR tem = (CORE_ADDR) addr + baseaddr; tem = gdbarch_adjust_dwarf2_addr (objfile->arch (), tem); return (unrelocated_addr) (tem - baseaddr); This code looks innocuous (or at least, it did to me), but if indexing is still happening when the objfile is relocated, this causes a data race when accessing the section offsets. I considered a couple of fixes for this. A simple one is to have relocation wait until indexing is done. However, it is better to avoid any blocking like this; and I figured there is no reason for the DWARF reader to require this information... famous last words. Adjustment is needed to work around a sort of deficiency in the MIPS target, where whether a function uses the MIPS16 ABI can apparently only be determined by examining the minimal symbols. To handle this, the patch uses the new lookup_minimal_symbol_by_pc_section overload that works solely off the per-BFD object -- which only holds unrelocated data and which is effectively read-only at the time of DWARF indexing. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31261 --- gdb/arch-utils.c | 5 +++-- gdb/arch-utils.h | 3 ++- gdb/dwarf2/frame.c | 13 ++++++++++--- gdb/dwarf2/read.c | 12 ++++++------ gdb/gdbarch-gen.h | 4 ++-- gdb/gdbarch.c | 6 +++--- gdb/gdbarch_components.py | 4 ++-- gdb/mips-tdep.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++ gdb/mips-tdep.h | 2 ++ 9 files changed, 79 insertions(+), 19 deletions(-) diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c index 1faa013c16f..a5cbd3f06d2 100644 --- a/gdb/arch-utils.c +++ b/gdb/arch-utils.c @@ -222,8 +222,9 @@ default_make_symbol_special (struct symbol *sym, struct objfile *objfile) /* See arch-utils.h. */ -CORE_ADDR -default_adjust_dwarf2_addr (CORE_ADDR pc) +unrelocated_addr +default_adjust_dwarf2_addr (objfile_per_bfd_storage *per_bfd, + unrelocated_addr pc) { return pc; } diff --git a/gdb/arch-utils.h b/gdb/arch-utils.h index 0f37aaf20f8..21cdade77b9 100644 --- a/gdb/arch-utils.h +++ b/gdb/arch-utils.h @@ -105,7 +105,8 @@ void default_make_symbol_special (struct symbol *sym, struct objfile *objfile); /* Do nothing default implementation of gdbarch_adjust_dwarf2_addr. */ -CORE_ADDR default_adjust_dwarf2_addr (CORE_ADDR pc); +unrelocated_addr default_adjust_dwarf2_addr (objfile_per_bfd_storage *per_bfd, + unrelocated_addr pc); /* Do nothing default implementation of gdbarch_adjust_dwarf2_line. */ diff --git a/gdb/dwarf2/frame.c b/gdb/dwarf2/frame.c index fc6704f434e..738906a77b9 100644 --- a/gdb/dwarf2/frame.c +++ b/gdb/dwarf2/frame.c @@ -145,13 +145,17 @@ typedef std::vector dwarf2_fde_table; struct comp_unit { comp_unit (struct objfile *objf) - : abfd (objf->obfd.get ()) + : abfd (objf->obfd.get ()), + per_bfd (objf->per_bfd) { } /* Keep the bfd convenient. */ bfd *abfd; + /* Also the per-bfd. */ + objfile_per_bfd_storage *per_bfd; + /* Pointer to the .debug_frame section loaded into memory. */ const gdb_byte *dwarf_frame_buffer = nullptr; @@ -1965,14 +1969,17 @@ decode_frame_entry_1 (struct gdbarch *gdbarch, = read_encoded_value (unit, fde->cie->encoding, fde->cie->ptr_size, buf, &bytes_read, (unrelocated_addr) 0); fde->initial_location - = (unrelocated_addr) gdbarch_adjust_dwarf2_addr (gdbarch, init_addr); + = gdbarch_adjust_dwarf2_addr (gdbarch, unit->per_bfd, + (unrelocated_addr) init_addr); buf += bytes_read; ULONGEST range = read_encoded_value (unit, fde->cie->encoding & 0x0f, fde->cie->ptr_size, buf, &bytes_read, (unrelocated_addr) 0); - ULONGEST addr = gdbarch_adjust_dwarf2_addr (gdbarch, init_addr + range); + ULONGEST addr + = (ULONGEST) gdbarch_adjust_dwarf2_addr (gdbarch, unit->per_bfd, + (unrelocated_addr) (init_addr + range)); fde->address_range = addr - (ULONGEST) fde->initial_location; buf += bytes_read; diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 486be7e4921..27feae20508 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -1211,10 +1211,8 @@ dwarf2_invalid_attrib_class_complaint (const char *arg1, const char *arg2) unrelocated_addr dwarf2_per_objfile::adjust (unrelocated_addr addr) { - CORE_ADDR baseaddr = objfile->text_section_offset (); - CORE_ADDR tem = (CORE_ADDR) addr + baseaddr; - tem = gdbarch_adjust_dwarf2_addr (objfile->arch (), tem); - return (unrelocated_addr) (tem - baseaddr); + return gdbarch_adjust_dwarf2_addr (objfile->arch (), objfile->per_bfd, + addr); } /* See read.h. */ @@ -1223,8 +1221,10 @@ CORE_ADDR dwarf2_per_objfile::relocate (unrelocated_addr addr) { CORE_ADDR baseaddr = objfile->text_section_offset (); - CORE_ADDR tem = (CORE_ADDR) addr + baseaddr; - return gdbarch_adjust_dwarf2_addr (objfile->arch (), tem); + unrelocated_addr adj = gdbarch_adjust_dwarf2_addr (objfile->arch (), + objfile->per_bfd, + addr); + return (CORE_ADDR) adj + baseaddr; } /* Hash function for line_header_hash. */ diff --git a/gdb/gdbarch-gen.h b/gdb/gdbarch-gen.h index 7a57bdcebe2..911547e8ef7 100644 --- a/gdb/gdbarch-gen.h +++ b/gdb/gdbarch-gen.h @@ -862,8 +862,8 @@ extern void set_gdbarch_make_symbol_special (struct gdbarch *gdbarch, gdbarch_ma code have the ISA bit set, matching line information and the symbol table. */ -typedef CORE_ADDR (gdbarch_adjust_dwarf2_addr_ftype) (CORE_ADDR pc); -extern CORE_ADDR gdbarch_adjust_dwarf2_addr (struct gdbarch *gdbarch, CORE_ADDR pc); +typedef unrelocated_addr (gdbarch_adjust_dwarf2_addr_ftype) (objfile_per_bfd_storage *per_bfd, unrelocated_addr pc); +extern unrelocated_addr gdbarch_adjust_dwarf2_addr (struct gdbarch *gdbarch, objfile_per_bfd_storage *per_bfd, unrelocated_addr pc); extern void set_gdbarch_adjust_dwarf2_addr (struct gdbarch *gdbarch, gdbarch_adjust_dwarf2_addr_ftype *adjust_dwarf2_addr); /* Adjust the address updated by a line entry in a backend-specific way. diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c index b9be3948d1e..34cd64edae1 100644 --- a/gdb/gdbarch.c +++ b/gdb/gdbarch.c @@ -3541,14 +3541,14 @@ set_gdbarch_make_symbol_special (struct gdbarch *gdbarch, gdbarch->make_symbol_special = make_symbol_special; } -CORE_ADDR -gdbarch_adjust_dwarf2_addr (struct gdbarch *gdbarch, CORE_ADDR pc) +unrelocated_addr +gdbarch_adjust_dwarf2_addr (struct gdbarch *gdbarch, objfile_per_bfd_storage *per_bfd, unrelocated_addr pc) { gdb_assert (gdbarch != NULL); gdb_assert (gdbarch->adjust_dwarf2_addr != NULL); if (gdbarch_debug >= 2) gdb_printf (gdb_stdlog, "gdbarch_adjust_dwarf2_addr called\n"); - return gdbarch->adjust_dwarf2_addr (pc); + return gdbarch->adjust_dwarf2_addr (per_bfd, pc); } void diff --git a/gdb/gdbarch_components.py b/gdb/gdbarch_components.py index d76b820c1b5..2a5d1e544e4 100644 --- a/gdb/gdbarch_components.py +++ b/gdb/gdbarch_components.py @@ -1497,9 +1497,9 @@ sure addresses in FDE, range records, etc. referring to compressed code have the ISA bit set, matching line information and the symbol table. """, - type="CORE_ADDR", + type="unrelocated_addr", name="adjust_dwarf2_addr", - params=[("CORE_ADDR", "pc")], + params=[("objfile_per_bfd_storage *", "per_bfd"), ("unrelocated_addr", "pc")], predefault="default_adjust_dwarf2_addr", invalid=False, ) diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c index bf0b66c4b00..8364cb0d009 100644 --- a/gdb/mips-tdep.c +++ b/gdb/mips-tdep.c @@ -356,6 +356,12 @@ is_compact_addr (CORE_ADDR addr) return ((addr) & 1); } +static int +is_compact_addr (unrelocated_addr addr) +{ + return ((CORE_ADDR) addr & 1); +} + /* Return one iff ADDR denotes standard ISA code. */ static int @@ -364,6 +370,12 @@ is_mips_addr (CORE_ADDR addr) return !is_compact_addr (addr); } +static int +is_mips_addr (unrelocated_addr addr) +{ + return !is_compact_addr (addr); +} + /* Return one iff ADDR denotes MIPS16 code. */ static int @@ -388,6 +400,12 @@ unmake_compact_addr (CORE_ADDR addr) return ((addr) & ~(CORE_ADDR) 1); } +static unrelocated_addr +unmake_compact_addr (unrelocated_addr addr) +{ + return (unrelocated_addr) (to_underlying (addr) & ~(CORE_ADDR) 1); +} + /* Add the ISA (compression) bit to ADDR. */ static CORE_ADDR @@ -396,6 +414,14 @@ make_compact_addr (CORE_ADDR addr) return ((addr) | (CORE_ADDR) 1); } +/* Add the ISA (compression) bit to ADDR. */ + +static unrelocated_addr +make_compact_addr (unrelocated_addr addr) +{ + return (unrelocated_addr) (to_underlying (addr) | (CORE_ADDR) 1); +} + /* Extern version of unmake_compact_addr; we use a separate function so that unmake_compact_addr can be inlined throughout this file. */ @@ -1225,6 +1251,21 @@ mips_pc_is_mips (CORE_ADDR memaddr) return is_mips_addr (memaddr); } +int +mips_pc_is_mips (objfile_per_bfd_storage *per_bfd, unrelocated_addr memaddr) +{ + /* Flags indicating that this is a MIPS16 or microMIPS function is + stored by elfread.c in the high bit of the info field. Use this + to decide if the function is standard MIPS. Otherwise if bit 0 + of the address is clear, then this is a standard MIPS function. */ + minimal_symbol *sym + = lookup_minimal_symbol_by_pc (per_bfd, make_compact_addr (memaddr)); + if (sym != nullptr) + return msymbol_is_mips (sym); + else + return is_mips_addr (memaddr); +} + /* Tell if the program counter value in MEMADDR is in a MIPS16 function. */ int @@ -1309,6 +1350,14 @@ mips_adjust_dwarf2_addr (CORE_ADDR pc) return mips_pc_is_mips (pc) ? pc : make_compact_addr (pc); } +static unrelocated_addr +mips_adjust_dwarf2_addr (objfile_per_bfd_storage *per_bfd, + unrelocated_addr pc) +{ + pc = unmake_compact_addr (pc); + return mips_pc_is_mips (per_bfd, pc) ? pc : make_compact_addr (pc); +} + /* Recalculate the line record requested so that the resulting PC has the ISA bit set correctly, used by DWARF-2 machinery. The need for this adjustment comes from some records associated with compressed diff --git a/gdb/mips-tdep.h b/gdb/mips-tdep.h index b64f37cebbb..9dd9bf16e7c 100644 --- a/gdb/mips-tdep.h +++ b/gdb/mips-tdep.h @@ -173,6 +173,8 @@ extern CORE_ADDR mips_unmake_compact_addr (CORE_ADDR addr); /* Tell if the program counter value in MEMADDR is in a standard MIPS function. */ extern int mips_pc_is_mips (CORE_ADDR memaddr); +extern int mips_pc_is_mips (objfile_per_bfd_storage *per_bfd, + unrelocated_addr memaddr); /* Tell if the program counter value in MEMADDR is in a MIPS16 function. */ From patchwork Sun Feb 18 01:10:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 85930 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 7F4CD3861002 for ; Sun, 18 Feb 2024 01:14:05 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta34.uswest2.a.cloudfilter.net (omta34.uswest2.a.cloudfilter.net [35.89.44.33]) by sourceware.org (Postfix) with ESMTPS id 971B2386000B for ; Sun, 18 Feb 2024 01:10:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 971B2386000B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 971B2386000B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708218615; cv=none; b=qdI2M5gYIVUGYhUQd3XPGbvavFbumCxtb5Vpmzr5F1OtFVf+RvXeBf2J2rER5Qx1+3c4ITSZof9Aoo6684mh3rzbM3PYcIcnOnkKCvzu4juKHIJjwZE/QYs1+4sOfU+IN5e9u3lycYhfTgNQA7iKD/FYS/LK39Q+tJP3ARA1J3s= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708218615; c=relaxed/simple; bh=bWYp0lO97u45+KOjL9P0tmPMorbx07OLiO0lc5wfoK8=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=PylRNjFPEPNMkXplhDGFgLWGxOZ7Tmy4mF9fG0FaW4cpS+QROsVKkMMUpwA6ofNBdgyQb7WeQfpH4AkxS+evI0aVrJ5WTC3CHMHhv19U9yLOt2uS5VNnw6SxxbFHVk/ajBaTe1kj1eX7McZf36frCpo6tJRqCKMdD+yFpW95uxs= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6009a.ext.cloudfilter.net ([10.0.30.184]) by cmsmtp with ESMTPS id bOyorcNwhpUFLbVh0rm9cY; Sun, 18 Feb 2024 01:10:06 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id bVgzrUHxv511rbVh0r86rq; Sun, 18 Feb 2024 01:10:06 +0000 X-Authority-Analysis: v=2.4 cv=X5vxK3Te c=1 sm=1 tr=0 ts=65d158ee a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=IkcTkHD0fZMA:10 a=k7vzHIieQBIA:10 a=Qbun_eYptAEA:10 a=1KOCFADMNJUfl-ylR9wA:9 a=QEXdDO2ut3YA:10 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=9Dz7DOCrR9nkfWSyzXm1kj3A26uVZq98MOBpVJ11EEc=; b=daE+MeHzmKRa5956nu21R5990E 1023kWCp3s8EBxG65UtxG7o3c13VPbUzfcCTZcEfjuu6ZQx9qPuAx3fjhNTwYNHosARs0fP47lykE V6L85c7X1VgLFYLoXEx6/2SVs; Received: from 71-211-170-195.hlrn.qwest.net ([71.211.170.195]:49770 helo=[192.168.0.21]) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1rbVgz-003IPy-1h for gdb-patches@sourceware.org; Sat, 17 Feb 2024 18:10:05 -0700 From: Tom Tromey Date: Sat, 17 Feb 2024 18:10:07 -0700 Subject: [PATCH 6/7] Use bound_minimal_symbol more in lookup_minimal_symbol_by_pc_section MIME-Version: 1.0 Message-Id: <20240217-dwarf-race-relocate-v1-6-d3d2d908c1e8@tromey.com> References: <20240217-dwarf-race-relocate-v1-0-d3d2d908c1e8@tromey.com> In-Reply-To: <20240217-dwarf-race-relocate-v1-0-d3d2d908c1e8@tromey.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.4 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 71.211.170.195 X-Source-L: No X-Exim-ID: 1rbVgz-003IPy-1h X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 71-211-170-195.hlrn.qwest.net ([192.168.0.21]) [71.211.170.195]:49770 X-Source-Auth: tom+tromey.com X-Email-Count: 7 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfJPRPR1L1PaGxvJrhAid3khsucv6d5CeAQt1Sa8iRg+sGo7Tkzyq9azoJ7SPLB/bw2rM3A5EwoWukkPGN1u/RrtnzB0/3XOKzpVLCw998eS90pxYkl9W mM//nLlgITb/I/BGXH7hAgm+pS2wsvZ73CtGpJMCBmO1oN4T5TfdeOC5ZIMfnJhs2H4+HMGtBBKQWUJI6trc2QLRbUEafetMkBw= X-Spam-Status: No, score=-3021.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_VALIDITY_RPBL, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org lookup_minimal_symbol_by_pc_section tracks the best symbol and objfile. This patch changes it to use a bound_minimal_symbol rather than two separate variables. This simplifies the code a little. --- gdb/minsyms.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/gdb/minsyms.c b/gdb/minsyms.c index 2c8bf2a9f0b..64f085a0314 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -968,9 +968,7 @@ lookup_minimal_symbol_by_pc_section (CORE_ADDR pc_in, struct obj_section *sectio lookup_msym_prefer prefer, bound_minimal_symbol *previous) { - struct minimal_symbol *best_symbol = NULL; - struct objfile *best_objfile = NULL; - struct bound_minimal_symbol result; + struct bound_minimal_symbol best = {}; if (previous != nullptr) { @@ -1036,18 +1034,13 @@ lookup_minimal_symbol_by_pc_section (CORE_ADDR pc_in, struct obj_section *sectio /* MINSYM now is the best one in this objfile's minimal symbol table. See if it is the best one overall. */ if (minsym != nullptr - && ((best_symbol == NULL) || - (best_symbol->unrelocated_address () - < minsym->unrelocated_address ()))) - { - best_symbol = minsym; - best_objfile = objfile; - } + && (best.minsym == nullptr + || (best.minsym->unrelocated_address () + < minsym->unrelocated_address ()))) + best = { minsym, objfile }; } - result.minsym = best_symbol; - result.objfile = best_objfile; - return result; + return best; } /* See minsyms.h. */ From patchwork Sun Feb 18 01:10:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 85931 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 66B2A3860C39 for ; Sun, 18 Feb 2024 01:14:11 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta34.uswest2.a.cloudfilter.net (omta34.uswest2.a.cloudfilter.net [35.89.44.33]) by sourceware.org (Postfix) with ESMTPS id ADE183860743 for ; Sun, 18 Feb 2024 01:10:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org ADE183860743 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org ADE183860743 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708218618; cv=none; b=qjgscBGlj8aw6cWewJ/K1hqIlkjLu4d9XtRz5TtJxJ0GzvYkrb+nBXFMOOXzJKrAKnrGlXQqYRtN5wWCTvb97hrR2BPaar3HWtThSyVrtzSk4SIUDD0x4IedTmBxtSpzfKrN4SgBQ6kGqaLN+1RRKmI5NWaZNP43bZg7LYHWuu0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708218618; c=relaxed/simple; bh=ohqCi4huH9l/TObGxRYoz2YiiZVfSqW4AuB3a7KHXWA=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=d+BV9GmHrCkqNe+wA2Lv0RS68P7psK+2OUPeB1J1Ppn7p126J8PWRxI3NmXPZQG5UdUtcl48BLwF6O8jMYE/yxAWGYR0SZWjZaypuRy2DwHh9SPJInE0N8i05/CpB7K0NvtVwTFxZaHdMaW688bVQE1NFYKr5W24jgBQ0lBws68= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6006a.ext.cloudfilter.net ([10.0.30.182]) by cmsmtp with ESMTPS id bOyprcNwnpUFLbVh0rm9ce; Sun, 18 Feb 2024 01:10:06 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id bVh0rvOlVsVJXbVh0r9ogV; Sun, 18 Feb 2024 01:10:06 +0000 X-Authority-Analysis: v=2.4 cv=acLCngot c=1 sm=1 tr=0 ts=65d158ee a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=IkcTkHD0fZMA:10 a=k7vzHIieQBIA:10 a=Qbun_eYptAEA:10 a=JiCVu4CyO55u8qh7b9UA:9 a=QEXdDO2ut3YA:10 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=Xa06npNdE3zMn4N2kvEMUZqaqIdcqiujRRPGU0Mpiro=; b=N6k3OV48gaanLwkjt72OIM4ZhB nnoUwng2kSTnLN67u3JwbKgpqidCh/VGCnkcUaqC88MYVRPuZlr9GePKnhWM5kXBIwP3Q59SVyp7W fupZ+P8qzUjPf6MjJWlG5tyh9; Received: from 71-211-170-195.hlrn.qwest.net ([71.211.170.195]:49770 helo=[192.168.0.21]) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1rbVgz-003IPy-2U for gdb-patches@sourceware.org; Sat, 17 Feb 2024 18:10:05 -0700 From: Tom Tromey Date: Sat, 17 Feb 2024 18:10:08 -0700 Subject: [PATCH 7/7] Fix address comparison in lookup_minimal_symbol_by_pc_section MIME-Version: 1.0 Message-Id: <20240217-dwarf-race-relocate-v1-7-d3d2d908c1e8@tromey.com> References: <20240217-dwarf-race-relocate-v1-0-d3d2d908c1e8@tromey.com> In-Reply-To: <20240217-dwarf-race-relocate-v1-0-d3d2d908c1e8@tromey.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.4 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 71.211.170.195 X-Source-L: No X-Exim-ID: 1rbVgz-003IPy-2U X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 71-211-170-195.hlrn.qwest.net ([192.168.0.21]) [71.211.170.195]:49770 X-Source-Auth: tom+tromey.com X-Email-Count: 8 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfIYE7/1Vz7V6PFPq0Lh6UqhHa3TeKWJaAP4C5P0xy9diLQnY0cUgf9VajWRsLa6yRGXl6H7ue1TIu6F16/J75zsDg0IKmNMxrX3zQzj68KR/C3LgVMYp p+YQczp8QLBx19BsSQfhbQhVAikqwf0tTODxBkoyLvbJMRn6sV3qX6NaAI0B5icnmHnqmlGa+4HpeoMFA7PN/jQ+dY3B47Saelg= X-Spam-Status: No, score=-3021.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_VALIDITY_RPBL, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org I noticed that lookup_minimal_symbol_by_pc_section is comparing unrelocated addresses across objfiles when trying to find the best symbol. However, this seems incorrect to me, as the unrelocated addresses aren't of interest here. This patch changes this code to compare the true addresses instead. This does make me wonder whether this code is necessary at all. --- gdb/minsyms.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gdb/minsyms.c b/gdb/minsyms.c index 64f085a0314..06a87865c13 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -1035,8 +1035,7 @@ lookup_minimal_symbol_by_pc_section (CORE_ADDR pc_in, struct obj_section *sectio table. See if it is the best one overall. */ if (minsym != nullptr && (best.minsym == nullptr - || (best.minsym->unrelocated_address () - < minsym->unrelocated_address ()))) + || best.value_address () < minsym->value_address (objfile))) best = { minsym, objfile }; }