From: Pedro Alves <pedro@palves.net>
To: Andrew Burgess <aburgess@redhat.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH 02/31] linux-nat: introduce pending_status_str
Date: Fri, 10 Mar 2023 17:15:18 +0000 [thread overview]
Message-ID: <f5f32303-0c93-ef05-b4b4-1105d0db49c0@palves.net> (raw)
In-Reply-To: <87cz6rrma6.fsf@redhat.com>
On 2023-02-03 12:00 p.m., Andrew Burgess wrote:
> Pedro Alves <pedro@palves.net> writes:
>
>> I noticed that some debug log output printing an lwp's pending status
>> wasn't considering lp->waitstatus. This fixes it, by introducing a
>> new pending_status_str function.
>
> This patch looks fine. I had one slightly related question: I took a
> look at the comment on lwp_info::waitstatus in linux-nat.h, which says:
>
> /* If WAITSTATUS->KIND != TARGET_WAITKIND_SPURIOUS, the waitstatus
> for this LWP's last event. This may correspond to STATUS above,
> or to a local variable in lin_lwp_wait. */
> struct target_waitstatus waitstatus;
>
> Am I right in thinking that this comment is wrong; it should say
> TARGET_WAITKIND_IGNORE, not TARGET_WAITKIND_SPURIOUS, right?
You're right.
I tweaked the comments in linux-nat.h in this new version. Let me know what
you think.
From 10f88baff2e25fb87f37d1665bf283206171dd42 Mon Sep 17 00:00:00 2001
From: Pedro Alves <pedro@palves.net>
Date: Fri, 12 Nov 2021 20:50:29 +0000
Subject: [PATCH] linux-nat: introduce pending_status_str
I noticed that some debug log output printing an lwp's pending status
wasn't considering lp->waitstatus. This fixes it, by introducing a
new pending_status_str function.
Also fix the comment in gdb/linux-nat.h describing
lwp_info::waitstatus and details the description of lwp_info::status
while at it.
Change-Id: I66e5c7a363d30a925b093b195d72925ce5b6b980
---
gdb/linux-nat.c | 19 ++++++++++++++++---
gdb/linux-nat.h | 11 +++++++----
2 files changed, 23 insertions(+), 7 deletions(-)
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index e5391b9ce35..9d811bbf3ff 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -255,6 +255,19 @@ is_leader (lwp_info *lp)
return lp->ptid.pid () == lp->ptid.lwp ();
}
+/* Convert an LWP's pending status to a std::string. */
+
+static std::string
+pending_status_str (lwp_info *lp)
+{
+ gdb_assert (lwp_status_pending_p (lp));
+
+ if (lp->waitstatus.kind () != TARGET_WAITKIND_IGNORE)
+ return lp->waitstatus.to_string ();
+ else
+ return status_to_str (lp->status);
+}
+
\f
/* LWP accessors. */
@@ -1647,8 +1660,8 @@ linux_nat_target::resume (ptid_t scope_ptid, int step, enum gdb_signal signo)
this thread with a signal? */
gdb_assert (signo == GDB_SIGNAL_0);
- linux_nat_debug_printf ("Short circuiting for status 0x%x",
- lp->status);
+ linux_nat_debug_printf ("Short circuiting for status %s",
+ pending_status_str (lp).c_str ());
if (target_can_async_p ())
{
@@ -3137,7 +3150,7 @@ linux_nat_wait_1 (ptid_t ptid, struct target_waitstatus *ourstatus,
if (lp != NULL)
{
linux_nat_debug_printf ("Using pending wait status %s for %s.",
- status_to_str (lp->status).c_str (),
+ pending_status_str (lp).c_str (),
lp->ptid.to_string ().c_str ());
}
diff --git a/gdb/linux-nat.h b/gdb/linux-nat.h
index 45534c92386..770fe924427 100644
--- a/gdb/linux-nat.h
+++ b/gdb/linux-nat.h
@@ -232,7 +232,9 @@ struct lwp_info : intrusive_list_node<lwp_info>
/* The last resume GDB requested on this thread. */
resume_kind last_resume_kind = resume_continue;
- /* If non-zero, a pending wait status. */
+ /* If non-zero, a pending wait status. A pending process exit is
+ recorded in WAITSTATUS, because W_EXITCODE(0,0) happens to be
+ 0. */
int status = 0;
/* When 'stopped' is set, this is where the lwp last stopped, with
@@ -260,9 +262,10 @@ struct lwp_info : intrusive_list_node<lwp_info>
/* Non-zero if we expect a duplicated SIGINT. */
int ignore_sigint = 0;
- /* If WAITSTATUS->KIND != TARGET_WAITKIND_SPURIOUS, the waitstatus
- for this LWP's last event. This may correspond to STATUS above,
- or to a local variable in lin_lwp_wait. */
+ /* If WAITSTATUS->KIND != TARGET_WAITKIND_IGNORE, the waitstatus for
+ this LWP's last event. This usually corresponds to STATUS above,
+ however because W_EXITCODE(0,0) happens to be 0, a process exit
+ will be recorded here, while 'status == 0' is ambiguous. */
struct target_waitstatus waitstatus;
/* Signal whether we are in a SYSCALL_ENTRY or
base-commit: 2562954ede66f32bff7d985e752b8052c2ae5775
prerequisite-patch-id: bbc9918ac5f79de07a29f34ec072794d270f942d
--
2.36.0
next prev parent reply other threads:[~2023-03-10 17:15 UTC|newest]
Thread overview: 100+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-12 20:30 [PATCH 00/31] Step over thread clone and thread exit Pedro Alves
2022-12-12 20:30 ` [PATCH 01/31] displaced step: pass down target_waitstatus instead of gdb_signal Pedro Alves
2023-02-03 10:44 ` Andrew Burgess via Gdb-patches
2023-03-10 17:15 ` Pedro Alves
2023-03-16 16:07 ` Andrew Burgess via Gdb-patches
2023-03-22 21:29 ` Andrew Burgess via Gdb-patches
2023-03-23 15:15 ` Pedro Alves
2023-03-27 12:40 ` Andrew Burgess via Gdb-patches
2023-03-27 16:21 ` Pedro Alves
2022-12-12 20:30 ` [PATCH 02/31] linux-nat: introduce pending_status_str Pedro Alves
2023-02-03 12:00 ` Andrew Burgess via Gdb-patches
2023-03-10 17:15 ` Pedro Alves [this message]
2023-03-16 16:19 ` Andrew Burgess via Gdb-patches
2023-03-27 18:05 ` Pedro Alves
2022-12-12 20:30 ` [PATCH 03/31] gdb/linux: Delete all other LWPs immediately on ptrace exec event Pedro Alves
2023-03-21 14:50 ` Andrew Burgess via Gdb-patches
2023-04-04 13:57 ` Pedro Alves
2023-04-14 19:29 ` Pedro Alves
2023-05-26 15:04 ` Andrew Burgess via Gdb-patches
2023-11-13 14:04 ` Pedro Alves
2023-05-26 14:45 ` Andrew Burgess via Gdb-patches
2022-12-12 20:30 ` [PATCH 04/31] Step over clone syscall w/ breakpoint, TARGET_WAITKIND_THREAD_CLONED Pedro Alves
2023-02-04 15:38 ` Andrew Burgess via Gdb-patches
2023-03-10 17:16 ` Pedro Alves
2023-03-21 16:06 ` Andrew Burgess via Gdb-patches
2023-11-13 14:05 ` Pedro Alves
2022-12-12 20:30 ` [PATCH 05/31] Support clone events in the remote protocol Pedro Alves
2023-03-22 15:46 ` Andrew Burgess via Gdb-patches
2023-11-13 14:05 ` Pedro Alves
2022-12-12 20:30 ` [PATCH 06/31] Avoid duplicate QThreadEvents packets Pedro Alves
2023-05-26 15:53 ` Andrew Burgess via Gdb-patches
2022-12-12 20:30 ` [PATCH 07/31] enum_flags to_string Pedro Alves
2023-01-30 20:07 ` Simon Marchi via Gdb-patches
2022-12-12 20:30 ` [PATCH 08/31] Thread options & clone events (core + remote) Pedro Alves
2023-01-31 12:25 ` Lancelot SIX via Gdb-patches
2023-03-10 19:16 ` Pedro Alves
2023-06-06 13:29 ` Andrew Burgess via Gdb-patches
2023-11-13 14:07 ` Pedro Alves
2022-12-12 20:30 ` [PATCH 09/31] Thread options & clone events (native Linux) Pedro Alves
2023-06-06 13:43 ` Andrew Burgess via Gdb-patches
2022-12-12 20:30 ` [PATCH 10/31] Thread options & clone events (Linux GDBserver) Pedro Alves
2023-06-06 14:12 ` Andrew Burgess via Gdb-patches
2023-11-13 14:07 ` Pedro Alves
2022-12-12 20:30 ` [PATCH 11/31] gdbserver: Hide and don't detach pending clone children Pedro Alves
2023-06-07 16:10 ` Andrew Burgess via Gdb-patches
2023-11-13 14:08 ` Pedro Alves
2022-12-12 20:30 ` [PATCH 12/31] Remove gdb/19675 kfails (displaced stepping + clone) Pedro Alves
2023-06-07 17:08 ` Andrew Burgess via Gdb-patches
2022-12-12 20:30 ` [PATCH 13/31] Add test for stepping over clone syscall Pedro Alves
2023-06-07 17:42 ` Andrew Burgess via Gdb-patches
2023-11-13 14:09 ` Pedro Alves
2022-12-12 20:30 ` [PATCH 14/31] all-stop/synchronous RSP support thread-exit events Pedro Alves
2023-06-07 17:52 ` Andrew Burgess via Gdb-patches
2023-11-13 14:11 ` Pedro Alves
2023-12-15 18:15 ` Pedro Alves
2022-12-12 20:30 ` [PATCH 15/31] gdbserver/linux-low.cc: Ignore event_ptid if TARGET_WAITKIND_IGNORE Pedro Alves
2022-12-12 20:30 ` [PATCH 16/31] Move deleting thread on TARGET_WAITKIND_THREAD_EXITED to core Pedro Alves
2023-06-08 12:27 ` Andrew Burgess via Gdb-patches
2022-12-12 20:30 ` [PATCH 17/31] Introduce GDB_THREAD_OPTION_EXIT thread option, fix step-over-thread-exit Pedro Alves
2023-06-08 13:17 ` Andrew Burgess via Gdb-patches
2022-12-12 20:30 ` [PATCH 18/31] Implement GDB_THREAD_OPTION_EXIT support for Linux GDBserver Pedro Alves
2023-06-08 14:14 ` Andrew Burgess via Gdb-patches
2022-12-12 20:30 ` [PATCH 19/31] Implement GDB_THREAD_OPTION_EXIT support for native Linux Pedro Alves
2023-06-08 14:17 ` Andrew Burgess via Gdb-patches
2022-12-12 20:30 ` [PATCH 20/31] gdb: clear step over information on thread exit (PR gdb/27338) Pedro Alves
2023-06-08 15:29 ` Andrew Burgess via Gdb-patches
2022-12-12 20:30 ` [PATCH 21/31] stop_all_threads: (re-)enable async before waiting for stops Pedro Alves
2023-06-08 15:49 ` Andrew Burgess via Gdb-patches
2023-11-13 14:12 ` Pedro Alves
2022-12-12 20:30 ` [PATCH 22/31] gdbserver: Queue no-resumed event after thread exit Pedro Alves
2023-06-08 18:16 ` Andrew Burgess via Gdb-patches
2023-11-13 14:12 ` Pedro Alves
2022-12-12 20:30 ` [PATCH 23/31] Don't resume new threads if scheduler-locking is in effect Pedro Alves
2023-06-08 18:24 ` Andrew Burgess via Gdb-patches
2023-11-13 14:12 ` Pedro Alves
2022-12-12 20:30 ` [PATCH 24/31] Report thread exit event for leader if reporting thread exit events Pedro Alves
2023-06-09 13:11 ` Andrew Burgess via Gdb-patches
2022-12-12 20:30 ` [PATCH 25/31] Ignore failure to read PC when resuming Pedro Alves
2023-06-10 10:33 ` Andrew Burgess via Gdb-patches
2023-11-13 14:13 ` Pedro Alves
2022-12-12 20:30 ` [PATCH 26/31] gdb/testsuite/lib/my-syscalls.S: Refactor new SYSCALL macro Pedro Alves
2023-06-10 10:33 ` Andrew Burgess via Gdb-patches
2022-12-12 20:30 ` [PATCH 27/31] Testcases for stepping over thread exit syscall (PR gdb/27338) Pedro Alves
2023-06-12 9:53 ` Andrew Burgess via Gdb-patches
2022-12-12 20:30 ` [PATCH 28/31] Document remote clone events, and QThreadOptions packet Pedro Alves
2023-06-05 15:53 ` Andrew Burgess via Gdb-patches
2023-11-13 14:13 ` Pedro Alves
2023-06-12 12:06 ` Andrew Burgess via Gdb-patches
2023-11-13 14:15 ` Pedro Alves
2022-12-12 20:30 ` [PATCH 29/31] inferior::clear_thread_list always silent Pedro Alves
2023-06-12 12:20 ` Andrew Burgess via Gdb-patches
2022-12-12 20:31 ` [PATCH 30/31] Centralize "[Thread ...exited]" notifications Pedro Alves
2023-02-04 16:05 ` Andrew Burgess via Gdb-patches
2023-03-10 17:21 ` Pedro Alves
2023-02-16 15:40 ` Andrew Burgess via Gdb-patches
2023-06-12 12:23 ` Andrew Burgess via Gdb-patches
2022-12-12 20:31 ` [PATCH 31/31] Cancel execution command on thread exit, when stepping, nexting, etc Pedro Alves
2023-06-12 13:12 ` Andrew Burgess via Gdb-patches
2023-01-24 19:47 ` [PATCH v3 00/31] Step over thread clone and thread exit Pedro Alves
2023-11-13 14:24 ` [PATCH " Pedro Alves
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=f5f32303-0c93-ef05-b4b4-1105d0db49c0@palves.net \
--to=pedro@palves.net \
--cc=aburgess@redhat.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