public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Kevin Buettner <kevinb@redhat.com>
To: gdb-patches@sourceware.org
Cc: Pedro Alves <pedro@palves.net>, Kevin Buettner <kevinb@redhat.com>
Subject: [PATCH v2 2/2] Make thread_db_target::pid_to_str checkpoint-aware
Date: Sat, 13 Apr 2024 20:24:27 -0700	[thread overview]
Message-ID: <20240414032731.130266-3-kevinb@redhat.com> (raw)
In-Reply-To: <20240414032731.130266-1-kevinb@redhat.com>

This commit prevents thread_db_target::pid_to_str from considering
a checkpoint as a thread.  The reason for doing this is that pids
associated with checkpoints can never be a thread due to the fact
that checkpoints (which are implemented by forking a process) can
only work with single-threaded processes.

Without this commit, many of the "info checkpoints" commands
in gdb.multi/checkpoint-multi.exp will incorrectly show some
of the checkpoints as threads.  E.g...

*  1.0 A  Thread 0x7ffff7cd3740 (LWP 128534) at 0x401199, file hello.c, line 51
   1.2    process 128546 at 0x401199, file hello.c, line 51
   1.3    process 128547 at 0x401199, file hello.c, line 51
   2.1    process 128538 at 0x401258, file goodbye.c, line 62
   2.2 A  Thread 0x7ffff7cd3740 (LWP 128542) at 0x401258, file goodbye.c, line 62
   3.0 A  Thread 0x7ffff7cd3740 (LWP 128543) at 0x40115c, file hangout.c, line 31
   3.2    process 128545 at 0x40115c, file hangout.c, line 31

With this commit in place, the output looks like this instead:

*  1.0 A  process 129961 at 0x401199, file hello.c, line 51
   1.2    process 129974 at 0x401199, file hello.c, line 51
   1.3    process 129975 at 0x401199, file hello.c, line 51
   2.1    process 129965 at 0x401258, file goodbye.c, line 62
   2.2 A  process 129969 at 0x401258, file goodbye.c, line 62
   3.0 A  process 129970 at 0x40115c, file hangout.c, line 31
   3.2    process 129972 at 0x40115c, file hangout.c, line 31

(For brevity, I've removed the directory elements in each of the paths
above.)

The testcase, gdb.multi/checkpoint-multi.exp, has been updated to
reflect the fact that only "process" should now appear in output
from "info checkpoints".
---
 gdb/linux-thread-db.c                        | 4 +++-
 gdb/testsuite/gdb.multi/checkpoint-multi.exp | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c
index 65bf4a79fdf..488a7086acf 100644
--- a/gdb/linux-thread-db.c
+++ b/gdb/linux-thread-db.c
@@ -48,6 +48,7 @@
 #include "gdbsupport/pathstuff.h"
 #include "valprint.h"
 #include "cli/cli-style.h"
+#include "linux-fork.h"
 
 /* GNU/Linux libthread_db support.
 
@@ -1657,7 +1658,8 @@ thread_db_target::pid_to_str (ptid_t ptid)
 {
   thread_info *thread_info = current_inferior ()->find_thread (ptid);
 
-  if (thread_info != NULL && thread_info->priv != NULL)
+  if (thread_info != NULL && thread_info->priv != NULL
+      && !forks_exist_p (current_inferior ()))
     {
       thread_db_thread_info *priv = get_thread_db_thread_info (thread_info);
 
diff --git a/gdb/testsuite/gdb.multi/checkpoint-multi.exp b/gdb/testsuite/gdb.multi/checkpoint-multi.exp
index a880d31d326..755c8e9e0e1 100644
--- a/gdb/testsuite/gdb.multi/checkpoint-multi.exp
+++ b/gdb/testsuite/gdb.multi/checkpoint-multi.exp
@@ -170,7 +170,7 @@ with_test_prefix "check continue to exit on non-checkpointed inferior" {
     gdb_test "continue" "Inferior 1.*? exited normally.*"
 }
 
-set proc_re "(?:process $::decimal|Thread $::hex \\(LWP $::decimal\\))"
+set proc_re "(?:process $::decimal)"
 set main_proc "\\(main process\\)"
 set hello_c "hello\\.c"
 set goodbye_c "goodbye\\.c"
-- 
2.44.0


      parent reply	other threads:[~2024-04-14  3:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-14  3:24 [PATCH v2 0/2] Make linux checkpoints work with multiple inferiors Kevin Buettner
2024-04-14  3:24 ` [PATCH v2 1/2] " Kevin Buettner
2024-04-14  3:24 ` Kevin Buettner [this message]

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=20240414032731.130266-3-kevinb@redhat.com \
    --to=kevinb@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=pedro@palves.net \
    /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).