From patchwork Sat Feb 15 16:54:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 38098 Received: (qmail 85320 invoked by alias); 15 Feb 2020 16:54:51 -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 85198 invoked by uid 89); 15 Feb 2020 16:54:50 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.5 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=prop, perobjfile, per-objfile, Temporarily X-HELO: gateway23.websitewelcome.com Received: from gateway23.websitewelcome.com (HELO gateway23.websitewelcome.com) (192.185.50.129) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 15 Feb 2020 16:54:49 +0000 Received: from cm14.websitewelcome.com (cm14.websitewelcome.com [100.42.49.7]) by gateway23.websitewelcome.com (Postfix) with ESMTP id E103A72D3 for ; Sat, 15 Feb 2020 10:54:47 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id 30iNjoLiTXVkQ30iNjBtTJ; Sat, 15 Feb 2020 10:54:47 -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=fPUZI1ukqJEjblbIv7x82zRh9d0VuZ3Sa1PnmlPS/bo=; b=HnX8i2LETPAgS9nRZkAQ+C6pDe cS76bwcKgF5vlF2hUedb/goyHdjzJi8nI2xdMPJXeJoX1ZG3UPoz/5cRy8shVWBIwG4Oe2ZzuDqon 5h+bOzJVJbmqxPnCbOd/p9xEU; Received: from 75-166-123-50.hlrn.qwest.net ([75.166.123.50]:45240 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1j30iN-000xcC-ML; Sat, 15 Feb 2020 09:54:47 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 05/14] Introduce dwarf2_unshareable and move die_type_hash Date: Sat, 15 Feb 2020 09:54:35 -0700 Message-Id: <20200215165444.32653-6-tom@tromey.com> In-Reply-To: <20200215165444.32653-1-tom@tromey.com> References: <20200215165444.32653-1-tom@tromey.com> The goal of this series is to share dwarf2_per_objfile across objfiles. However, this is difficult to do, because it has some members that are inherently per-objfile. This patch introduces a new "unshareable" object. The idea here is that we'll have one such object per objfile, and we'll temporarily update the pointer when needed. This is a bit ugly, but it's convenient, because it doesn't require a huge rewriting of the DWARF code. (I would be in favor of such a rewriting, but ... it's huge.) This patch further moves one such member, the DIE type hash, to the new structure. In this patch, the new object is managed by the dwarf2_per_objfile. However, by the end of the series, this will change. gdb/ChangeLog 2020-02-15 Tom Tromey * dwarf2/read.h (struct dwarf2_unshareable): New type. (struct dwarf2_per_objfile) : Move to dwarf2_unshareable. : New member. * dwarf2/read.c (dwarf2_per_objfile::dwarf2_per_objfile): Initialize "unshareable". (dwarf2_per_objfile::~dwarf2_per_objfile): Delete unshareable. (set_die_type, get_die_type_at_offset): Update. --- gdb/ChangeLog | 11 +++++++++++ gdb/dwarf2/read.c | 19 +++++++++++++------ gdb/dwarf2/read.h | 28 +++++++++++++++++++++++----- 3 files changed, 47 insertions(+), 11 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index a897b11693a..cb04eb19beb 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -1774,7 +1774,10 @@ dwarf2_per_objfile::dwarf2_per_objfile (struct objfile *objfile_, const dwarf2_debug_sections *names, bool can_copy_) : objfile (objfile_), - can_copy (can_copy_) + can_copy (can_copy_), + /* Temporarily just allocate one per objfile -- we don't have + sharing yet. */ + unshareable (new dwarf2_unshareable) { if (names == NULL) names = &dwarf2_elf_names; @@ -1796,6 +1799,8 @@ dwarf2_per_objfile::~dwarf2_per_objfile () for (signatured_type *sig_type : all_type_units) sig_type->per_cu.imported_symtabs_free (); + delete unshareable; + /* Everything else should be on the objfile obstack. */ } @@ -24434,8 +24439,8 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu) cu->per_cu->addr_type ())) add_dyn_prop (DYN_PROP_DATA_LOCATION, prop, type); - if (dwarf2_per_objfile->die_type_hash == NULL) - dwarf2_per_objfile->die_type_hash + if (dwarf2_per_objfile->unshareable->die_type_hash == NULL) + dwarf2_per_objfile->unshareable->die_type_hash = htab_up (htab_create_alloc (127, per_cu_offset_and_type_hash, per_cu_offset_and_type_eq, @@ -24445,7 +24450,8 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu) ofs.sect_off = die->sect_off; ofs.type = type; slot = (struct dwarf2_per_cu_offset_and_type **) - htab_find_slot (dwarf2_per_objfile->die_type_hash.get (), &ofs, INSERT); + htab_find_slot (dwarf2_per_objfile->unshareable->die_type_hash.get (), + &ofs, INSERT); if (*slot) complaint (_("A problem internal to GDB: DIE %s has type already set"), sect_offset_str (die->sect_off)); @@ -24465,13 +24471,14 @@ get_die_type_at_offset (sect_offset sect_off, struct dwarf2_per_cu_offset_and_type *slot, ofs; struct dwarf2_per_objfile *dwarf2_per_objfile = per_cu->dwarf2_per_objfile; - if (dwarf2_per_objfile->die_type_hash == NULL) + if (dwarf2_per_objfile->unshareable->die_type_hash == NULL) return NULL; ofs.per_cu = per_cu; ofs.sect_off = sect_off; slot = ((struct dwarf2_per_cu_offset_and_type *) - htab_find (dwarf2_per_objfile->die_type_hash.get (), &ofs)); + htab_find (dwarf2_per_objfile->unshareable->die_type_hash.get (), + &ofs)); if (slot) return slot->type; else diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h index 5fa8dec9bfb..06a0fa3a19a 100644 --- a/gdb/dwarf2/read.h +++ b/gdb/dwarf2/read.h @@ -66,6 +66,24 @@ struct dwarf2_queue_item enum language pretend_language; }; +/* Some DWARF data cannot (currently) be shared across objfiles. Such + data is stored in this object. + + dwarf2_per_objfile holds a pointer to an instance of this object. + This pointer is temporarily set when expanding CUs. This hackish + approach is due to the history of the DWARF reader. In the past, + all objects were stored per-objfile, and this object was introduced + in the process of separating out the shareable and per-objfile + state. */ + +struct dwarf2_unshareable +{ + /* Table mapping type DIEs to their struct type *. + This is NULL if not allocated yet. + The mapping is done via (CU/TU + DIE offset) -> type. */ + htab_up die_type_hash; +}; + /* Collection of data recorded per objfile. This hangs off of dwarf2_objfile_data_key. */ @@ -214,11 +232,6 @@ public: symbols. */ bool reading_partial_symbols = false; - /* Table mapping type DIEs to their struct type *. - This is NULL if not allocated yet. - The mapping is done via (CU/TU + DIE offset) -> type. */ - htab_up die_type_hash; - /* The CUs we recently read. */ std::vector just_read_cus; @@ -241,6 +254,11 @@ public: /* CUs that are queued to be read. */ std::queue queue; + + /* State that cannot be shared across objfiles. This is normally + nullptr and is temporarily set to the correct value at the entry + points of the reader. */ + dwarf2_unshareable *unshareable = nullptr; }; /* Get the dwarf2_per_objfile associated to OBJFILE. */