Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Markus Metzger <markus.t.metzger@intel.com>
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	[thread overview]
Message-ID: <20261001102847.576880-3-markus.t.metzger@intel.com> (raw)
In-Reply-To: <20261001102847.576880-1-markus.t.metzger@intel.com>

---
 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
-- 
2.53.0

________________________________________
Intel Deutschland GmbH 

Registered Address: Dornacher Strasse 1, 85622 Feldkirchen, Germany 

Tel: +49 (89) 99143-0 

www.intel.de 

Managing Directors: Candice Moore, Jeffrey Schneiderman, Ramachandran Sitaraman

Chairperson of the Supervisory Board: Sonja Pierer

Registered Seat: Munich Commercial Register B: Amtsgericht Munich HRB 186928

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.


  parent reply	other threads:[~2026-10-01 10:30 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-01 10:28 [RFC PATCH 0/8] breakpoint handling Markus Metzger
2026-10-01 10:28 ` [RFC PATCH 1/8] gdb, infrun: do not discard a step-completed pending waitstatus Markus Metzger
2026-10-01 10:28 ` Markus Metzger [this message]
2026-10-01 10:28 ` [RFC PATCH 3/8] gdb, infrun: simplify print_stop_location() Markus Metzger
2026-10-01 10:28 ` [RFC PATCH 4/8] gdb, thread: simplify print_selected_thread_frame() Markus Metzger
2026-10-01 10:28 ` [RFC PATCH 5/8] gdb, interp: repeat stop event when switching threads Markus Metzger
2026-10-01 10:28 ` [RFC PATCH 6/8] gdb, infrun: handle stop event when selecting a thread Markus Metzger
2026-10-01 10:28 ` [RFC PATCH 7/8] gdb, infrun: inline init_thread_stepping_state() Markus Metzger
2026-10-01 10:28 ` [RFC PATCH 8/8] gdb, infrun: only step over breakpoints that were hit Markus Metzger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261001102847.576880-3-markus.t.metzger@intel.com \
    --to=markus.t.metzger@intel.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox