From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id IWTRIkMW4mmMRh4AWB0awg (envelope-from ) for ; Fri, 17 Apr 2026 07:15:15 -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=hMzZD3gk; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 895F31E0C3; Fri, 17 Apr 2026 07:15:15 -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 45AC61E0B1 for ; Fri, 17 Apr 2026 07:15:14 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 770AD4C900E6 for ; Fri, 17 Apr 2026 11:15:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 770AD4C900E6 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=hMzZD3gk Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by sourceware.org (Postfix) with ESMTPS id 8B3DA4BA23D9 for ; Fri, 17 Apr 2026 11:14:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8B3DA4BA23D9 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 8B3DA4BA23D9 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=198.175.65.9 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776424485; cv=none; b=qk8+BmXX+xgrCrtWo+K123EzPtoOGc9X6tSDnCUE4HNuAiS/XshhaPw1NhHgVkmqMT5lF+PKnc2mSb+ghVof9qEcaKTkYnrujLu1MyLpemHzV2AtB4uScnpL/ZPERLx66OAfvPY3g3vqqKeoIaqKNUh3IcFqgthI1aE6LpqJ4Xo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776424485; c=relaxed/simple; bh=hzeDeOmRVyAmMWOlQdsvHvfQ/5w6ERiOZa1GJKL2syc=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=GWATiIEc8vwt4euAbufOEHJ2x/vDE5dG5e97P1AypDfzaIVFpqDJFrKA+Nwk3DnFD/2oca3CYLmEcVMAq2KurJngJNxlmfjjaXDMOTqvg91daFUrNYhaw8QUuku2NLDP4Q4TAGxev9LwD5ICm17RiZcYncRcW/2+aydpbVZUxMk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8B3DA4BA23D9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1776424485; x=1807960485; h=from:to:subject:date:message-id:mime-version: content-transfer-encoding; bh=hzeDeOmRVyAmMWOlQdsvHvfQ/5w6ERiOZa1GJKL2syc=; b=hMzZD3gkGVJECRURl18wTbOlvDTuU5pniiWmI7ALOnMftHuswUROkKh2 ZFiAWmhOr/1jQT/JF5VzvE1ylW1Lh8PWDa5e7iD+w9vuQjq9ulU3dz+cX /uSZ/flaVoHEfxlACdbbuZyh9mcGlJVq3v88nyA4jYkNsT7nV79icf1HV D45N5TlT2qNOFWTtZvfFaRgxEuHNM2BdbcrQBXdZFI+yRajwOiGluIbiK ErHaPwXEJCdjZ+3tOL+MVi2ir/FBSGn6FTEPYZbrpzkLdVpzGcpk04v5u +JOHi2BGqxmEcB/ZltxVm8NS+sF6TaREYXrof3dFDju8Hpjes1oCo9W1L g==; X-CSE-ConnectionGUID: zkDTDWV3Q3u74762K5HJzQ== X-CSE-MsgGUID: +4DQOAHgT+WYoNz/vzPzUg== X-IronPort-AV: E=McAfee;i="6800,10657,11761"; a="100086877" X-IronPort-AV: E=Sophos;i="6.23,184,1770624000"; d="scan'208,223";a="100086877" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Apr 2026 04:14:42 -0700 X-CSE-ConnectionGUID: BSiat7LHSNqe8LbHRAhK2w== X-CSE-MsgGUID: 6KSIJhBCSkyLThZlXcRuDw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,184,1770624000"; d="scan'208,223";a="226331257" 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:14:41 -0700 From: Tankut Baris Aktemur To: gdb-patches@sourceware.org Subject: [PATCH 1/2] gdb, multi-target: pass a target argument to prune_threads Date: Fri, 17 Apr 2026 13:14:30 +0200 Message-Id: <20260417111430.4111679-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 >From the way 'prune_threads' is used, it is designed to delete the threads of the current target. So, while iterating the threads, ignore those that do not belong to the current target. To do this, prune_threads is modified to take a process_stratum_target as a parameter. --- gdb/bsd-uthread.c | 2 +- gdb/fbsd-nat.c | 2 +- gdb/gdbthread.h | 5 +++-- gdb/gnu-nat.c | 2 +- gdb/obsd-nat.c | 2 +- gdb/procfs.c | 2 +- gdb/remote.c | 2 +- gdb/sol-thread.c | 2 +- gdb/thread.c | 7 ++++++- 9 files changed, 16 insertions(+), 10 deletions(-) diff --git a/gdb/bsd-uthread.c b/gdb/bsd-uthread.c index 0aa8ebda558..64a67cdfb8b 100644 --- a/gdb/bsd-uthread.c +++ b/gdb/bsd-uthread.c @@ -454,7 +454,7 @@ bsd_uthread_target::update_thread_list () int offset = bsd_uthread_thread_next_offset; CORE_ADDR addr; - prune_threads (); + prune_threads (current_inferior ()->process_target ()); addr = bsd_uthread_read_memory_address (bsd_uthread_thread_list_addr); while (addr != 0) diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c index 9e7965b900a..a1c7801ec1e 100644 --- a/gdb/fbsd-nat.c +++ b/gdb/fbsd-nat.c @@ -1006,7 +1006,7 @@ fbsd_nat_target::update_thread_list () list as events are reported, so just try deleting exited threads. */ delete_exited_threads (); #else - prune_threads (); + prune_threads (this); fbsd_add_threads (this, inferior_ptid.pid ()); #endif diff --git a/gdb/gdbthread.h b/gdb/gdbthread.h index c56c4ce4036..835d07dc660 100644 --- a/gdb/gdbthread.h +++ b/gdb/gdbthread.h @@ -963,9 +963,10 @@ extern struct thread_info* inferior_thread (void); extern void update_thread_list (void); -/* Delete any thread the target says is no longer alive. */ +/* Delete any thread of TARGET that the target says is no longer + alive. */ -extern void prune_threads (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 diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c index 70685cee526..9f481ba7e8b 100644 --- a/gdb/gnu-nat.c +++ b/gdb/gnu-nat.c @@ -2146,7 +2146,7 @@ gnu_nat_target::create_inferior (const char *exec_file, inf->pending_execs = 0; /* Get rid of the old shell threads. */ - prune_threads (); + prune_threads (this); inf_validate_procinfo (inf); inf_update_signal_thread (inf); diff --git a/gdb/obsd-nat.c b/gdb/obsd-nat.c index e659434a1aa..a32a03bb042 100644 --- a/gdb/obsd-nat.c +++ b/gdb/obsd-nat.c @@ -48,7 +48,7 @@ obsd_nat_target::update_thread_list () pid_t pid = inferior_ptid.pid (); struct ptrace_thread_state pts; - prune_threads (); + prune_threads (this); if (ptrace (PT_GET_THREAD_FIRST, pid, (caddr_t)&pts, sizeof pts) == -1) perror_with_name (("ptrace")); diff --git a/gdb/procfs.c b/gdb/procfs.c index cea9f823bbc..f50d825cfe8 100644 --- a/gdb/procfs.c +++ b/gdb/procfs.c @@ -2868,7 +2868,7 @@ procfs_target::update_thread_list () { procinfo *pi; - prune_threads (); + prune_threads (this); /* Find procinfo for main process. */ pi = find_procinfo_or_die (inferior_ptid.pid (), 0); diff --git a/gdb/remote.c b/gdb/remote.c index 88668b2748e..3d257fe3ca8 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -4651,7 +4651,7 @@ remote_target::update_thread_list () each known thread is alive, one by one, with the T packet. If the target doesn't support threads at all, then this is a no-op. See remote_thread_alive. */ - prune_threads (); + prune_threads (this); } } diff --git a/gdb/sol-thread.c b/gdb/sol-thread.c index c765a4205a0..0e812c472d4 100644 --- a/gdb/sol-thread.c +++ b/gdb/sol-thread.c @@ -1012,7 +1012,7 @@ void sol_thread_target::update_thread_list () { /* Delete dead threads. */ - prune_threads (); + prune_threads (current_inferior ()->process_target ()); /* Find any new LWP's. */ beneath ()->update_thread_list (); diff --git a/gdb/thread.c b/gdb/thread.c index a6ae2a75139..861eca3591d 100644 --- a/gdb/thread.c +++ b/gdb/thread.c @@ -764,12 +764,17 @@ switch_to_thread_if_alive (thread_info *thr) /* See gdbthreads.h. */ void -prune_threads (void) +prune_threads (process_stratum_target *target) { + gdb_assert (target != nullptr); + scoped_restore_current_thread restore_thread; for (thread_info &tp : all_threads_safe ()) { + if (tp.inf->process_target () != target) + continue; + switch_to_inferior_no_thread (tp.inf); if (!thread_alive (&tp)) -- 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