From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id B83753857BA5 for ; Mon, 4 Nov 2024 18:30:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B83753857BA5 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=efficios.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B83753857BA5 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730745029; cv=none; b=lsVqIBop7y7/86dWxneH+4Lpikd4UYmJPM1wzC4S+OHpUUP90Gt84x8gNArqdp6HWS51IZ4IV8a0wGqOV6dFfL8z1yALN9iYuycC2xUA02SVE44Yu4+Yq+MwQ+LRPtbYoPMtR3S0VQhKY6vHoOqbprxzIsN1I1UesgnjjBC7un4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730745029; c=relaxed/simple; bh=JWPMk9MvSD0OlTfkF8GsyqKpAb5B2bIv5QX7a55NHL4=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=EVSYdSiumsJy72xDfJxjZU1bVLjvTa/qPjKGvilJ0hMGq1zEVaQ8fHhd+BObNmN8gx7Ji6pZk28eP7L42wcD0W9UVdji8tTbjXkVoDki84VGsrkBK611yzTz10m8Ifqp9aKv3Olg7twNvPX+WJ/4SbIjnwx7UKOrrugatnv7wUs= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by simark.ca (Postfix, from userid 112) id 69E461E5ED; Mon, 4 Nov 2024 13:30:26 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-Spam-Level: X-Spam-Status: No, score=-1173.4 required=5.0 tests=BAYES_00,GIT_PATCH_0,KAM_DMARC_NONE,KAM_DMARC_STATUS,SPF_HELO_PASS,SPF_SOFTFAIL,TXREP autolearn=ham autolearn_force=no version=3.4.6 Received: from smarchi-efficios.internal.efficios.com (96-127-217-162.qc.cable.ebox.net [96.127.217.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 4AE7C1E5DF; Mon, 4 Nov 2024 13:30:21 -0500 (EST) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi , Tom Tromey Subject: [PATCH v5 09/25] Convert dwarf2/macro.c to new hash table Date: Mon, 4 Nov 2024 13:27:40 -0500 Message-ID: <20241104182817.89835-10-simon.marchi@efficios.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241104182817.89835-1-simon.marchi@efficios.com> References: <20241104182817.89835-1-simon.marchi@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: This converts dwarf2/macro.c to use the new hash table. Change-Id: I6af0d1178e2db330fe3a89d57763974145ed17c4 Co-Authored-By: Tom Tromey --- gdb/dwarf2/macro.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/gdb/dwarf2/macro.c b/gdb/dwarf2/macro.c index 5371acf3d59c..aab855ac28a6 100644 --- a/gdb/dwarf2/macro.c +++ b/gdb/dwarf2/macro.c @@ -35,6 +35,7 @@ #include "macrotab.h" #include "complaints.h" #include "objfiles.h" +#include "gdbsupport/unordered_set.h" static void dwarf2_macro_malformed_definition_complaint (const char *arg1) @@ -422,7 +423,8 @@ dwarf_decode_macro_bytes (dwarf2_per_objfile *per_objfile, struct dwarf2_section_info *str_section, struct dwarf2_section_info *str_offsets_section, std::optional str_offsets_base, - htab_t include_hash, struct dwarf2_cu *cu) + gdb::unordered_set &include_hash, + struct dwarf2_cu *cu) { struct objfile *objfile = per_objfile->objfile; enum dwarf_macro_record_type macinfo_type; @@ -697,7 +699,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; @@ -719,9 +720,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. */ @@ -730,8 +730,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, @@ -739,7 +737,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; @@ -788,7 +786,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 (); @@ -933,14 +930,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::unordered_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); } -- 2.47.0