From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id KJDUHURb5mlS9CwAWB0awg (envelope-from ) for ; Mon, 20 Apr 2026 12:58:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1776704324; bh=bx3Ap4tNUuOswpm9a06rfEW2K7xcpkeGQtVGoV/jj60=; h=Date:Subject:To:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=kptgXeExXK7HZR/rAEOdLzF0fPzzyvthsaSsarIRQXY0HGNtAN7H9De6Xaz2OzZ9m dgUxnp0Oj8ZSj05QNs9idw2JTOXViIhtFeGkVR9vb/dqW10i5eD+ciWD6B6qE37WXH nt1+5bPLAG3KIyZFUhD42X8IHbc7O2m/hlouB6ww= Received: by simark.ca (Postfix, from userid 112) id 67AD81E0C3; Mon, 20 Apr 2026 12:58:44 -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=Rmm2P1G0; 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 89A341E093 for ; Mon, 20 Apr 2026 12:58:43 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id E98DB4B35881 for ; Mon, 20 Apr 2026 16:58:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E98DB4B35881 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=Rmm2P1G0 Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id DE6D34AA54C6 for ; Mon, 20 Apr 2026 16:58:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DE6D34AA54C6 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 DE6D34AA54C6 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=1776704299; cv=none; b=XsZ8vkB5TYdsktaHaEox7fbvl2oDhelXqctXn2hOQKIPc9l+RwVKvxNN1uTD6ZbT/nN9KWt54mN7txN8NXSqT5G3XL43P8BTFZ+5+SI5Mjhjr08W6GqG7hISKQvvH7TcZX1cqXavAe6jidZbizMBhHsJo7SKlItLCrFezsGzwnk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776704299; c=relaxed/simple; bh=bx3Ap4tNUuOswpm9a06rfEW2K7xcpkeGQtVGoV/jj60=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=jhGcMGLuJ38nh8sPuqoxAUnZmMDNtSfCm8ynUKOT0fick+fuJuMW6Lia0JERyeleuNWLxKWl59dn0rIgb6gvNGzlIed+6UbcH0DYmcITdOBENYKzEKl1GISqrXY4U0Aa3PiMqjGVQOdw+6UGUQjV2+kx+UVk/m3YZ+qSLjmteg4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DE6D34AA54C6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1776704297; bh=bx3Ap4tNUuOswpm9a06rfEW2K7xcpkeGQtVGoV/jj60=; h=Date:Subject:To:References:From:In-Reply-To:From; b=Rmm2P1G0/XAx+nzc74KoJhO2z7VgpJetWiWQH1rWSCGdPee+9C3PNKDv8jG1zcnwr r1ZVE99MdR73KHheHeHNEcZ13xBtXqyelHqFhxkFABZkb0NgsUYoq//gf4I6CSh8wW kjbUFAHFxKtCvmrOAJG9g5dl1WvI8V6E1RLSE8ow= Received: by simark.ca (Postfix) id C40BD1E093; Mon, 20 Apr 2026 12:58:17 -0400 (EDT) Message-ID: Date: Mon, 20 Apr 2026 12:58:17 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 1/3] gdb: parameterize all_threads_safe for the target and ptid To: Tankut Baris Aktemur , gdb-patches@sourceware.org References: <20260420134611.4009838-1-tankut.baris.aktemur@intel.com> Content-Language: fr From: Simon Marchi In-Reply-To: <20260420134611.4009838-1-tankut.baris.aktemur@intel.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 4/20/26 9:46 AM, Tankut Baris Aktemur wrote: > diff --git a/gdb/infrun.c b/gdb/infrun.c > index b295956f8ea..46d6b684ebc 100644 > --- a/gdb/infrun.c > +++ b/gdb/infrun.c > @@ -1239,7 +1239,7 @@ static void > follow_exec (ptid_t ptid, const char *exec_file_target) > { > int pid = ptid.pid (); > - ptid_t process_ptid; > + ptid_t process_ptid = ptid_t (pid); ptid_t process_ptid (pid); > /* Switch terminal for any messages produced e.g. by > breakpoint_re_set. */ > @@ -1285,8 +1285,9 @@ follow_exec (ptid_t ptid, const char *exec_file_target) > them. Deleting them now rather than at the next user-visible > stop provides a nicer sequence of events for user and MI > notifications. */ > - for (thread_info &th : all_threads_safe ()) > - if (th.ptid.pid () == pid && th.ptid != ptid) > + process_stratum_target *target = current_inferior ()->process_target (); > + for (thread_info &th : all_threads_safe (target, process_ptid)) > + if (th.ptid != ptid) Just noting that this is a behavior change, the previous code iterated threads of all targets, while the new code only iterates the threads of the current process target. You could have passed nullptr to preserve existing behavior. But I think this is a good change, it's the same spirit as your other patches. > diff --git a/gdb/remote.c b/gdb/remote.c > index 88668b2748e..7c8aed481f2 100644 > --- a/gdb/remote.c > +++ b/gdb/remote.c > @@ -4584,11 +4584,8 @@ remote_target::update_thread_list () > /* CONTEXT now holds the current thread list on the remote > target end. Delete GDB-side threads no longer found on the > target. */ > - for (thread_info &tp : all_threads_safe ()) > + for (thread_info &tp : all_threads_safe (this)) > { > - if (tp.inf->process_target () != this) > - continue; > - You could now remove the braces for the `for`, to reduce indentation a bit. > if (!context.contains_thread (tp.ptid)) > { > /* Do not remove the thread if it is the last thread in > diff --git a/gdb/thread-iter.h b/gdb/thread-iter.h > index 3c15ada1cbb..32bc6475ebe 100644 > --- a/gdb/thread-iter.h > +++ b/gdb/thread-iter.h > @@ -165,7 +165,7 @@ using inf_non_exited_threads_iterator > /* Iterate over all threads of all inferiors, safely. */ > > using all_threads_safe_iterator > - = basic_safe_iterator; > + = basic_safe_iterator; I'd rename all_threads_safe_iterator to all_matching_threads_safe_iterator, to try to preserve the logic in how these are named. all_threads_safe_range would also be renamed to all_matching_threads_safe_range. With those fixed: Approved-By: Simon Marchi Simon