public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Magne Hov <mhov@undo.io>
To: gdb-patches@sourceware.org
Cc: Magne Hov <mhov@undo.io>
Subject: [PATCH v2 2/2] gdb: retain thread-specific breakpoints in reverse execution targets
Date: Fri,  7 Jul 2023 17:24:51 +0100	[thread overview]
Message-ID: <20230707162451.3605544-3-mhov@undo.io> (raw)
In-Reply-To: <20230707162451.3605544-1-mhov@undo.io>

Thread-specific breakpoints are currently ignored and removed (since
49fa26b0411d990d36f3f6c095d167f3d12afdf4) if the corresponding thread
has exited.  This makes sense for targets that only execute in the
forward direction because those breakpoints can never be hit again, but
for targets with reverse execution the same thread can be seen again.
---
 gdb/breakpoint.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index da6c8de9d14..9a25c5f663d 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -3157,10 +3157,12 @@ insert_breakpoint_locations (void)
 	continue;
 
       /* There is no point inserting thread-specific breakpoints if
-	 the thread no longer exists.  ALL_BP_LOCATIONS bp_location
-	 has BL->OWNER always non-NULL.  */
+	 the thread no longer exists, unless the target supports
+	 reverse execution.  ALL_BP_LOCATIONS bp_location has
+	 BL->OWNER always non-NULL.  */
       if (bl->owner->thread != -1
-	  && !valid_global_thread_id (bl->owner->thread))
+	  && !valid_global_thread_id (bl->owner->thread)
+	  && !target_can_execute_reverse ())
 	continue;
 
       switch_to_program_space_and_thread (bl->pspace);
@@ -3245,12 +3247,18 @@ remove_breakpoints (void)
   return val;
 }
 
-/* When a thread exits, remove breakpoints that are related to
-   that thread.  */
+/* When a thread exits, remove breakpoints that are related to that
+   thread and cannot be hit again.  */
 
 static void
 remove_threaded_breakpoints (struct thread_info *tp, int silent)
 {
+  /* Targets that support reverse execution may navigate to a point in
+     time where an exited thread reappears and where its breakpoints
+     are still relevant.  */
+  if (target_can_execute_reverse ())
+    return;
+
   for (breakpoint &b : all_breakpoints_safe ())
     {
       if (b.thread == tp->global_num && user_breakpoint_p (&b))
-- 
2.40.1


  parent reply	other threads:[~2023-07-07 16:24 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-29  8:36 [PATCH 0/2] Improve handling of thread numbers for " Magne Hov
2023-06-29  8:36 ` [PATCH 1/2] gdb: keep record " Magne Hov
2023-06-29  9:01   ` Lancelot SIX
2023-06-29  9:38     ` Magne Hov
2023-06-29  8:36 ` [PATCH 2/2] gdb: retain thread-specific breakpoints in " Magne Hov
2023-07-07 16:24 ` [PATCH v2 0/2] Improve handling of thread numbers for " Magne Hov
2023-07-07 16:24   ` [PATCH v2 1/2] gdb: keep record " Magne Hov
2023-07-13 12:21     ` Bruno Larsen
2023-09-19 16:33     ` Tom Tromey
2023-09-20 16:42       ` Pedro Alves
2023-09-20 17:00         ` Magne Hov
2023-09-20 17:13     ` Pedro Alves
2023-07-07 16:24   ` Magne Hov [this message]
2023-07-13 12:22     ` [PATCH v2 2/2] gdb: retain thread-specific breakpoints in " Bruno Larsen
2023-08-18 14:27   ` [PING][PATCH v2 0/2] Improve handling of thread numbers for " Magne Hov
2023-09-18 11:38     ` Magne Hov
2023-09-19 16:34   ` [PATCH " Tom Tromey

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=20230707162451.3605544-3-mhov@undo.io \
    --to=mhov@undo.io \
    --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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).