Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Kevin Buettner <kevinb@redhat.com>
To: Pedro Alves <pedro@palves.net>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH v4 1/4] Make linux checkpoints work with multiple inferiors
Date: Wed, 30 Oct 2024 20:04:34 -0700	[thread overview]
Message-ID: <20241030200434.46738394@f40-zbm-amd> (raw)
In-Reply-To: <c1497147-778a-438b-83a0-83936a61199a@palves.net>

On Wed, 23 Oct 2024 21:10:53 +0100
Pedro Alves <pedro@palves.net> wrote:

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

As you say, it was intentional, but it's easy enough to change it
to always print fully-qualified ids when there are multiple inferiors.
I'll make that change (and will update the test case).

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

The current linux-fork.c code prints <running>.  In the v1 series, I
had used '*' and '+' as the first character to indicate the active
forks, with '*' also indicating the active inferior.  You recommended
that I instead use a state character "A" and dispense with the '+'
indicators.  Well, since we have one state character, why not another,
hence "R".  (It makes the output more compact.) If we change "R" to
"(running)", the state character "A" seems a little odd to me; why not
say "(active)" or, instead, use a compact method of indicating active
forks as I did in my v1 patch.

But perhaps this is needless bike-shedding.  If you really want it to
be "(running)", I'll change it.  But do give some thought about whether
the state character "A" still makes sense.

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

I'll look into the various problems that you mention above and will
also look at adding some more tests.  (I'll fix the nits for the v5
series too.)

Kevin


  reply	other threads:[~2024-10-31  3:05 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
2024-10-31  3:04     ` Kevin Buettner [this message]
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=20241030200434.46738394@f40-zbm-amd \
    --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