From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id A19eBbEnyV/PFgAAWB0awg (envelope-from ) for ; Thu, 03 Dec 2020 13:00:17 -0500 Received: by simark.ca (Postfix, from userid 112) id 06D341F0AB; Thu, 3 Dec 2020 13:00:17 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_NONE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from sourceware.org (unknown [8.43.85.97]) (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 ESMTPS id 8E6431E58E for ; Thu, 3 Dec 2020 13:00:16 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D72A6385042C; Thu, 3 Dec 2020 18:00:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D72A6385042C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1607018415; bh=/xD/5EQOVlyj9D2JCv7bls0uh3jccbNSPweppRi4RGc=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=boR1g3RplKX6wg0mQXFAnGoxpGqiqLz3GJ+djf0kyA3qgcIo1gEvzdocSh9pNS+5Z NzqTJYiCHOuA8YR+TX8ecpqExrxvTPB06j7Egvgg9zWj+175AN4ggXCtujjYd3UWrU CbiDNUSNdRCA8VtHnw4bA6runienr1wiorNOBeRU= Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id C65F8385042C for ; Thu, 3 Dec 2020 18:00:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C65F8385042C X-ASG-Debug-ID: 1607018412-0c856e67e2420b0001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id 4E4eEzaXdwOPkRva (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 03 Dec 2020 13:00:12 -0500 (EST) X-Barracuda-Envelope-From: simon.marchi@polymtl.ca X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from simark.localdomain (173-246-6-90.qc.cable.ebox.net [173.246.6.90]) by smtp.ebox.ca (Postfix) with ESMTP id 4F446441B21; Thu, 3 Dec 2020 13:00:12 -0500 (EST) X-Barracuda-RBL-IP: 173.246.6.90 X-Barracuda-Effective-Source-IP: 173-246-6-90.qc.cable.ebox.net[173.246.6.90] X-Barracuda-Apparent-Source-IP: 173.246.6.90 To: gdb-patches@sourceware.org Subject: [PATCH] gdb: fix logic of find_comp_unit and set_comp_unit Date: Thu, 3 Dec 2020 13:00:11 -0500 X-ASG-Orig-Subj: [PATCH] gdb: fix logic of find_comp_unit and set_comp_unit Message-Id: <20201203180011.1909405-1-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1607018412 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Barracuda-BRTS-Status: 1 X-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-Scan-Msg-Size: 2012 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=8.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.86280 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 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: , From: Simon Marchi via Gdb-patches Reply-To: Simon Marchi Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" The logic in find_comp_unit and set_comp_unit is reversed. When the BFD requires relocation, we want to put the comp_unit structure in the map where the comp_unit objects are not shared, that is the one indexed by objfile. If the BFD does not require relocation, then, we can share a single comp_unit structure for all users of that BFD, so we want to put it in the BFD-indexed map. The comments on top of dwarf2_frame_bfd_data and dwarf2_frame_objfile_data make that clear. Fix it by swapping the two in find_comp_unit and set_comp_unit. I don't have a test for this, because I don't see how to write one in a reasonable amount of time. gdb/ChangeLog: PR gdb/26876 * dwarf2/frame.c (find_comp_unit, set_comp_unit): Reverse use of dwarf2_frame_bfd_data and dwarf2_frame_objfile_data. Change-Id: I80c1ee7ad8425fa4947de65b170973d05f5a52ec --- gdb/dwarf2/frame.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/gdb/dwarf2/frame.c b/gdb/dwarf2/frame.c index a577a671f242..7df3ccfe46a7 100644 --- a/gdb/dwarf2/frame.c +++ b/gdb/dwarf2/frame.c @@ -1640,8 +1640,9 @@ find_comp_unit (struct objfile *objfile) { bfd *abfd = objfile->obfd; if (gdb_bfd_requires_relocations (abfd)) - return dwarf2_frame_bfd_data.get (abfd); - return dwarf2_frame_objfile_data.get (objfile); + return dwarf2_frame_objfile_data.get (objfile); + + return dwarf2_frame_bfd_data.get (abfd); } /* Store the comp_unit on OBJFILE, or the corresponding BFD, as @@ -1652,8 +1653,9 @@ set_comp_unit (struct objfile *objfile, struct comp_unit *unit) { bfd *abfd = objfile->obfd; if (gdb_bfd_requires_relocations (abfd)) - return dwarf2_frame_bfd_data.set (abfd, unit); - return dwarf2_frame_objfile_data.set (objfile, unit); + return dwarf2_frame_objfile_data.set (objfile, unit); + + return dwarf2_frame_bfd_data.set (abfd, unit); } /* Find the FDE for *PC. Return a pointer to the FDE, and store the -- 2.29.2