From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id KYlsAJsImWnQcQMAWB0awg (envelope-from ) for ; Fri, 20 Feb 2026 20:21:31 -0500 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=polymtl.ca header.i=@polymtl.ca header.a=rsa-sha256 header.s=oct2025 header.b=GIYfWSsC; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id F1D751E0BA; Fri, 20 Feb 2026 20:21:30 -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.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,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 167311E08D for ; Fri, 20 Feb 2026 20:21:30 -0500 (EST) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id D82A04BAD150 for ; Sat, 21 Feb 2026 01:21:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D82A04BAD150 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=polymtl.ca header.i=@polymtl.ca header.a=rsa-sha256 header.s=oct2025 header.b=GIYfWSsC Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id D93B54B9DB7B for ; Sat, 21 Feb 2026 01:19:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D93B54B9DB7B Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=polymtl.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=polymtl.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D93B54B9DB7B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=132.207.4.11 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1771636777; cv=none; b=srIZIOxFKsoWkACfMP1JCoGyRwiJ3qonTcSz1HJjDMdi3f8rmpnuQ98KoEkwbzFiwW/m0SVH+aqu4fKFpLVknO1gZUZaNcd9oOG1o9lGy8NSnwKT45TUlBBPsmy0iSKVqMyHQeozrn+fifrMSRcP39PRh7qbllNdgPMW/HWvKXM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1771636777; c=relaxed/simple; bh=OkfNUAboOoEtnYD7X4CxBh2Eyo2+vZqM2W/lNYXvqVM=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=AvwFSq7uK+Vl0ZZ2QaV/ySCQonsU0lLCI15jG6Ivdz3RglFPLss2vsYFBvhLcnGXvEpu6xteJP/3aQ6imGLxf+YNfDgl8LHTFszDDdi0L24NENuAopT/djo0tcPtuOQhl/1HmnsLYUTKJPyOlvVLqi6KJB+CXBrvHo3Kumk8vgE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D93B54B9DB7B Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 61L1JT46209424 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 20 Feb 2026 20:19:33 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 61L1JT46209424 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=polymtl.ca; s=oct2025; t=1771636774; bh=kR+NzrGvhAd3KPq+11ZHC4c1TvrKFA6kyrqptrIbGOA=; h=From:To:Cc:Subject:Date:In-Reply-To:From; b=GIYfWSsCcg4MmZToSE/vUOnPBAfuBzhLcz8kaeQq5TLx316CZ3r274jG4MMOziTkr p038VlEAvKOiqPaqGSU8/2CbRIYipVhLtn7ib7Fg32wbG8Y557Ky5ZxF+N42Rw73XE 6EoXJibzMfirhoAJhb0MeaHukrMwiWtF0CajLsQOX0KgUKlrkrblpA8w0bv3c6nXkN xul/YxSog+kbppEdPbs+CCg+/PRYZGwPx4284BRWPU0hLMkg2/5bduyhLdrtkQMRBd S2cHkOqp93+dOB3XnQnV2QPiNsXN02WnD550DkF7jAbLfPuYjEC40PYrNDw5USpCn0 rqrErmxgJFsqQ== Received: by simark.ca (Postfix) id E39FE1E09A; Fri, 20 Feb 2026 20:19:28 -0500 (EST) From: simon.marchi@polymtl.ca To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH v2 2/3] gdb/dwarf: use enumerate in index-write.c Date: Fri, 20 Feb 2026 20:18:59 -0500 Message-ID: <20260221011924.2029855-2-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260221011924.2029855-1-simon.marchi@polymtl.ca> References: <20260220202002.860008-1-simon.marchi@efficios.com> <20260221011924.2029855-1-simon.marchi@polymtl.ca> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Sat, 21 Feb 2026 01:19:29 +0000 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..2877f30dc816 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::ranges::views::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::ranges::views::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