public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PUSHED] gdb: two changes to linux_nat_debug_printf calls in linux-nat.c
@ 2023-07-23  8:33 Andrew Burgess
  0 siblings, 0 replies; only message in thread
From: Andrew Burgess @ 2023-07-23  8:33 UTC (permalink / raw)
  To: gdb-patches; +Cc: Andrew Burgess

This commit adjusts some of the debug output in linux-nat.c, but makes
no other functional changes to GDB.

In resume_lwp I've added the word "sibling" to one of the debug
messages.  All the other debug messages in this function talk about
operating on the sibling thread, so I think it makes sense, for
consistency, if the message I've updated also talks about the sibling
thread.

In resume_stopped_resumed_lwps I've reordered the condition checks so
that the vfork-parent check now happens after the checks for whether
the thread is already resumed or not.  This makes no functional
difference to GDB, but does, I think, mean we see more helpful debug
messages first.

Consider the situation where a vfork-parent thread is already resumed,
and resume_stopped_resumed_lwps is called.  Previously the message
saying that the thread was not being resumed due to being a
vfork-parent, was printed.  This might give the impression that the
thread is left in a not resumed state, which is misleading.

After this change we now get a message saying that the thread is not
being resumed due to it not being stopped (i.e. is already resumed).
With this message the already resumed nature of the thread is much
clearer.

I found this change helpful when debugging some vfork related issues.
---
 gdb/linux-nat.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index 73008a313c0..250a8f43282 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -1550,7 +1550,7 @@ resume_lwp (struct lwp_info *lp, int step, enum gdb_signal signo)
 
       if (inf->vfork_child != NULL)
 	{
-	  linux_nat_debug_printf ("Not resuming %s (vfork parent)",
+	  linux_nat_debug_printf ("Not resuming sibling %s (vfork parent)",
 				  lp->ptid.to_string ().c_str ());
 	}
       else if (!lwp_status_pending_p (lp))
@@ -3359,12 +3359,7 @@ resume_stopped_resumed_lwps (struct lwp_info *lp, const ptid_t wait_ptid)
 {
   inferior *inf = find_inferior_ptid (linux_target, lp->ptid);
 
-  if (inf->vfork_child != nullptr)
-    {
-      linux_nat_debug_printf ("NOT resuming LWP %s (vfork parent)",
-			      lp->ptid.to_string ().c_str ());
-    }
-  else if (!lp->stopped)
+  if (!lp->stopped)
     {
       linux_nat_debug_printf ("NOT resuming LWP %s, not stopped",
 			      lp->ptid.to_string ().c_str ());
@@ -3379,6 +3374,11 @@ resume_stopped_resumed_lwps (struct lwp_info *lp, const ptid_t wait_ptid)
       linux_nat_debug_printf ("NOT resuming LWP %s, has pending status",
 			      lp->ptid.to_string ().c_str ());
     }
+  else if (inf->vfork_child != nullptr)
+    {
+      linux_nat_debug_printf ("NOT resuming LWP %s (vfork parent)",
+			      lp->ptid.to_string ().c_str ());
+    }
   else
     {
       struct regcache *regcache = get_thread_regcache (linux_target, lp->ptid);

base-commit: dd82bbc1b3e79fb5e072ce4953cafc789333ce82
-- 
2.25.4


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-07-23  8:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-23  8:33 [PUSHED] gdb: two changes to linux_nat_debug_printf calls in linux-nat.c Andrew Burgess

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).