From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 0VSaO5Au5mmYniwAWB0awg (envelope-from ) for ; Mon, 20 Apr 2026 09:48:01 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=Y5VGiESX; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id ED2891E0BA; Mon, 20 Apr 2026 09:48:00 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,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 C0CFA1E067 for ; Mon, 20 Apr 2026 09:47:59 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 6BA884B358A9 for ; Mon, 20 Apr 2026 13:47:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6BA884B358A9 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=Y5VGiESX Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) by sourceware.org (Postfix) with ESMTPS id 8DF784B35881 for ; Mon, 20 Apr 2026 13:46:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8DF784B35881 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 8DF784B35881 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=192.198.163.10 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776692787; cv=none; b=w0l/2TyHIJtwS/jZLsSqh/fLfRYNYWOyzVZMELtrZrzi6ra3pj09v1YkhtKHRWPhGVF2heJk7E3b45Nmy0VyhllpL5e9wmJ8XpTksba2oMpjxRay5rbAqsGJzpU4Peo+YzclXQkL/oAMErZtQajTG8QP4G2oAUWSXCTX4N+Pano= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776692787; c=relaxed/simple; bh=VPMMnXzAlL75uyIRJ7fCrayK1RuBsnBACpKTaxd4JS4=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=QF3WjKzMsaz1XMU4/WgIIRcQuKeaU587QOMQm22gw6Gw82UoW8s7kBLvobYYM+rsK3mc0UvI3KfM3axj+URsJMgj0DbDIblxej7dkq9RCb3BEYrdo3wVInF4XTDXr40gs3s5xyGADZzGII0rBa5pdIvqyJfo1Iu1wxAWWPp+GuI= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8DF784B35881 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1776692788; x=1808228788; h=from:to:subject:date:message-id:mime-version: content-transfer-encoding; bh=VPMMnXzAlL75uyIRJ7fCrayK1RuBsnBACpKTaxd4JS4=; b=Y5VGiESXCrlx7NwmQFONEtkd5ZWfaMVWNLcn0ggiO5Kip5/zdRkocBIj N+zCdyHGm1KQGAabiZ09rZvFDsmF2b+y0Dhp79a67T0W+QpDMvSmjQGyt bRCB5EErb1Li0bXgJ4xurUWFlx4ziSDfXUKw5/0O+X/65ZUEnepO6y9Iv L9M0Nt93EpWi9nz6nykK/+MmhnjZtOGq9xUE+V+Ou7r0Eqq49REpmGm84 Bc3dSCI4QJ61EoI+TsBVJjd4pq/x3QoPT3h8eMLXlIrUCu79H+7ClMMKS vERIFn8WL0QAN1PlNjDxl8kiSLQV2j5Zo4S1bz5NKoARwJXLgJMxROxpp g==; X-CSE-ConnectionGUID: /MeE939hSTmNHG3UPr2atQ== X-CSE-MsgGUID: OncrbIENRkCkkxfmOn+eKg== X-IronPort-AV: E=McAfee;i="6800,10657,11762"; a="88984697" X-IronPort-AV: E=Sophos;i="6.23,189,1770624000"; d="scan'208";a="88984697" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Apr 2026 06:46:26 -0700 X-CSE-ConnectionGUID: oSHfrDRGT1uHo8UvN/MXxA== X-CSE-MsgGUID: gxnTp3FpT8eo5z1YlK/x+A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,189,1770624000"; d="scan'208";a="236100101" Received: from gkldtt-dev-004.igk.intel.com (HELO localhost) ([10.123.221.202]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Apr 2026 06:46:26 -0700 From: Tankut Baris Aktemur To: gdb-patches@sourceware.org Subject: [PATCH v2 1/3] gdb: parameterize all_threads_safe for the target and ptid Date: Mon, 20 Apr 2026 15:46:09 +0200 Message-Id: <20260420134611.4009838-1-tankut.baris.aktemur@intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" 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 'all_threads' and 'all_threads_safe' are two range providers to iterate over threads. The former takes optional process target and ptid arguments to filter the threads that are being iterated. The latter does not. Enhance 'all_threads_safe' to also take the optional arguments. Use the new version of the function in two places. --- gdb/gdbthread.h | 5 +++-- gdb/infrun.c | 8 ++++---- gdb/remote.c | 5 +---- gdb/thread-iter.h | 2 +- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/gdb/gdbthread.h b/gdb/gdbthread.h index 729dcf5ab06..3c568e29a04 100644 --- a/gdb/gdbthread.h +++ b/gdb/gdbthread.h @@ -864,9 +864,10 @@ all_non_exited_threads (process_stratum_target *proc_target = nullptr, */ inline all_threads_safe_range -all_threads_safe () +all_threads_safe (process_stratum_target *proc_target = nullptr, + ptid_t filter_ptid = minus_one_ptid) { - all_threads_iterator begin (all_threads_iterator::begin_t {}); + all_matching_threads_iterator begin (proc_target, filter_ptid); all_threads_safe_iterator safe_begin (std::move (begin)); return all_threads_safe_range (std::move (safe_begin)); 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); /* 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) delete_thread (&th); /* We also need to clear any left over stale state for the @@ -1308,7 +1309,6 @@ follow_exec (ptid_t ptid, const char *exec_file_target) update_breakpoints_after_exec (); /* What is this a.out's name? */ - process_ptid = ptid_t (pid); gdb_printf (_("%s is executing new program: %s\n"), target_pid_to_str (process_ptid).c_str (), exec_file_target); 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; - 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; /* Iterate over all threads of an inferior, safely. */ -- 2.34.1 Intel Deutschland GmbH Registered Address: Dornacher Strasse 1, 85622 Feldkirchen, Germany Tel: +49 89 991 430, www.intel.de Managing Directors: Harry Demas, Jeffrey Schneiderman, Yin Chong Sorrell Chairperson of the Supervisory Board: Nicole Lau Registered Seat: Munich Commercial Register: Amtsgericht Muenchen HRB 186928