From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 51534 invoked by alias); 18 Feb 2020 11:23:05 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 51523 invoked by uid 89); 18 Feb 2020 11:23:04 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.7 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy=Everything, Table X-HELO: mail-qk1-f194.google.com Received: from mail-qk1-f194.google.com (HELO mail-qk1-f194.google.com) (209.85.222.194) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 18 Feb 2020 11:23:02 +0000 Received: by mail-qk1-f194.google.com with SMTP id b7so19081095qkl.7 for ; Tue, 18 Feb 2020 03:23:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=zul1Vi9d46SAq65Ib0GAIaqNanXigYuNh+UwZT6qNvk=; b=XpP3to5jh2MM9TCmMy5+kHXUE+ds19J7+9wvMVYcK8+/39LTxIQPQXmsu99d+qsJEq xj1pdpnjbNvzk/P6HsCTEUEbEgVXGbk+w4Bxi8O69RV/zpS8HkSzQAjaZbvamO1XXBsx jGDYFvO0CZWgQ5kdSm3wazIrpnYXzma/Ndzrz4j9enlIBbKtFIRy32aba2C9+kX0vkFv fyF/DdYpEeAWMZcqGldUWXT1kC2pIcFCC2iKAnn+hMzE+79LULw8NCs8Od+Ce/6/yDMk xC9sxs/MnAryYmqvzKhgKqmZ9dJkg9txlPGY1TsJQBvklauR1Evg9B4BDggWTOUInegC Bm5A== Return-Path: Received: from [192.168.0.185] ([179.177.236.155]) by smtp.gmail.com with ESMTPSA id n123sm1696200qke.58.2020.02.18.03.22.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 18 Feb 2020 03:22:59 -0800 (PST) Subject: Re: [PATCH 05/14] Introduce dwarf2_unshareable and move die_type_hash To: Tom Tromey , gdb-patches@sourceware.org References: <20200215165444.32653-1-tom@tromey.com> <20200215165444.32653-6-tom@tromey.com> From: Luis Machado Message-ID: <8b5bda21-39f2-a7ca-d3e9-b5fb938e7099@linaro.org> Date: Tue, 18 Feb 2020 11:23:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <20200215165444.32653-6-tom@tromey.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2020-02/txt/msg00706.txt.bz2 Just one nit... On 2/15/20 1:54 PM, Tom Tromey wrote: > 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. "This is nullptr" > + 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. */ >