From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id EYGnNQ3CmGmiKQMAWB0awg (envelope-from ) for ; Fri, 20 Feb 2026 15:20:29 -0500 Received: by simark.ca (Postfix, from userid 112) id D4D9F1E0E1; Fri, 20 Feb 2026 15:20:29 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (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 ESMTPS id 1B5D11E08D for ; Fri, 20 Feb 2026 15:20:29 -0500 (EST) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 84C354BAD17F for ; Fri, 20 Feb 2026 20:20:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 84C354BAD17F Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id E6E854B9DB6E for ; Fri, 20 Feb 2026 20:20:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E6E854B9DB6E 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 E6E854B9DB6E 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=1771618806; cv=none; b=gq5HGEE02yEdREWCw8U8kS9YngouWaE/saQuzzFEn/5lfLlMxWwC/j3qFSKWIq0YHD8JX+iWEQYjp9t7KDuohKrS+GiKhZCXA6vkqeM1c0+SDmE9tXI8e179l0uyiny1FiebTfct9MI7Ot79Ns7jEeBYAyvsU9Z32lvzIfepYhI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1771618806; c=relaxed/simple; bh=NHPIIxuf+cgA6MvNnBCcS/3Fd721A22BUtfio0tR7mo=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=L8vC+cnV4m9LxWYBIpFGQeVhdBOBhJlJv4vDqguZdw0UyvpuQWK/jW9q1HYQXEqf6SU3bbnb7KtkdLDko+CNnZGo1hyYokGWFxtBzekLqbNIDSQ0sDkMvJaRftKpf8xiMOMFYJ+TCFyzXtIVacKYlz2PmjS7nS+JYZyN2ONKL0w= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E6E854B9DB6E Received: by simark.ca (Postfix) id 7E6431E09A; Fri, 20 Feb 2026 15:20:03 -0500 (EST) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 2/3] gdb/dwarf: use enumerate in index-write.c Date: Fri, 20 Feb 2026 15:19:42 -0500 Message-ID: <20260220202002.860008-2-simon.marchi@efficios.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260220202002.860008-1-simon.marchi@efficios.com> References: <20260220202002.860008-1-simon.marchi@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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~public-inbox=simark.ca@sourceware.org From: Simon Marchi Use the new enumerate util to get rid of some manual counters. Change-Id: I0573f0890e9b775a5181d8c0d435bb7ba661cae4 --- gdb/dwarf2/index-write.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c index c4e75898f4c0..66beff663072 100644 --- a/gdb/dwarf2/index-write.c +++ b/gdb/dwarf2/index-write.c @@ -24,6 +24,7 @@ #include "cli/cli-decode.h" #include "exceptions.h" #include "gdbsupport/byte-vector.h" +#include "gdbsupport/enumerate.h" #include "gdbsupport/filestuff.h" #include "gdbsupport/gdb_unlinker.h" #include "gdbsupport/pathstuff.h" @@ -1461,32 +1462,28 @@ write_debug_names (dwarf2_per_bfd *per_bfd, cooked_index *table, unit_lists units = get_unit_lists (*per_bfd); debug_names nametable (per_bfd, dwarf5_is_dwarf64, dwarf5_byte_order); data_buf comp_unit_list; - int comp_unit_counter = 0; - for (const auto per_cu : units.comp) + for (auto [i, per_cu] : gdb::enumerate (units.comp)) { - nametable.add_cu (per_cu, comp_unit_counter); + nametable.add_cu (per_cu, i); comp_unit_list.append_uint (nametable.dwarf5_offset_size (), dwarf5_byte_order, to_underlying (per_cu->sect_off ())); - comp_unit_counter++; } data_buf type_unit_list; - int type_unit_counter = 0; - for (const auto per_cu : units.type) + for (auto [i, per_cu] : gdb::enumerate (units.type)) { - nametable.add_cu (per_cu, type_unit_counter); + nametable.add_cu (per_cu, i); type_unit_list.append_uint (nametable.dwarf5_offset_size (), dwarf5_byte_order, to_underlying (per_cu->sect_off ())); - type_unit_counter++; } - /* Verify that all units are represented. */ - gdb_assert (comp_unit_counter == per_bfd->num_comp_units); - gdb_assert (type_unit_counter == per_bfd->num_type_units); + /* Verify that all units are represented. */ + gdb_assert (units.comp.size () == per_bfd->num_comp_units); + gdb_assert (units.type.size () == per_bfd->num_type_units); for (const cooked_index_entry *entry : table->all_entries ()) nametable.insert (entry); @@ -1525,11 +1522,11 @@ write_debug_names (dwarf2_per_bfd *per_bfd, cooked_index *table, header.append_uint (2, dwarf5_byte_order, 0); /* comp_unit_count - The number of CUs in the CU list. */ - header.append_uint (4, dwarf5_byte_order, comp_unit_counter); + header.append_uint (4, dwarf5_byte_order, units.comp.size ()); /* local_type_unit_count - The number of TUs in the local TU list. */ - header.append_uint (4, dwarf5_byte_order, type_unit_counter); + header.append_uint (4, dwarf5_byte_order, units.type.size ()); /* foreign_type_unit_count - The number of TUs in the foreign TU list. */ -- 2.53.0