From patchwork Sat Feb 8 15:27:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 37762 Received: (qmail 69197 invoked by alias); 8 Feb 2020 15:28:04 -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 69173 invoked by uid 89); 8 Feb 2020 15:28:04 -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=framec, frame.c, UD:frame.c, sk:dwarf_f X-HELO: gateway32.websitewelcome.com Received: from gateway32.websitewelcome.com (HELO gateway32.websitewelcome.com) (192.185.145.123) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 08 Feb 2020 15:28:02 +0000 Received: from cm12.websitewelcome.com (cm12.websitewelcome.com [100.42.49.8]) by gateway32.websitewelcome.com (Postfix) with ESMTP id 3AB6B76428 for ; Sat, 8 Feb 2020 09:28:01 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id 0S1Zj7XDSvBMd0S1ZjRr7R; Sat, 08 Feb 2020 09:28:01 -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=+tH6vN98jKpJtxruoL30944RL11LLlXYAWtDBccVVXw=; b=GXX+oef29ppaWlq/aCXypLqpxw fEENJl8cEMZAQx2XG6yD2r5NqHhJ5CQWAb+yXJrC3VHFug9l6sVYuEc/1UhFaCF03PDaBLy+Ce/An LCPSduOFnWDNWvAFQ0lYAu5GM; 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-0A; Sat, 08 Feb 2020 08:28:01 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 4/8] Store the comp_unit instead of the FDE table Date: Sat, 8 Feb 2020 08:27:54 -0700 Message-Id: <20200208152758.29385-5-tom@tromey.com> In-Reply-To: <20200208152758.29385-1-tom@tromey.com> References: <20200208152758.29385-1-tom@tromey.com> This changes the DWARF frame code to store the comp_unit on the objfile, rather than storing the FDE table. It also changes the comp_unit to be heap-allocated using "new". This change makes it simpler for a later patch to add a field to the comp_unit, and to have deallaction work properly. This in turn is important for making the frame data be independent of the objfile. gdb/ChangeLog 2020-02-08 Tom Tromey * dwarf2/frame.c (struct comp_unit): Add initializers. (dwarf2_frame_objfile_data): Store a comp_unit. (dwarf2_frame_find_fde): Update. (dwarf2_build_frame_info): Use "new". Change-Id: Id339892824caf47e7909ed5ee7e2f0556d645dba --- gdb/ChangeLog | 7 +++++++ gdb/dwarf2/frame.c | 43 ++++++++++++++++++++----------------------- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/gdb/dwarf2/frame.c b/gdb/dwarf2/frame.c index 6d87e598345..0e74b8e7e68 100644 --- a/gdb/dwarf2/frame.c +++ b/gdb/dwarf2/frame.c @@ -137,24 +137,27 @@ typedef std::vector dwarf2_fde_table; struct comp_unit { /* Keep the bfd convenient. */ - bfd *abfd; + bfd *abfd = nullptr; - struct objfile *objfile; + struct objfile *objfile = nullptr; /* Pointer to the .debug_frame section loaded into memory. */ - const gdb_byte *dwarf_frame_buffer; + const gdb_byte *dwarf_frame_buffer = nullptr; /* Length of the loaded .debug_frame section. */ - bfd_size_type dwarf_frame_size; + bfd_size_type dwarf_frame_size = 0; /* Pointer to the .debug_frame section. */ - asection *dwarf_frame_section; + asection *dwarf_frame_section = nullptr; /* Base for DW_EH_PE_datarel encodings. */ - bfd_vma dbase; + bfd_vma dbase = 0; /* Base for DW_EH_PE_textrel encodings. */ - bfd_vma tbase; + bfd_vma tbase = 0; + + /* The FDE table. */ + dwarf2_fde_table fde_table; }; static struct dwarf2_fde *dwarf2_frame_find_fde (CORE_ADDR *pc, @@ -1467,7 +1470,7 @@ dwarf2_frame_cfa (struct frame_info *this_frame) return get_frame_base (this_frame); } -const struct objfile_key dwarf2_frame_objfile_data; +const struct objfile_key dwarf2_frame_objfile_data; @@ -1630,18 +1633,18 @@ dwarf2_frame_find_fde (CORE_ADDR *pc, CORE_ADDR *out_offset) { for (objfile *objfile : current_program_space->objfiles ()) { - dwarf2_fde_table *fde_table; CORE_ADDR offset; CORE_ADDR seek_pc; - fde_table = dwarf2_frame_objfile_data.get (objfile); - if (fde_table == NULL) + comp_unit *unit = dwarf2_frame_objfile_data.get (objfile); + if (unit == NULL) { dwarf2_build_frame_info (objfile); - fde_table = dwarf2_frame_objfile_data.get (objfile); + unit = dwarf2_frame_objfile_data.get (objfile); } - gdb_assert (fde_table != NULL); + gdb_assert (unit != NULL); + dwarf2_fde_table *fde_table = &unit->fde_table; if (fde_table->empty ()) continue; @@ -2120,14 +2123,11 @@ dwarf2_build_frame_info (struct objfile *objfile) const gdb_byte *frame_ptr; dwarf2_cie_table cie_table; dwarf2_fde_table fde_table; - dwarf2_fde_table *fde_table2; /* Build a minimal decoding of the DWARF2 compilation unit. */ - unit = XOBNEW (&objfile->objfile_obstack, comp_unit); + unit = new comp_unit; unit->abfd = objfile->obfd; unit->objfile = objfile; - unit->dbase = 0; - unit->tbase = 0; if (objfile->separate_debug_objfile_backlink == NULL) { @@ -2202,9 +2202,6 @@ dwarf2_build_frame_info (struct objfile *objfile) } } - /* Copy fde_table to obstack: it is needed at runtime. */ - fde_table2 = new dwarf2_fde_table; - if (!fde_table.empty ()) { struct dwarf2_fde *fde_prev = NULL; @@ -2249,13 +2246,13 @@ dwarf2_build_frame_info (struct objfile *objfile) && fde_prev->initial_location == fde->initial_location) continue; - fde_table2->push_back (fde); + unit->fde_table.push_back (fde); fde_prev = fde; } - fde_table2->shrink_to_fit (); + unit->fde_table.shrink_to_fit (); } - dwarf2_frame_objfile_data.set (objfile, fde_table2); + dwarf2_frame_objfile_data.set (objfile, unit); } /* Handle 'maintenance show dwarf unwinders'. */