From patchwork Fri Apr 7 15:25:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 67498 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 C25483857C44 for ; Fri, 7 Apr 2023 15:25:56 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from progateway7-pub.mail.pro1.eigbox.com (gproxy5-pub.mail.unifiedlayer.com [67.222.38.55]) by sourceware.org (Postfix) with ESMTPS id 156183858C83 for ; Fri, 7 Apr 2023 15:25:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 156183858C83 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw10.mail.unifiedlayer.com (unknown [10.0.90.125]) by progateway7.mail.pro1.eigbox.com (Postfix) with ESMTP id 7452610047419 for ; Fri, 7 Apr 2023 15:25:41 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id kny9poKFOFhsVkny9pK5ps; Fri, 07 Apr 2023 15:25:41 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=ELjDb3VC c=1 sm=1 tr=0 ts=643035f5 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10:nop_charset_1 a=dKHAf1wccvYA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=CCpqsmhAAAAA:8 a=XINXnd7XTCThitrW7pYA:9 a=QEXdDO2ut3YA:10:nop_charset_2 a=ul9cdbp4aOFLsgKbc677:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc: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=CapfTj95Xc2HEy4ueCKkDUvS+phIfFO49A1AjvNyptE=; b=su586iJBCf8/z4/pthP0gCnK3F X6DDRHHvZVoWU45qfY5X+EDnuSM36ejCOFuKDqJHJ/Jei5NfiDuMCx+IuzFPEWGa/iCUjJ6+78TC4 mcpERQZh8PtG9CqN+K6af/jkl; Received: from 75-166-159-36.hlrn.qwest.net ([75.166.159.36]:60392 helo=[192.168.0.21]) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pkny9-001hDU-8p for gdb-patches@sourceware.org; Fri, 07 Apr 2023 09:25:41 -0600 From: Tom Tromey Date: Fri, 07 Apr 2023 09:25:38 -0600 Subject: [PATCH 06/19] Convert dwarf2/macro.c to new hash table MIME-Version: 1.0 Message-Id: <20230407-t-robin-hood-hash-v1-6-900d93ef1510@tromey.com> References: <20230407-t-robin-hood-hash-v1-0-900d93ef1510@tromey.com> In-Reply-To: <20230407-t-robin-hood-hash-v1-0-900d93ef1510@tromey.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.1 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: 75.166.159.36 X-Source-L: No X-Exim-ID: 1pkny9-001hDU-8p X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-159-36.hlrn.qwest.net ([192.168.0.21]) [75.166.159.36]:60392 X-Source-Auth: tom+tromey.com X-Email-Count: 7 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3026.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP 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.29 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 Sender: "Gdb-patches" This converts dwarf2/macro.c to use the new hash table. --- gdb/dwarf2/macro.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/gdb/dwarf2/macro.c b/gdb/dwarf2/macro.c index 78cce2d69eb..7a3aa5ffee3 100644 --- a/gdb/dwarf2/macro.c +++ b/gdb/dwarf2/macro.c @@ -445,7 +445,8 @@ dwarf_decode_macro_bytes (dwarf2_per_objfile *per_objfile, struct dwarf2_section_info *str_section, struct dwarf2_section_info *str_offsets_section, gdb::optional str_offsets_base, - htab_t include_hash, struct dwarf2_cu *cu) + gdb::hash_set &include_hash, + struct dwarf2_cu *cu) { struct objfile *objfile = per_objfile->objfile; enum dwarf_macro_record_type macinfo_type; @@ -720,7 +721,6 @@ dwarf_decode_macro_bytes (dwarf2_per_objfile *per_objfile, case DW_MACRO_import_sup: { LONGEST offset; - void **slot; bfd *include_bfd = abfd; const struct dwarf2_section_info *include_section = section; const gdb_byte *include_mac_end = mac_end; @@ -744,9 +744,8 @@ dwarf_decode_macro_bytes (dwarf2_per_objfile *per_objfile, } new_mac_ptr = include_section->buffer + offset; - slot = htab_find_slot (include_hash, new_mac_ptr, INSERT); - if (*slot != NULL) + if (!include_hash.insert (new_mac_ptr).second) { /* This has actually happened; see http://sourceware.org/bugzilla/show_bug.cgi?id=13568. */ @@ -755,8 +754,6 @@ dwarf_decode_macro_bytes (dwarf2_per_objfile *per_objfile, } else { - *slot = (void *) new_mac_ptr; - dwarf_decode_macro_bytes (per_objfile, builder, include_bfd, new_mac_ptr, include_mac_end, current_file, lh, section, @@ -764,7 +761,7 @@ dwarf_decode_macro_bytes (dwarf2_per_objfile *per_objfile, str_section, str_offsets_section, str_offsets_base, include_hash, cu); - htab_remove_elt (include_hash, (void *) new_mac_ptr); + include_hash.erase (new_mac_ptr); } } break; @@ -813,7 +810,6 @@ dwarf_decode_macros (dwarf2_per_objfile *per_objfile, struct macro_source_file *current_file = 0; enum dwarf_macro_record_type macinfo_type; const gdb_byte *opcode_definitions[256]; - void **slot; abfd = section->get_bfd_owner (); @@ -958,14 +954,11 @@ dwarf_decode_macros (dwarf2_per_objfile *per_objfile, command-line macro definitions/undefinitions. This flag is unset when we reach the first DW_MACINFO_start_file entry. */ - htab_up include_hash (htab_create_alloc (1, htab_hash_pointer, - htab_eq_pointer, - NULL, xcalloc, xfree)); + gdb::hash_set include_hash; mac_ptr = section->buffer + offset; - slot = htab_find_slot (include_hash.get (), mac_ptr, INSERT); - *slot = (void *) mac_ptr; + include_hash.insert (mac_ptr); dwarf_decode_macro_bytes (per_objfile, builder, abfd, mac_ptr, mac_end, current_file, lh, section, section_is_gnu, 0, offset_size, str_section, str_offsets_section, - str_offsets_base, include_hash.get (), cu); + str_offsets_base, include_hash, cu); }