From patchwork Thu Oct 1 10:28:41 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Metzger X-Patchwork-Id: 145087 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1A2F24BB5905 for ; Thu, 1 Oct 2026 10:30:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1A2F24BB5905 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=elwoaz2z X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) by sourceware.org (Postfix) with ESMTPS id 7BE0B4BB58F4 for ; Thu, 1 Oct 2026 10:28:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7BE0B4BB58F4 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 7BE0B4BB58F4 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=192.198.163.14 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790850536; cv=none; b=uNd4qTcfElg/1MzNlOyIxeF6BT4FCPOWBAuxb3HgqHPLpdwFmgp/ObJo5E0q0GrJ/zqgnJYkaj3qgjhI7XepsNfaV/rji80FbcG45MoxvDZ7S5P2QGg64Qjq+SStw7vfHpei8CFSWwSOyPoyvAx7yBoCN5BZDBbQu40R/RrbPTA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790850536; c=relaxed/simple; bh=c0ekZJfbryX0WnRpmK9zKx/3yPKPColdhbYN8rAA/O4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=vjElze4jty1hayPnWbwivZPdNKcaFtf7NAAZWoqBDvtkCLYLwPO/de/rifd10oLd+HvsCgGTtnn5NfF7pVStc5RcwGF4MGz8SLzzMn3EQe3KumEQfbZYPLmVi9Gv+pnnJ2bOsLgs+YBUR9BUdB4098CHKH3MrpoI2jzjBKq8hGc= ARC-Authentication-Results: i=1; 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=elwoaz2z DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7BE0B4BB58F4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1790850537; x=1822386537; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=c0ekZJfbryX0WnRpmK9zKx/3yPKPColdhbYN8rAA/O4=; b=elwoaz2z8YuoKkUNuVnIVVKo8qGI+kPxUCknpTZ8SiyblBhA/L86PyR4 5XIjeZcZ9fBqueMqn9GiS1vRg+5/p3TaUt/qTp61Shoi20/aX4/1uuCGB cqXWJs2bSMvNlpUhjcNyCoMudN0gwwxAIJkQ7EYJuFWxovmkzq2zpGXuH y9uSYo9A6fxCTyCoFbUAuYcfzLLLHjWHmEvPvJkcdEMaPmAQUX2P4+4v3 jEPAGN9Z1fCxyMyDbqwcEnD2KY3HQGHuxu+y/+ir3+gqzCvDnl8H1WcJz VBuzHUQncldZVQzsQXSZTWON0dyp/h6K/9qBrmdARcT7W374uO7kSyVL/ g==; X-CSE-ConnectionGUID: A7ia0un5Q6ChM2GmgNJ2sw== X-CSE-MsgGUID: hFMmQ0IyQja8ZXJ1JprbXg== X-IronPort-AV: E=McAfee;i="6800,10657,11921"; a="91619612" X-IronPort-AV: E=Sophos;i="6.27,134,1787036400"; d="scan'208";a="91619612" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Oct 2026 03:28:56 -0700 X-CSE-ConnectionGUID: HbYiNO9jRo6VzsZT+P/8MA== X-CSE-MsgGUID: toWKB0KISPypj47hXo96Ew== X-ExtLoop1: 1 Received: from gkldtt-dev-004.igk.intel.com (HELO localhost) ([10.123.221.202]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Oct 2026 03:28:55 -0700 From: Markus Metzger To: gdb-patches@sourceware.org Subject: [RFC PATCH 2/8] gdb, infrun: track last waitstatus per thread Date: Thu, 1 Oct 2026 12:28:41 +0200 Message-ID: <20261001102847.576880-3-markus.t.metzger@intel.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261001102847.576880-1-markus.t.metzger@intel.com> References: <20261001102847.576880-1-markus.t.metzger@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-9.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, TXREP, T_SPF_TEMPERROR shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org 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~patchwork=sourceware.org@sourceware.org --- gdb/gdbthread.h | 3 +++ gdb/infrun.c | 11 +++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/gdb/gdbthread.h b/gdb/gdbthread.h index 51e9ae1b3f0..fdb6b749387 100644 --- a/gdb/gdbthread.h +++ b/gdb/gdbthread.h @@ -225,6 +225,9 @@ struct thread_control_state /* Nonzero if stopped due to a step command. */ int stop_step = 0; + /* The last waitstatus for this thread. */ + target_waitstatus stop_ws {}; + /* Chain containing status of breakpoint(s) the thread stopped at. */ bpstat *stop_bpstat = nullptr; diff --git a/gdb/infrun.c b/gdb/infrun.c index a70d88cd4a7..b347459f335 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -3134,6 +3134,7 @@ clear_proceed_status_thread (struct thread_info *tp) /* Discard any remaining commands or status from previous stop. */ bpstat_clear (&tp->control.stop_bpstat); + tp->control.stop_ws.set_ignore (); } /* Notify the current interpreter and observers that the target is about to @@ -4169,7 +4170,8 @@ do_target_wait_1 (inferior *inf, ptid_t ptid, } tp->set_stop_reason (TARGET_STOPPED_BY_NO_REASON); - *status = tp->pending_waitstatus (); + tp->control.stop_ws = tp->pending_waitstatus (); + *status = tp->control.stop_ws; tp->set_internal_state (THREAD_INT_STOPPED); tp->clear_pending_waitstatus (); @@ -4187,7 +4189,12 @@ do_target_wait_1 (inferior *inf, ptid_t ptid, if (!target_can_async_p ()) options &= ~TARGET_WNOHANG; - return target_wait (ptid, status, options); + ptid_t event_ptid = target_wait (ptid, status, options); + tp = inf->find_thread (event_ptid); + if (tp != nullptr) + tp->control.stop_ws = *status; + + return event_ptid; } /* Wrapper for target_wait that first checks whether threads have