From patchwork Fri Jan 19 20:13:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 84467 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9DF623861000 for ; Fri, 19 Jan 2024 20:14:12 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta38.uswest2.a.cloudfilter.net (omta38.uswest2.a.cloudfilter.net [35.89.44.37]) by sourceware.org (Postfix) with ESMTPS id D22143858C2A for ; Fri, 19 Jan 2024 20:13:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D22143858C2A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D22143858C2A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.37 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705695229; cv=none; b=rTm9ffA94OFwmlJy95YTCyARLzruVammBeE1xghjweTk2NDIj2VgmCii9ZZW90OfdbYbxRJ1coiAZg1qQU1vi6kmU5R5G+e46juMeoPUS5KnpDDtem2Umafp5wgKIDVu05MgZEtkaFkfU8aFpwEqWI+9j4xP9SnNZTiVKxSv3Zc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705695229; c=relaxed/simple; bh=sci0aqHcyKaSgl1dc6gh7Oaa3N5/ajhxX3gk2XZvqLo=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=d4XZBE+5FMH4MH890Tp7iTp/BzPASut9CgrfIX+jte00RaEAP/1ibirFwzZ0UJP70WXq6aGkWRKEe9VuLonDCbDbWfmD+xCHeX+JtErXtk/YDWAYne1cn2KoiDE9Tfsu+P5eVyTYmSXYkcdgBsaWXPDGPfm5Yftk06LNu2etDDA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5005a.ext.cloudfilter.net ([10.0.29.234]) by cmsmtp with ESMTPS id QhvArjmQcoMN9QvFJrYjgz; Fri, 19 Jan 2024 20:13:45 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id QvFIrMdK3fs4hQvFIrFxAK; Fri, 19 Jan 2024 20:13:44 +0000 X-Authority-Analysis: v=2.4 cv=Q6TBXq6a c=1 sm=1 tr=0 ts=65aad7f8 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dEuoMetlWLkA:10 a=Qbun_eYptAEA:10 a=CCpqsmhAAAAA:8 a=LrZztbY9fZCjSmGSVzYA:9 a=ul9cdbp4aOFLsgKbc677:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Subject: Cc:To:From:Sender:Reply-To:Content-Type:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=Ds2GstO0SccSJjTOraD08prRG/eTL6kojvgmlKl8s8M=; b=MPj3/Cnh2h3j0/dzrik0tJKS44 SBZk+nAagqowesqgZDLTCltL+FEnV7ccuuCgW3njRSBz/uxPwjyqLkeSiZNUsRd0o0oeoxfc2qzZd E7nOk3j/e7W0ljfVLSh20ROTt; Received: from 97-122-68-157.hlrn.qwest.net ([97.122.68.157]:34202 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1rQvFI-004CIO-00; Fri, 19 Jan 2024 13:13:44 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Simplify DWARF symtab inclusion handling Date: Fri, 19 Jan 2024 13:13:34 -0700 Message-ID: <20240119201334.536259-1-tom@tromey.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.122.68.157 X-Source-L: No X-Exim-ID: 1rQvFI-004CIO-00 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-68-157.hlrn.qwest.net (localhost.localdomain) [97.122.68.157]:34202 X-Source-Auth: tom+tromey.com X-Email-Count: 1 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfCsWSHhNYzMaS4XTIt2HTlZ7lKq9CpNno2a28/NbYye+VMY0NQTz6fXNPLn8c83SDuxE2ffag80N0o3qRXLUc5c7mvqJHoWH3g9NFwE6NjM8Rn1sP1AA 96X3gwdDBJ/IscZrmip7fhT9Y1u0eTIIMSjL/K/uj2itvOkLdBo1bWgASxZNIs6CH6eaw+0LgBQctXAvPG2nRLKdCuCMuZonOJY= X-Spam-Status: No, score=-3022.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org In the past, dwarf2_per_cu_data was allocated using malloc, so special handling was needed for the vector used for symtab handling. We changed this to use 'new' a while back, so this code can now be greatly simplified. Regression tested on x86-64 Fedora 38. --- gdb/dwarf2/read.c | 34 +++++++++++++--------------------- gdb/dwarf2/read.h | 46 +++------------------------------------------- 2 files changed, 16 insertions(+), 64 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 7691fe0050b..5230358c4a7 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -1280,10 +1280,7 @@ dwarf2_per_bfd::~dwarf2_per_bfd () index_table->wait_completely (); for (auto &per_cu : all_units) - { - per_cu->imported_symtabs_free (); - per_cu->free_cached_file_names (); - } + per_cu->free_cached_file_names (); /* Everything else should be on this->obstack. */ } @@ -6103,13 +6100,10 @@ recursively_compute_inclusions (std::vector *result, } } - if (!per_cu->imported_symtabs_empty ()) - for (dwarf2_per_cu_data *ptr : *per_cu->imported_symtabs) - { - recursively_compute_inclusions (result, all_children, - all_type_symtabs, ptr, per_objfile, - cust); - } + for (dwarf2_per_cu_data *ptr : per_cu->imported_symtabs) + recursively_compute_inclusions (result, all_children, + all_type_symtabs, ptr, per_objfile, + cust); } /* Compute the compunit_symtab 'includes' fields for the compunit_symtab of @@ -6121,7 +6115,7 @@ compute_compunit_symtab_includes (dwarf2_per_cu_data *per_cu, { gdb_assert (! per_cu->is_debug_types); - if (!per_cu->imported_symtabs_empty ()) + if (!per_cu->imported_symtabs.empty ()) { int len; std::vector result_symtabs; @@ -6138,12 +6132,10 @@ compute_compunit_symtab_includes (dwarf2_per_cu_data *per_cu, htab_eq_pointer, NULL, xcalloc, xfree)); - for (dwarf2_per_cu_data *ptr : *per_cu->imported_symtabs) - { - recursively_compute_inclusions (&result_symtabs, all_children.get (), - all_type_symtabs.get (), ptr, - per_objfile, cust); - } + for (dwarf2_per_cu_data *ptr : per_cu->imported_symtabs) + recursively_compute_inclusions (&result_symtabs, all_children.get (), + all_type_symtabs.get (), ptr, + per_objfile, cust); /* Now we have a transitive closure of all the included symtabs. */ len = result_symtabs.size (); @@ -6391,7 +6383,7 @@ process_imported_unit_die (struct die_info *die, struct dwarf2_cu *cu) load_full_comp_unit (per_cu, per_objfile, per_objfile->get_cu (per_cu), false, cu->lang ()); - cu->per_cu->imported_symtabs_push (per_cu); + cu->per_cu->imported_symtabs.push_back (per_cu); } } @@ -9651,7 +9643,7 @@ queue_and_load_dwo_tu (void **slot, void *info) if (maybe_queue_comp_unit (NULL, sig_type, cu->per_objfile, cu->lang ())) load_full_type_unit (sig_type, cu->per_objfile); - cu->per_cu->imported_symtabs_push (sig_type); + cu->per_cu->imported_symtabs.push_back (sig_type); } return 1; @@ -20702,7 +20694,7 @@ follow_die_sig_1 (struct die_info *src_die, struct signatured_type *sig_type, if (per_objfile->per_bfd->index_table != NULL && !per_objfile->per_bfd->index_table->version_check ()) { - (*ref_cu)->per_cu->imported_symtabs_push (sig_cu->per_cu); + (*ref_cu)->per_cu->imported_symtabs.push_back (sig_cu->per_cu); } *ref_cu = sig_cu; diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h index 66c6fe3fe87..ea60218e494 100644 --- a/gdb/dwarf2/read.h +++ b/gdb/dwarf2/read.h @@ -227,10 +227,7 @@ struct dwarf2_per_cu_data NOTE: This points into dwarf2_per_objfile->per_bfd->quick_file_names_table. */ struct quick_file_names *file_names = nullptr; - /* The CUs we import using DW_TAG_imported_unit. This is filled in - while reading psymtabs, used to compute the psymtab dependencies, - and then cleared. Then it is filled in again while reading full - symbols, and only deleted when the objfile is destroyed. + /* The CUs we import using DW_TAG_imported_unit. This is also used to work around a difference between the way gold generates .gdb_index version <=7 and the way gdb does. Arguably this @@ -244,45 +241,8 @@ struct dwarf2_per_cu_data .gdb_index version <=7 this also records the TUs that the CU referred to. Concurrently with this change gdb was modified to emit version 8 indices so we only pay a price for gold generated indices. - http://sourceware.org/bugzilla/show_bug.cgi?id=15021. - - This currently needs to be a public member due to how - dwarf2_per_cu_data is allocated and used. Ideally in future things - could be refactored to make this private. Until then please try to - avoid direct access to this member, and instead use the helper - functions above. */ - std::vector *imported_symtabs = nullptr; - - /* Return true of IMPORTED_SYMTABS is empty or not yet allocated. */ - bool imported_symtabs_empty () const - { - return (imported_symtabs == nullptr || imported_symtabs->empty ()); - } - - /* Push P to the back of IMPORTED_SYMTABS, allocated IMPORTED_SYMTABS - first if required. */ - void imported_symtabs_push (dwarf2_per_cu_data *p) - { - if (imported_symtabs == nullptr) - imported_symtabs = new std::vector ; - imported_symtabs->push_back (p); - } - - /* Return the size of IMPORTED_SYMTABS if it is allocated, otherwise - return 0. */ - size_t imported_symtabs_size () const - { - if (imported_symtabs == nullptr) - return 0; - return imported_symtabs->size (); - } - - /* Delete IMPORTED_SYMTABS and set the pointer back to nullptr. */ - void imported_symtabs_free () - { - delete imported_symtabs; - imported_symtabs = nullptr; - } + http://sourceware.org/bugzilla/show_bug.cgi?id=15021. */ + std::vector imported_symtabs; /* Get the header of this per_cu, reading it if necessary. */ const comp_unit_head *get_header () const;