From patchwork Sat Feb 8 15:27:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 37765 Received: (qmail 69801 invoked by alias); 8 Feb 2020 15:28:07 -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 69492 invoked by uid 89); 8 Feb 2020 15:28:06 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.8 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=20108 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:04 +0000 Received: from cm16.websitewelcome.com (cm16.websitewelcome.com [100.42.49.19]) by gateway31.websitewelcome.com (Postfix) with ESMTP id 1807F19940 for ; Sat, 8 Feb 2020 09:28:03 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id 0S1ZjLikE8vkB0S1ZjKZjr; 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=3T+Ez6yFCWQYGb1bg0aEwhi8eL23X12qCx6+iYwL3IY=; b=IKiAlgiK0tVgZENM6LiggVOApu Sh76GTTYYjTlTgoMfbSRlEYGiN9LrQPhv4hoAnFff6KsUDZ42qRJ5wyNAQAzWH7asupCN9xFjOfl2 QIQPzjLIYwrekQ4pcCdM3zlWu; 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-EA; Sat, 08 Feb 2020 08:28:01 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 6/8] Remove a use of the comp_unit backlink Date: Sat, 8 Feb 2020 08:27:56 -0700 Message-Id: <20200208152758.29385-7-tom@tromey.com> In-Reply-To: <20200208152758.29385-1-tom@tromey.com> References: <20200208152758.29385-1-tom@tromey.com> The DWARF frame comp_unit object still has a backlink to the objfile. In order to be truly objfile-independent, this must be removed. This patch removes one such use, by passing the gdbarch to decode_frame_entry directly. gdb/ChangeLog 2020-02-08 Tom Tromey * dwarf2/frame.c (decode_frame_entry_1): Add gdbarch parameter. (decode_frame_entry): Likewise. (dwarf2_build_frame_info): Update. Change-Id: I51126a468a012540eaf002be64dba7cbcb111b4d --- gdb/ChangeLog | 6 ++++++ gdb/dwarf2/frame.c | 21 +++++++++++++-------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/gdb/dwarf2/frame.c b/gdb/dwarf2/frame.c index 7e1a744513b..d4f6165b75c 100644 --- a/gdb/dwarf2/frame.c +++ b/gdb/dwarf2/frame.c @@ -1695,7 +1695,8 @@ enum eh_frame_type EH_CIE_OR_FDE_TYPE_ID = EH_CIE_TYPE_ID | EH_FDE_TYPE_ID }; -static const gdb_byte *decode_frame_entry (struct comp_unit *unit, +static const gdb_byte *decode_frame_entry (struct gdbarch *gdbarch, + struct comp_unit *unit, const gdb_byte *start, int eh_frame_p, dwarf2_cie_table &cie_table, @@ -1706,13 +1707,13 @@ static const gdb_byte *decode_frame_entry (struct comp_unit *unit, Return NULL if invalid input, otherwise the next byte to be processed. */ static const gdb_byte * -decode_frame_entry_1 (struct comp_unit *unit, const gdb_byte *start, +decode_frame_entry_1 (struct gdbarch *gdbarch, + struct comp_unit *unit, const gdb_byte *start, int eh_frame_p, dwarf2_cie_table &cie_table, dwarf2_fde_table *fde_table, enum eh_frame_type entry_type) { - struct gdbarch *gdbarch = get_objfile_arch (unit->objfile); const gdb_byte *buf, *end; ULONGEST length; unsigned int bytes_read; @@ -1957,7 +1958,8 @@ decode_frame_entry_1 (struct comp_unit *unit, const gdb_byte *start, fde->cie = find_cie (cie_table, cie_pointer); if (fde->cie == NULL) { - decode_frame_entry (unit, unit->dwarf_frame_buffer + cie_pointer, + decode_frame_entry (gdbarch, unit, + unit->dwarf_frame_buffer + cie_pointer, eh_frame_p, cie_table, fde_table, EH_CIE_TYPE_ID); fde->cie = find_cie (cie_table, cie_pointer); @@ -2008,7 +2010,8 @@ decode_frame_entry_1 (struct comp_unit *unit, const gdb_byte *start, expect an FDE or a CIE. */ static const gdb_byte * -decode_frame_entry (struct comp_unit *unit, const gdb_byte *start, +decode_frame_entry (struct gdbarch *gdbarch, + struct comp_unit *unit, const gdb_byte *start, int eh_frame_p, dwarf2_cie_table &cie_table, dwarf2_fde_table *fde_table, @@ -2020,7 +2023,7 @@ decode_frame_entry (struct comp_unit *unit, const gdb_byte *start, while (1) { - ret = decode_frame_entry_1 (unit, start, eh_frame_p, + ret = decode_frame_entry_1 (gdbarch, unit, start, eh_frame_p, cie_table, fde_table, entry_type); if (ret != NULL) break; @@ -2127,6 +2130,8 @@ dwarf2_build_frame_info (struct objfile *objfile) dwarf2_cie_table cie_table; dwarf2_fde_table fde_table; + struct gdbarch *gdbarch = get_objfile_arch (objfile); + /* Build a minimal decoding of the DWARF2 compilation unit. */ unit = new comp_unit; unit->abfd = objfile->obfd; @@ -2162,7 +2167,7 @@ dwarf2_build_frame_info (struct objfile *objfile) { frame_ptr = unit->dwarf_frame_buffer; while (frame_ptr < unit->dwarf_frame_buffer + unit->dwarf_frame_size) - frame_ptr = decode_frame_entry (unit, frame_ptr, 1, + frame_ptr = decode_frame_entry (gdbarch, unit, frame_ptr, 1, cie_table, &fde_table, EH_CIE_OR_FDE_TYPE_ID); } @@ -2192,7 +2197,7 @@ dwarf2_build_frame_info (struct objfile *objfile) { frame_ptr = unit->dwarf_frame_buffer; while (frame_ptr < unit->dwarf_frame_buffer + unit->dwarf_frame_size) - frame_ptr = decode_frame_entry (unit, frame_ptr, 0, + frame_ptr = decode_frame_entry (gdbarch, unit, frame_ptr, 0, cie_table, &fde_table, EH_CIE_OR_FDE_TYPE_ID); }