From: Pedro Alves <pedro@palves.net>
To: Kevin Buettner <kevinb@redhat.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH v4 1/4] Make linux checkpoints work with multiple inferiors
Date: Wed, 23 Oct 2024 21:10:53 +0100 [thread overview]
Message-ID: <c1497147-778a-438b-83a0-83936a61199a@palves.net> (raw)
In-Reply-To: <20240626020148.68109-2-kevinb@redhat.com>
Hi Kevin!
Trying v4 before looking at the code, I saw one behavior that
surprised me. That is when you have two inferiors, and checkpoints
in only one inferior. Like so:
(gdb) info checkpoints
No checkpoints.
(gdb) checkpoint
Checkpoint 1: fork returned pid 66326.
(gdb) info checkpoints
* 0 A process 66173 at 0x555555555258, file threads.c, line 53
1 process 66326 at 0x555555555258, file threads.c, line 53
(gdb) add-inferior
[New inferior 2]
Added inferior 2 on connection 1 (native)
Now in the following command, I was expecting to see 1.0 and 1.1
as checkpoint numbers, since we now have two inferiors, but we only
get the 0 and 1:
(gdb) info checkpoints
* 0 A process 66173 at 0x555555555258, file threads.c, line 53
1 process 66326 at 0x555555555258, file threads.c, line 53
If I switch to inferior 2, and then list checkpoints, I do get
the fully-qualified checkpoint ids:
(gdb) info inferiors
Num Description Connection Executable
* 1 process 66173 1 (native) /net/cascais.nfs/brno/pedro/gdb/tests/threads
2 <null> 1 (native)
(gdb) inferior 2
[Switching to inferior 2 [<null>] (<noexec>)]
(gdb) info checkpoints
1.0 A process 66173 at 0x55555258, file threads.c, line 53
1.1 process 66326 at 0x55555258, file threads.c, line 53
I was expecting to see the same output when inferior 1 is the
one selected. Again, going back to inferior 1:
(gdb) inferior 1
[Switching to inferior 1 [process 66173] (/net/cascais.nfs/brno/pedro/gdb/tests/threads)]
[Switching to thread 1.1 (Thread 0x7ffff7f93740 (LWP 66173))]
#0 main () at threads.c:53
53 int main() {
(gdb) info checkpoints
* 0 A process 66173 at 0x555555555258, file threads.c, line 53
1 process 66326 at 0x555555555258, file threads.c, line 53
(gdb)
Now that I look at the code, I see that the predicate used to
determine whether to show the inferior number is checking if
there are multiple inferiors with checkpoints, so it seems
intentional. But FYI, coming at this with a lot of context
from previous discussion swapped out, I found it confusing.
On the "R" state, thinking some more (since our last discussion),
I wonder if we really need it. In "info threads", we show that
the thread is running in the "frame" column, like:
(gdb) info threads
Id Target Id Frame
* 1 Thread 0x7ffff7f8e740 (LWP 439463) "infloop" (running)
^^^^^^^^^
Maybe we should just reuse the frame-printing code from "info threads".
I tried to reproduce the "R" state here locally, and saw that
it's broken, for trying to fetch registers of a running thread:
(gdb) start
...
(gdb) checkpoint
...
(gdb) info checkpoints
* 0 A process 439463 at 0x7ffff7ce578a, file ../sysdeps/unix/sysv/linux/clock_nanosleep.c, line 78
1 process 439827 at 0x7ffff7ce578a, file ../sysdeps/unix/sysv/linux/clock_nanosleep.c, line 78
(gdb) c&
Continuing.
(gdb) info checkpoints
* 0 AR process 439463 at Couldn't get registers: No such process.
BTW, the documentation patch says that you can only see the "R" state
in non-stop mode:
+one which @value{GDBN} is currently debugging. @code{R} indicates a
+running process; this status letter can only appear when @value{GDBN}
+is running in non-stop mode.
But that's not correct. You can also use the "c&" command in
all-stop mode.
I noticed this because I wanted to try what it say here:
If neither @code{A} or @code{R} are present,
+this indicates a checkpoint which can be switched to using the
+@code{restart} command or deleted using the @code{delete checkpoint}
+command.
... specifically, I wanted to try switching to a checkpoint in the "R"
state, check that GDB behaves properly.
Other than the issues above, this all LGTM. Some trivial typos
pointed out below.
Pedro Alves
On 2024-06-26 02:55, Kevin Buettner wrote:
> The functions 'find_fork_ptid' and 'find_fork_pid' used to return a
> pointer to a fork_info struct. They now return a pair consisting of
> the pointer to a fork_info struct in addition to a pointer to the
> inferior containing that checkpoint.
>
> 'find_fork_id' returns a a pointer to a fork_info struct just as
Typo, double "a a".
> it did before, but it's now gained a new parameter, 'inf', which
> is the inferior in which to look.
>
> info_checkpoints_command used to simply iterate over the list of
> forks (checkpoints), printing each one out. It now needs to iterate
> over all inferiors and, for those which have checkpoints, it needs
> to iterate over the list of checkpoints in that inferior. As noted
> earlier, the format of the output has been changed so that checkpoint
> identifers incorporating an inferior number may be printed.
identifers -> identifiers
>
> linux_fork_context, called by restart_command, now contains code to
> switch inferiors when the fork being restarted is in an inferior which
> is different from the current one. The scoped_switch_fork_info class
> now also contains code for switching inferiors in both the constructor
> and destructor.
>
next prev parent reply other threads:[~2024-10-23 20:11 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-26 1:55 [PATCH v4 0/4] " Kevin Buettner
2024-06-26 1:55 ` [PATCH v4 1/4] " Kevin Buettner
2024-10-23 20:10 ` Pedro Alves [this message]
2024-10-31 3:04 ` Kevin Buettner
2024-11-11 18:40 ` Pedro Alves
2024-06-26 1:55 ` [PATCH v4 2/4] Capitalize output of successful checkpoint command Kevin Buettner
2024-06-26 1:55 ` [PATCH v4 3/4] Print only process ptids from linux-fork.c Kevin Buettner
2024-06-26 1:55 ` [PATCH v4 4/4] Linux checkpoints: Update NEWS and gdb.texinfo regarding multiple inferiors Kevin Buettner
2024-06-26 12:25 ` Eli Zaretskii
2024-09-07 18:12 ` [PATCH v4 0/4] Make linux checkpoints work with " Kevin Buettner
2024-09-30 3:39 ` Kevin Buettner
2024-10-21 18:21 ` Kevin Buettner
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=c1497147-778a-438b-83a0-83936a61199a@palves.net \
--to=pedro@palves.net \
--cc=gdb-patches@sourceware.org \
--cc=kevinb@redhat.com \
/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