From patchwork Sat Feb 8 15:27:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 37767 Received: (qmail 69874 invoked by alias); 8 Feb 2020 15:28:08 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 69592 invoked by uid 89); 8 Feb 2020 15:28:06 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy= X-HELO: gateway31.websitewelcome.com Received: from gateway31.websitewelcome.com (HELO gateway31.websitewelcome.com) (192.185.143.4) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 08 Feb 2020 15:28:05 +0000 Received: from cm10.websitewelcome.com (cm10.websitewelcome.com [100.42.49.4]) by gateway31.websitewelcome.com (Postfix) with ESMTP id 71CAB1995E for ; Sat, 8 Feb 2020 09:28:03 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id 0S1ajx1P9Efyq0S1aj7uVC; Sat, 08 Feb 2020 09:28:03 -0600 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: 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=RFCHB45MdJJBlGCPUmdzmRJSTaGTQOzJQ0wWjltmwfc=; b=JjYNeMbBJV2lmfLwVBV2/GFD0t mMpjAz515uEkFrs3pk0RMNy4YUNGxh/TawXJtiQnKlvLmEKaUFPO/P+3I3u+rxkLHGd5MyLBRAe4P TerJNGa8eehC7sCx3Chun851G; Received: from 75-166-123-50.hlrn.qwest.net ([75.166.123.50]:38112 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1j0S1Z-001WwE-SA; Sat, 08 Feb 2020 08:28:01 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 8/8] Move the frame data to the BFD when possible Date: Sat, 8 Feb 2020 08:27:58 -0700 Message-Id: <20200208152758.29385-9-tom@tromey.com> In-Reply-To: <20200208152758.29385-1-tom@tromey.com> References: <20200208152758.29385-1-tom@tromey.com> Now that comp_unit and the remaining frame data are all independent of the objfile, it can all be stored on the BFD and shared across inferiors. As with other code doing this same thing, care must be taken to not share the data when the objfile requires relocations. So, two keys are used: one for the BFD and one for the objfile, and gdb_bfd_requires_relocations is used to differentiate between the two cases. gdb/ChangeLog 2020-02-08 Tom Tromey * dwarf2/frame.c (dwarf2_frame_bfd_data): New global. (dwarf2_frame_objfile_data): Add comment. (find_comp_unit, set_comp_unit): New functions. (dwarf2_frame_find_fde): Use find_comp_unit. (dwarf2_build_frame_info): Use set_comp_unit. Change-Id: I50f5e1220c3f6b2992a15d5112fe474fb2904511 --- gdb/ChangeLog | 8 ++++++++ gdb/dwarf2/frame.c | 37 +++++++++++++++++++++++++++++++++---- 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/gdb/dwarf2/frame.c b/gdb/dwarf2/frame.c index 2c35016e2d9..25dddb7b1ae 100644 --- a/gdb/dwarf2/frame.c +++ b/gdb/dwarf2/frame.c @@ -1475,8 +1475,14 @@ dwarf2_frame_cfa (struct frame_info *this_frame) return get_frame_base (this_frame); } -const struct objfile_key dwarf2_frame_objfile_data; +/* We store the frame data on the BFD, when it is independent of the + address space and so can be shared. */ +const struct bfd_key dwarf2_frame_bfd_data; +/* If any BFD sections require relocations (note; really should be if + any debug info requires relocations), then we store the frame data + on the objfile instead, and do not share it. */ +const struct objfile_key dwarf2_frame_objfile_data; /* Pointer encoding helper functions. */ @@ -1630,6 +1636,29 @@ bsearch_fde_cmp (const dwarf2_fde *fde, CORE_ADDR seek_pc) return 1; } +/* Find an existing comp_unit for an objfile, if any. */ + +static comp_unit * +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); +} + +/* Store the comp_unit on OBJFILE, or the corresponding BFD, as + appropriate. */ + +static void +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); +} + /* Find the FDE for *PC. Return a pointer to the FDE, and store the initial location associated with it into *PC. */ @@ -1641,11 +1670,11 @@ dwarf2_frame_find_fde (CORE_ADDR *pc, CORE_ADDR *out_offset) CORE_ADDR offset; CORE_ADDR seek_pc; - comp_unit *unit = dwarf2_frame_objfile_data.get (objfile); + comp_unit *unit = find_comp_unit (objfile); if (unit == NULL) { dwarf2_build_frame_info (objfile); - unit = dwarf2_frame_objfile_data.get (objfile); + unit = find_comp_unit (objfile); } gdb_assert (unit != NULL); @@ -2261,7 +2290,7 @@ dwarf2_build_frame_info (struct objfile *objfile) unit->fde_table.shrink_to_fit (); } - dwarf2_frame_objfile_data.set (objfile, unit); + set_comp_unit (objfile, unit); } /* Handle 'maintenance show dwarf unwinders'. */