From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 35488 invoked by alias); 19 Feb 2020 04:47:19 -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 35479 invoked by uid 89); 19 Feb 2020 04:47:19 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-7.7 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_1,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.1 spammy=states X-HELO: simark.ca Received: from simark.ca (HELO simark.ca) (158.69.221.121) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 19 Feb 2020 04:47:18 +0000 Received: from [10.0.0.11] (unknown [192.222.164.54]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 585081E47D; Tue, 18 Feb 2020 23:47:16 -0500 (EST) Subject: Re: [PATCH 08/14] Remove symtab links from dwarf2_psymtab and dwarf2_per_cu_quick_data To: Luis Machado , Tom Tromey , gdb-patches@sourceware.org References: <20200215165444.32653-1-tom@tromey.com> <20200215165444.32653-9-tom@tromey.com> <6767060e-cc61-1180-de10-df5652d606bb@linaro.org> From: Simon Marchi Message-ID: <2314c5d2-55f7-1ab3-b92c-862b945cc68d@simark.ca> Date: Wed, 19 Feb 2020 04:47:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.2 MIME-Version: 1.0 In-Reply-To: <6767060e-cc61-1180-de10-df5652d606bb@linaro.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2020-02/txt/msg00762.txt.bz2 >> @@ -2332,9 +2328,9 @@ dw2_do_instantiate_symtab (struct dwarf2_per_cu_data *per_cu, bool skip_partial) >> with the dwarf queue empty. */ >> dwarf2_queue_guard q_guard (dwarf2_per_objfile); >> >> - if (dwarf2_per_objfile->using_index >> - ? per_cu->v.quick->compunit_symtab == NULL >> - : (per_cu->v.psymtab == NULL || !per_cu->v.psymtab->readin)) >> + gdb::optional &symtab >> + = dwarf2_per_objfile->unshareable->symtabs[per_cu->index]; >> + if (!symtab.has_value ()) > > I noticed the above sequence gets repeated a lot throughout the code. > Can we turn it into a function/method and reduce the duplication? I was going to say the same thing, a getter on dwarf2_unshareable would be nice. Since this is a new data type, we might as well design it right from the start. >> @@ -82,6 +82,10 @@ struct dwarf2_unshareable >> This is NULL if not allocated yet. >> The mapping is done via (CU/TU + DIE offset) -> type. */ >> htab_up die_type_hash; >> + >> + /* Hold the corresponding compunit_symtab for each CU or TU. This >> + is indexed by dwarf2_per_cu_data::index. */ >> + std::vector> symtabs; Having pointers in an optional gives us three states: 1- not instantiated 2- instantiated but NULL 3- instantiated and not NULL Do we actually need the distinction between 1 and 2 here? If not, I think the optional doesn't bring much and just makes the code more complicated. Simon