From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id A7t4MKrYBWqkKjoAWB0awg (envelope-from ) for ; Thu, 14 May 2026 10:14:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1778768042; bh=hcWM32Bo8e2kGz0HRE19YgJ2tGYQGp7Not7WHIaXXlk=; h=Date:Subject:To:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=ufCr0hXriSW9D5tjg25IZcTavAPgqmkX3e7SowQovAbL+lppscINQZC/q3sEFioGW H3KVCGBUm1//9ckbd1y+yjHXHm1Sg3GJynCxUhWudn+BEh+qHdSPnnzEwispZZAB2f ardw8lJhfylEwg1WPTNP9U6TUu0Iq0N+c4WPrmbk= Received: by simark.ca (Postfix, from userid 112) id B698D1E093; Thu, 14 May 2026 10:14:02 -0400 (EDT) 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 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=JBm+5j4B; dkim-atps=neutral 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 26B2B1E093 for ; Thu, 14 May 2026 10:14:01 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 72D764C3185B for ; Thu, 14 May 2026 14:13:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 72D764C3185B Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=JBm+5j4B Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 993B64B19729 for ; Thu, 14 May 2026 14:13:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 993B64B19729 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 993B64B19729 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1778768014; cv=none; b=E9OhJhnN5Gw4I8R3qThLSk6zOGX2qkJhA0a1yET0QouD50UiDfvSmuibine1XbsEG2Df9lnnqile7ihuQx1h/pea9UGs4gw5QD9l2Pm3dPNofHBh+w5eMOcBbU0cL5pzkdrTUZwSg9pFAwDlFLS6IuT29s+awfoTZQomOQeSbCk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1778768014; c=relaxed/simple; bh=hcWM32Bo8e2kGz0HRE19YgJ2tGYQGp7Not7WHIaXXlk=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=s0JyS74S3Dax3C+LfsG8VXr8/00u2bGimxB0D+5nsJRiNYXQ29bIex5/EXf/ECeeFaSnQse5Lf5nO798ZP5YleNihevnrdnmbwl2qaTLJCl3C801fzoi+lkj2Z+gpfEgeMGGDDDGu43gHXoSF4oQ3/ebPrOTp4eT9SHhdwSh5uw= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=JBm+5j4B DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 993B64B19729 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1778768013; bh=hcWM32Bo8e2kGz0HRE19YgJ2tGYQGp7Not7WHIaXXlk=; h=Date:Subject:To:References:From:In-Reply-To:From; b=JBm+5j4BYjCF8YVD+gI8o4UX62wDffGXyvIu6AITDCk9ISr2tY0ZGL3+qhN7MvPQZ D56MslOAz7VeLG1J0TMZwZYwhTMhhA+Yn8uekW1FXvAc8acjHFG02TdvzlrCiZ1TCH TNpcv3Unxp8F8eT+5pg92kyD8DA8F7lgcxm7t9Io= Received: by simark.ca (Postfix) id 6B7861E093; Thu, 14 May 2026 10:13:32 -0400 (EDT) Message-ID: <9c0a15ea-df3d-4795-9028-f290fdeb8232@simark.ca> Date: Thu, 14 May 2026 10:13:31 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/2] Remove for_each_thread To: Tom Tromey , gdb-patches@sourceware.org References: <20260513-remove-for-each-v1-0-8793bd79f781@adacore.com> <20260513-remove-for-each-v1-2-8793bd79f781@adacore.com> Content-Language: en-US From: Simon Marchi In-Reply-To: <20260513-remove-for-each-v1-2-8793bd79f781@adacore.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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 On 2026-05-13 13:32, Tom Tromey wrote: > This patch removes the for_each_thread function, changing the callers > to use 'foreach' loops instead. In general I think loops with > iterators should be preferred over callback-based approaches -- they > are easier to read and often result in less source code as well. For > example, in this patch a helper function is inlined into its sole > caller. Perhaps mention that there is a functional change, since you switch from using all_threads_safe to all_threads everywhere. This happens to fix the bug that Markus was fixing here: https://inbox.sourceware.org/gdb-patches/20260504071636.1571615-2-markus.t.metzger@intel.com/ I would have liked to see a test along with that fix (I supplied one down-thread), but whatever. The other callers don't seem to need all_threads_safe, at first glance. > @@ -607,16 +605,16 @@ print_one_inferior (struct inferior *inferior, bool recurse, > > if (inferior->pid != 0) > { > - for_each_thread ([&] (struct thread_info *ti) > + for (auto &ti : all_threads ()) > { > - if (ti->ptid.pid () == inferior->pid) > + if (ti.ptid.pid () == inferior->pid) > { > - int core = target_core_of_thread (ti->ptid); > + int core = target_core_of_thread (ti.ptid); > > if (core != -1) > cores.insert (core); > } > - }); > + } You could remove the braces of the "for" here. Approved-By: Simon Marchi Simon