From patchwork Thu Jan 23 00:57:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 37506 Received: (qmail 83368 invoked by alias); 23 Jan 2020 00:57:57 -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 81399 invoked by uid 89); 23 Jan 2020 00:57:42 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.2 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= X-HELO: gateway36.websitewelcome.com Received: from gateway36.websitewelcome.com (HELO gateway36.websitewelcome.com) (192.185.193.12) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 23 Jan 2020 00:57:30 +0000 Received: from cm13.websitewelcome.com (cm13.websitewelcome.com [100.42.49.6]) by gateway36.websitewelcome.com (Postfix) with ESMTP id 6873F407358A1 for ; Wed, 22 Jan 2020 18:10:22 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id uQoLizIHxERZguQoLirDFJ; Wed, 22 Jan 2020 18:57:29 -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=TGsZdNB6fJ9bNexku/KrbBxKIUVBnTr1jqoCTcVnMgY=; b=LlC+gLqanjosn2bidCLpzBSVJc +r4rV96AX/IyX5OUImE7y8FmoIXIdjhgGYuBEW2meuWJbl3oUoi08JMpdLzrwDPKNXLYdJy9hKL5F ZpYAqv/rtUUFgGfVwTLd7CTfw; Received: from 75-166-123-50.hlrn.qwest.net ([75.166.123.50]:40832 helo=bapiya.Home) by box5379.bluehost.com with esmtpa (Exim 4.92) (envelope-from ) id 1iuQoK-004KqG-W5; Wed, 22 Jan 2020 17:57:29 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 38/38] Remove "keep" parameter from cutu_reader constructor Date: Wed, 22 Jan 2020 17:57:10 -0700 Message-Id: <20200123005710.7978-39-tom@tromey.com> In-Reply-To: <20200123005710.7978-1-tom@tromey.com> References: <20200123005710.7978-1-tom@tromey.com> cutu_reader has a "keep" parameter, which is used to decide what to do with a new CU when the reader is destroyed. Most code does not try to preserve the CU, so this patch removes this parameter and instead adds a new method that users can call to preserve the CU on the chain. 2020-01-22 Tom Tromey * dwarf2/read.c (class cutu_reader) : Remove "keep" parameter. : Declare method. : Remove member. <~cutu_reader>: Default. (cutu_reader::init_tu_and_read_dwo_dies): Update. (cutu_reader::cutu_reader): Update. (cutu_reader::keep): Rename from ~cutu_reader. (process_psymtab_comp_unit, build_type_psymtabs_1) (process_skeletonless_type_unit, load_partial_comp_unit) (load_full_comp_unit, dwarf2_read_addr_index) (read_signatured_type): Update. Change-Id: I859b1c64313569d76d46317c14e9b077ebc3a27b --- gdb/ChangeLog | 15 +++++++++++++ gdb/dwarf2/read.c | 55 +++++++++++++++++++++++++---------------------- 2 files changed, 44 insertions(+), 26 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index d1a78afd8cf..754b752dc5d 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -881,14 +881,14 @@ public: cutu_reader (struct dwarf2_per_cu_data *this_cu, struct abbrev_table *abbrev_table, - int use_existing_cu, int keep, + int use_existing_cu, bool skip_partial); explicit cutu_reader (struct dwarf2_per_cu_data *this_cu, struct dwarf2_cu *parent_cu = nullptr, struct dwo_file *dwo_file = nullptr); - ~cutu_reader (); + ~cutu_reader () = default; DISABLE_COPY_AND_ASSIGN (cutu_reader); @@ -896,12 +896,15 @@ public: struct die_info *comp_unit_die = nullptr; bool dummy_p = false; + /* Release the new CU, putting it on the chain. This cannot be done + for dummy CUs. */ + void keep (); + private: void init_tu_and_read_dwo_dies (struct dwarf2_per_cu_data *this_cu, - int use_existing_cu, int keep); + int use_existing_cu); struct dwarf2_per_cu_data *m_this_cu; - int m_keep = 0; std::unique_ptr m_new_cu; /* The ordinary abbreviation table. */ @@ -6730,7 +6733,7 @@ lookup_dwo_unit (struct dwarf2_per_cu_data *this_cu, void cutu_reader::init_tu_and_read_dwo_dies (struct dwarf2_per_cu_data *this_cu, - int use_existing_cu, int keep) + int use_existing_cu) { struct signatured_type *sig_type; struct die_reader_specs reader; @@ -6778,19 +6781,14 @@ cutu_reader::init_tu_and_read_dwo_dies (struct dwarf2_per_cu_data *this_cu, This is an optimization for when we already have the abbrev table. If USE_EXISTING_CU is non-zero, and THIS_CU->cu is non-NULL, then use it. - Otherwise, a new CU is allocated with xmalloc. - - If KEEP is non-zero, then if we allocated a dwarf2_cu we add it to - read_in_chain. Otherwise the dwarf2_cu data is freed at the - end. */ + Otherwise, a new CU is allocated with xmalloc. */ cutu_reader::cutu_reader (struct dwarf2_per_cu_data *this_cu, struct abbrev_table *abbrev_table, - int use_existing_cu, int keep, + int use_existing_cu, bool skip_partial) : die_reader_specs {}, - m_this_cu (this_cu), - m_keep (keep) + m_this_cu (this_cu) { struct dwarf2_per_objfile *dwarf2_per_objfile = this_cu->dwarf2_per_objfile; struct objfile *objfile = dwarf2_per_objfile->objfile; @@ -6810,9 +6808,6 @@ cutu_reader::cutu_reader (struct dwarf2_per_cu_data *this_cu, this_cu->is_debug_types ? "type" : "comp", sect_offset_str (this_cu->sect_off)); - if (use_existing_cu) - gdb_assert (keep); - /* If we're reading a TU directly from a DWO file, including a virtual DWO file (instead of going through the stub), short-circuit all of this. */ if (this_cu->reading_dwo_directly) @@ -6820,7 +6815,7 @@ cutu_reader::cutu_reader (struct dwarf2_per_cu_data *this_cu, /* Narrow down the scope of possibilities to have to understand. */ gdb_assert (this_cu->is_debug_types); gdb_assert (abbrev_table == NULL); - init_tu_and_read_dwo_dies (this_cu, use_existing_cu, keep); + init_tu_and_read_dwo_dies (this_cu, use_existing_cu); return; } @@ -6976,10 +6971,12 @@ cutu_reader::cutu_reader (struct dwarf2_per_cu_data *this_cu, } } -cutu_reader::~cutu_reader () +void +cutu_reader::keep () { /* Done, clean up. */ - if (m_new_cu != NULL && m_keep && !dummy_p) + gdb_assert (!dummy_p); + if (m_new_cu != NULL) { struct dwarf2_per_objfile *dwarf2_per_objfile = m_this_cu->dwarf2_per_objfile; @@ -7384,7 +7381,7 @@ process_psymtab_comp_unit (struct dwarf2_per_cu_data *this_cu, if (this_cu->cu != NULL) free_one_cached_comp_unit (this_cu); - cutu_reader reader (this_cu, NULL, 0, 0, false); + cutu_reader reader (this_cu, NULL, 0, false); if (reader.dummy_p) { @@ -7553,7 +7550,7 @@ build_type_psymtabs_1 (struct dwarf2_per_objfile *dwarf2_per_objfile) } cutu_reader reader (&tu.sig_type->per_cu, abbrev_table.get (), - 0, 0, false); + 0, false); if (!reader.dummy_p) build_type_psymtabs_reader (&reader, reader.info_ptr, reader.comp_unit_die); @@ -7661,7 +7658,7 @@ process_skeletonless_type_unit (void **slot, void *info) *slot = entry; /* This does the job that build_type_psymtabs_1 would have done. */ - cutu_reader reader (&entry->per_cu, NULL, 0, 0, false); + cutu_reader reader (&entry->per_cu, NULL, 0, false); if (!reader.dummy_p) build_type_psymtabs_reader (&reader, reader.info_ptr, reader.comp_unit_die); @@ -7790,7 +7787,7 @@ dwarf2_build_psymtabs_hard (struct dwarf2_per_objfile *dwarf2_per_objfile) static void load_partial_comp_unit (struct dwarf2_per_cu_data *this_cu) { - cutu_reader reader (this_cu, NULL, 1, 1, false); + cutu_reader reader (this_cu, NULL, 1, false); if (!reader.dummy_p) { @@ -7802,6 +7799,8 @@ load_partial_comp_unit (struct dwarf2_per_cu_data *this_cu) If not, there's no more debug_info for this comp unit. */ if (reader.comp_unit_die->has_children) load_partial_dies (&reader, reader.info_ptr, 0); + + reader.keep (); } } @@ -8937,7 +8936,7 @@ load_full_comp_unit (struct dwarf2_per_cu_data *this_cu, { gdb_assert (! this_cu->is_debug_types); - cutu_reader reader (this_cu, NULL, 1, 1, skip_partial); + cutu_reader reader (this_cu, NULL, 1, skip_partial); if (reader.dummy_p) return; @@ -8968,6 +8967,8 @@ load_full_comp_unit (struct dwarf2_per_cu_data *this_cu, Similarly, if we do not read the producer, we can not apply producer-specific interpretation. */ prepare_one_comp_unit (cu, cu->dies, pretend_language); + + reader.keep (); } /* Add a DIE to the delayed physname list. */ @@ -18961,7 +18962,7 @@ dwarf2_read_addr_index (struct dwarf2_per_cu_data *per_cu, } else { - cutu_reader reader (per_cu, NULL, 0, 0, false); + cutu_reader reader (per_cu, NULL, 0, false); addr_base = reader.cu->addr_base; addr_size = reader.cu->header.addr_size; } @@ -22791,7 +22792,7 @@ read_signatured_type (struct signatured_type *sig_type) gdb_assert (per_cu->is_debug_types); gdb_assert (per_cu->cu == NULL); - cutu_reader reader (per_cu, NULL, 0, 1, false); + cutu_reader reader (per_cu, NULL, 0, false); if (!reader.dummy_p) { @@ -22822,6 +22823,8 @@ read_signatured_type (struct signatured_type *sig_type) correctly. Similarly, if we do not read the producer, we can not apply producer-specific interpretation. */ prepare_one_comp_unit (cu, cu->dies, language_minimal); + + reader.keep (); } sig_type->per_cu.tu_read = 1;