From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 0UEMLcsu5mmRnywAWB0awg (envelope-from ) for ; Mon, 20 Apr 2026 09:48:59 -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=FgbNGlaY; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id AF7C71E0BA; Mon, 20 Apr 2026 09:48:59 -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 1BC901E067 for ; Mon, 20 Apr 2026 09:48:59 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id D152C4BA23D3 for ; Mon, 20 Apr 2026 13:48:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D152C4BA23D3 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=FgbNGlaY Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) by sourceware.org (Postfix) with ESMTPS id 641744CD2030 for ; Mon, 20 Apr 2026 13:46:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 641744CD2030 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 641744CD2030 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=1776692805; cv=none; b=NQJCE1IzCTLJWOHpCnWh8jow4tQBon3RuwZLibasUZXHqyu6vMwnrF8nKYGfmfm/58vmsbOix83x1+xx25i9Tua7cgAqLdlJHpzCVCEXsHpnyrMDJ0si4UUvlyiFgkoTm3gOG7C5S4qLxzMSn5AR9cVUmGyCkro/QksfQiMhxW8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776692805; c=relaxed/simple; bh=qNMcFtacHwNd8qwKpm9loW0/TY0IbIhp8R9SKIvck1g=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=duqy/VPuQipYCXUtu1p0NOwNhm2nW3b0ONg+Z0c1HyYm0zq1sn6+7N2RSg83eLN1tbsCMcVRrHB9q5HRM2Ke83GsGMs7GxQyMTFpcSpHZwIW40JG5wRvhUirlDlES/n50RYQCica2+hMaQlfp9iTJ8h01iL0G6jjrWdxsMGEFoY= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 641744CD2030 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1776692806; x=1808228806; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=qNMcFtacHwNd8qwKpm9loW0/TY0IbIhp8R9SKIvck1g=; b=FgbNGlaYprarYSlZWlAgOADZ11VIcU063Q+ME8s1sSQZFRnoUoaohrlQ 3Ir4E1iS4V01nTn525lfKMYGiURagPKRBUk9Jp5xICXlGiYWLeN/KAbBj cBvEhrzK/Hl9xLMzpBQMMX2Jyu4h0BsaQDsOVTBCj9t+TFB5l3XJEYMev AIB4tZRmExV4HM6YgdKCodHsB9MaY2mRrscx2H6zryghe+0VAkk0/0OlF 2OJewparIpwcWzx057L4cGyiVI1EPZcs8EfRcgp0Q9ptEHTlLkddNzzsY jsUnqBBVI/8ezC1o8UZ4RTujxi9Sw+guOvuwhfFA+SV2q87fM71sHeHEc w==; X-CSE-ConnectionGUID: 7JAdRBY2ThWAtPiKEOyreQ== X-CSE-MsgGUID: swo+zRu/RfyMRR9/pSo4YA== X-IronPort-AV: E=McAfee;i="6800,10657,11762"; a="88984763" X-IronPort-AV: E=Sophos;i="6.23,189,1770624000"; d="scan'208";a="88984763" 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:45 -0700 X-CSE-ConnectionGUID: 2k+f2625QyCyFd++B4VusQ== X-CSE-MsgGUID: Y3Wa7+6lS/qEA5A27Cqpdg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,189,1770624000"; d="scan'208";a="236100145" 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:44 -0700 From: Tankut Baris Aktemur To: gdb-patches@sourceware.org Subject: [PATCH v2 3/3] gdb, multi-target: pass a target argument to delete_exited_threads Date: Mon, 20 Apr 2026 15:46:11 +0200 Message-Id: <20260420134611.4009838-3-tankut.baris.aktemur@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260420134611.4009838-1-tankut.baris.aktemur@intel.com> References: <20260420134611.4009838-1-tankut.baris.aktemur@intel.com> 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 | 6 +++--- 6 files changed, 10 insertions(+), 10 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 fb1969e2f94..07ac231fc84 100644 --- a/gdb/gdbthread.h +++ b/gdb/gdbthread.h @@ -983,9 +983,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 6018d6c9914..d7d5e010748 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -3967,7 +3967,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 64c06dc87f6..74124596b28 100644 --- a/gdb/thread.c +++ b/gdb/thread.c @@ -779,9 +779,9 @@ 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 ()) + for (thread_info &tp : all_threads_safe (target)) if (tp.state () == THREAD_EXITED) delete_thread (&tp); } @@ -2112,7 +2112,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