From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 2ZQFAWcW4mmMRh4AWB0awg (envelope-from ) for ; Fri, 17 Apr 2026 07:15:51 -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=m6x8TzVg; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id F34B31E0B1; Fri, 17 Apr 2026 07:15:50 -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 4B0721E0B1 for ; Fri, 17 Apr 2026 07:15:50 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 8255A4C91776 for ; Fri, 17 Apr 2026 11:15:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8255A4C91776 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=m6x8TzVg Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) by sourceware.org (Postfix) with ESMTPS id 4F6E04C91769 for ; Fri, 17 Apr 2026 11:15:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4F6E04C91769 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 4F6E04C91769 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=192.198.163.18 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776424505; cv=none; b=nB0EEUxoh3URG/Sqm3UK9CvuLNRxy+vkW44hL1CqdVd7VKcdsTHZLA1WFaXXvYFCvwMtxbS4sBl5J5kci6MBkJYP+qKs2ZsQYhhGbDw3HxTkeBx8yEnqytsUXRb40roswFrCCP93VZfX0TGIxpSzQvQAOzmztCmZUTLMmH0kG1Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776424505; c=relaxed/simple; bh=a4Oa/kjv+RtIrIZkdfwJdcp4zcmg6lWq7wlV6R6i22A=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=f4inj+1eb/OOtnf6KiGyjdl6o01XAImuNrsyRlzmYoGbHUxGEeI3s6hEE6dMivnxTD3n3lzrPQHO8K/xy/2Btu1pWH7apbyzC9sXzwP/rXPkSNVfjylDo/hLkTolXiWF3VWW1PO0uSXIsloqJ3ANi2ErCMHOBqzwkkRorAULfPY= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4F6E04C91769 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1776424506; x=1807960506; h=from:to:subject:date:message-id:mime-version: content-transfer-encoding; bh=a4Oa/kjv+RtIrIZkdfwJdcp4zcmg6lWq7wlV6R6i22A=; b=m6x8TzVgTV2Fq/+XhZ++j7Vat4+38htTLSp9wCyS+RcQaFkvMGOpoLXo qVbTVdqQuRFWbxNVBaFaepZYZmwk1NEG1AfzqjXIjSMz3A4ZEPn+kW5X9 z94zWbfr/7yArAuO/GDqfX98mzTHvVdk8X7T4eVroM61JwDVgquW0wyoa HRqNAZ1bWOiHplGYMRLeyMyS2AjKhOYh0kiBrHASpaNfKlJtZ19KQIWFW PD722PGOtNEJ4QCNLj9ZjEFj9+ldb/I/jE6YIqZntHQuZsPNXuIFUNtjU 8MangVknPKAXpnRvPmks2PGOtk9cU9wndg3VHAEeF2W6kn7a9M3Nr/VJH A==; X-CSE-ConnectionGUID: 0IsWjjdMRR+0pwZ/FZNprA== X-CSE-MsgGUID: O2wQJf0xTwCv4O5dzbUF6g== X-IronPort-AV: E=McAfee;i="6800,10657,11761"; a="76602781" X-IronPort-AV: E=Sophos;i="6.23,184,1770624000"; d="scan'208";a="76602781" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Apr 2026 04:15:04 -0700 X-CSE-ConnectionGUID: nmUS39rQRZKP5CAhFo3AWw== X-CSE-MsgGUID: 1SdgPQN0Q42Gnd1rvmTUHQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,184,1770624000"; d="scan'208";a="226331288" Received: from gkldtt-dev-004.igk.intel.com (HELO localhost) ([10.123.221.202]) by fmviesa006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Apr 2026 04:15:02 -0700 From: Tankut Baris Aktemur To: gdb-patches@sourceware.org Subject: [PATCH 2/2] gdb, multi-target: pass a target argument to delete_exited_threads Date: Fri, 17 Apr 2026 13:14:55 +0200 Message-Id: <20260417111455.4126998-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 Similar to the parent commit, delete_exited_threads is also mostly used in the context of a particular target. Pass that target as a parameter and skip other targets. There seems to be two cases where we actually would want to iterate all targets. One use is in inferior_appeared (inferior.c) and the other is in thread_select (thread.c). To handle these cases, allow the argument to be nullptr. --- gdb/fbsd-nat.c | 2 +- gdb/gdbthread.h | 6 +++--- gdb/inferior.c | 2 +- gdb/linux-nat.c | 2 +- gdb/netbsd-nat.c | 2 +- gdb/thread.c | 14 ++++++++++---- 6 files changed, 17 insertions(+), 11 deletions(-) diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c index a1c7801ec1e..706d6efd342 100644 --- a/gdb/fbsd-nat.c +++ b/gdb/fbsd-nat.c @@ -1004,7 +1004,7 @@ fbsd_nat_target::update_thread_list () #ifdef PT_LWP_EVENTS /* With support for thread events, threads are added/deleted from the list as events are reported, so just try deleting exited threads. */ - delete_exited_threads (); + delete_exited_threads (this); #else prune_threads (this); diff --git a/gdb/gdbthread.h b/gdb/gdbthread.h index 835d07dc660..3bd9598907d 100644 --- a/gdb/gdbthread.h +++ b/gdb/gdbthread.h @@ -969,9 +969,9 @@ extern void update_thread_list (void); extern void prune_threads (process_stratum_target *target); /* Delete threads marked THREAD_EXITED. Unlike prune_threads, this - does not consult the target about whether the thread is alive right - now. */ -extern void delete_exited_threads (void); + does not consult TARGET about whether the thread is alive right + now. If TARGET is nullptr, operate on all targets. */ +extern void delete_exited_threads (process_stratum_target *target); /* Return true if PC is in the stepping range of THREAD. */ diff --git a/gdb/inferior.c b/gdb/inferior.c index e050dec402e..1481f46cdd1 100644 --- a/gdb/inferior.c +++ b/gdb/inferior.c @@ -368,7 +368,7 @@ inferior_appeared (struct inferior *inf, int pid) { /* If this is the first inferior with threads, reset the global thread id. */ - delete_exited_threads (); + delete_exited_threads (nullptr); if (!any_thread_p ()) init_thread_list (); diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index f141ba19ea4..5ac61316445 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -3963,7 +3963,7 @@ linux_nat_target::update_thread_list () /* We add/delete threads from the list as clone/exit events are processed, so just try deleting exited threads still in the thread list. */ - delete_exited_threads (); + delete_exited_threads (this); /* Update the processor core that each lwp/thread was last seen running on. */ diff --git a/gdb/netbsd-nat.c b/gdb/netbsd-nat.c index 6b9029bf0ef..36bd91f968c 100644 --- a/gdb/netbsd-nat.c +++ b/gdb/netbsd-nat.c @@ -155,7 +155,7 @@ nbsd_nat_target::post_attach (int pid) void nbsd_nat_target::update_thread_list () { - delete_exited_threads (); + delete_exited_threads (this); } /* Convert PTID to a string. */ diff --git a/gdb/thread.c b/gdb/thread.c index 861eca3591d..4e1f1ad17ac 100644 --- a/gdb/thread.c +++ b/gdb/thread.c @@ -785,11 +785,17 @@ prune_threads (process_stratum_target *target) /* See gdbthreads.h. */ void -delete_exited_threads (void) +delete_exited_threads (process_stratum_target *target) { for (thread_info &tp : all_threads_safe ()) - if (tp.state () == THREAD_EXITED) - delete_thread (&tp); + { + if (target != nullptr + && tp.inf->process_target () != target) + continue; + + if (tp.state () == THREAD_EXITED) + delete_thread (&tp); + } } /* Return true value if stack temporaries are enabled for the thread @@ -2118,7 +2124,7 @@ thread_select (const char *tidstr, thread_info *tp) /* Since the current thread may have changed, see if there is any exited thread we can now delete. */ - delete_exited_threads (); + delete_exited_threads (nullptr); } /* Print thread and frame switch command response. */ -- 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