From 8a9da63e407c511df32841abcbe20effe2f3e398 Mon Sep 17 00:00:00 2001 From: Andrew Burgess Date: Sat, 22 Jul 2023 15:28:28 +0100 Subject: [PATCH] gdb: two changes to linux_nat_debug_printf calls in linux-nat.c 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); -- 2.30.2