public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug gdb/31211] New: [gdb] info checkpoints show incorrect info
@ 2024-01-04 14:40 vries at gcc dot gnu.org
  2024-01-04 14:48 ` [Bug gdb/31211] " vries at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: vries at gcc dot gnu.org @ 2024-01-04 14:40 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=31211

            Bug ID: 31211
           Summary: [gdb] info checkpoints show incorrect info
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot org
          Reporter: vries at gcc dot gnu.org
  Target Milestone: ---

Consider test-case test.c:
...
$ cat test.c
#include <stdio.h>

int
main (void)
{
  printf ("1\n");
  printf ("2\n");
  printf ("3\n");
  printf ("4\n");
  printf ("5\n");
  printf ("6\n");
  printf ("7\n");
  printf ("8\n");
  printf ("9\n");
  printf ("10\n");

  return 0;
}
...

Compiled with:
...
$ gcc -g test.c
...

Let's look at the output of "info checkpoints":
...
$ gdb -q a.out
Reading symbols from a.out...
(gdb) start
Temporary breakpoint 1 at 0x40051b: file test.c, line 6.
Starting program: /data/vries/gdb/a.out 

Temporary breakpoint 1, main () at test.c:6
6         printf ("1\n");
(gdb) info checkpoints
No checkpoints.
...

OK, sofar so good.  Now let's add a checkpoint:
...
(gdb) checkpoint
checkpoint 1: fork returned pid 7886.
(gdb) info checkpoints 
* 0 process 7881 (main process) at 0x0
  1 process 7886 at 0x40051b, file test.c, line 6
...

The documentation says checkpoints, but what we really have is fork
child/parent, which are initially equal, so it's odd that they're not both
shown with "at 0x40051b, file test.c, line 6".

After switching to checkpoint 1, we have:
...
(gdb) restart 1
Switching to process 7886
#0  main () at test.c:6
6         printf ("1\n");
(gdb) info checkpoints 
  0 process 7881 (main process) at 0x40051b, file test.c, line 6
* 1 process 7886 at 0x40051b, file test.c, line 6
(gdb) 
...
OK, so now they're indeed equal.

Let's see what happens when we step to the next line:
...
(gdb) next
1
7         printf ("2\n");
(gdb) info checkpoints 
  0 process 7881 (main process) at 0x40051b, file test.c, line 6
* 1 process 7886 at 0x40051b, file test.c, line 6
(gdb) 
...
Hmm, the line number didn't change.

So, are we stuck at line 6?  Let's try switching forth and back:
...
(gdb) restart 0
Switching to process 7881
#0  main () at test.c:6
6         printf ("1\n");
(gdb) info checkpoints
* 0 process 7881 (main process) at 0x40051b, file test.c, line 6
  1 process 7886 at 0x400525, file test.c, line 7
(gdb) restart 1
Switching to process 7886
#0  main () at test.c:7
7         printf ("2\n");
(gdb) info checkpoints
  0 process 7881 (main process) at 0x40051b, file test.c, line 6
* 1 process 7886 at 0x400525, file test.c, line 7
(gdb) 
...
Now the line is updated to 7.

So, it seems info checkpoints show outdated info for the current fork.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug gdb/31211] [gdb] info checkpoints show incorrect info
  2024-01-04 14:40 [Bug gdb/31211] New: [gdb] info checkpoints show incorrect info vries at gcc dot gnu.org
@ 2024-01-04 14:48 ` vries at gcc dot gnu.org
  2024-01-08 15:26 ` vries at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: vries at gcc dot gnu.org @ 2024-01-04 14:48 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=31211

--- Comment #1 from Tom de Vries <vries at gcc dot gnu.org> ---
With this patch:
...
diff --git a/gdb/linux-fork.c b/gdb/linux-fork.c
index 1430ff89fa7..4f34c72ef8e 100644
--- a/gdb/linux-fork.c
+++ b/gdb/linux-fork.c
@@ -594,12 +594,13 @@ info_checkpoints_command (const char *arg, int from_tty)
        continue;

       printed = &fi;
-      if (fi.ptid == inferior_ptid)
+      bool is_current = fi.ptid == inferior_ptid;
+      if (is_current)
        gdb_printf ("* ");
       else
        gdb_printf ("  ");

-      ULONGEST pc = fi.pc;
+      ULONGEST pc = is_current ? get_frame_pc (get_current_frame ()) : fi.pc ;
       gdb_printf ("%d %s", fi.num, target_pid_to_str (fi.ptid).c_str ());
       if (fi.num == 0)
        gdb_printf (_(" (main process)"));
...
we get:
...
$ gdb -q a.out
Reading symbols from a.out...
(gdb) start
Temporary breakpoint 1 at 0x40051b: file test.c, line 6.
Starting program: /data/vries/gdb/a.out 

Temporary breakpoint 1, main () at test.c:6
6         printf ("1\n");
(gdb) checkpoint
checkpoint 1: fork returned pid 9696.
(gdb) info checkpoint
* 0 process 9693 (main process) at 0x40051b, file test.c, line 6
  1 process 9696 at 0x40051b, file test.c, line 6
(gdb) n
1
7         printf ("2\n");
(gdb) info checkpoint
* 0 process 9693 (main process) at 0x400525, file test.c, line 7
  1 process 9696 at 0x40051b, file test.c, line 6
(gdb) 
...

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug gdb/31211] [gdb] info checkpoints show incorrect info
  2024-01-04 14:40 [Bug gdb/31211] New: [gdb] info checkpoints show incorrect info vries at gcc dot gnu.org
  2024-01-04 14:48 ` [Bug gdb/31211] " vries at gcc dot gnu.org
@ 2024-01-08 15:26 ` vries at gcc dot gnu.org
  2024-01-10 10:27 ` cvs-commit at gcc dot gnu.org
  2024-01-10 10:27 ` vries at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: vries at gcc dot gnu.org @ 2024-01-08 15:26 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=31211

--- Comment #2 from Tom de Vries <vries at gcc dot gnu.org> ---
https://sourceware.org/pipermail/gdb-patches/2024-January/205705.html

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug gdb/31211] [gdb] info checkpoints show incorrect info
  2024-01-04 14:40 [Bug gdb/31211] New: [gdb] info checkpoints show incorrect info vries at gcc dot gnu.org
  2024-01-04 14:48 ` [Bug gdb/31211] " vries at gcc dot gnu.org
  2024-01-08 15:26 ` vries at gcc dot gnu.org
@ 2024-01-10 10:27 ` cvs-commit at gcc dot gnu.org
  2024-01-10 10:27 ` vries at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-01-10 10:27 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=31211

--- Comment #3 from Sourceware Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tom de Vries <vries@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=cdf2a0febd8a20ef74e782bdf4493536535d33a8

commit cdf2a0febd8a20ef74e782bdf4493536535d33a8
Author: Tom de Vries <tdevries@suse.de>
Date:   Wed Jan 10 11:27:34 2024 +0100

    [gdb] Fix info checkpoints

    Consider test-case gdb.base/checkpoint.exp.  At some point, it issues an
info
    checkpoints command:
    ...
    (gdb) info checkpoints^M
    * 0 process 30570 (main process) at 0x0^M
      1 process 30573 at 0x4008bb, file checkpoint.c, line 49^M
      2 process 30574 at 0x4008bb, file checkpoint.c, line 49^M
      3 process 30575 at 0x4008bb, file checkpoint.c, line 49^M
      4 process 30576 at 0x4008bb, file checkpoint.c, line 49^M
      5 process 30577 at 0x4008bb, file checkpoint.c, line 49^M
      6 process 30578 at 0x4008bb, file checkpoint.c, line 49^M
      7 process 30579 at 0x4008bb, file checkpoint.c, line 49^M
      8 process 30580 at 0x4008bb, file checkpoint.c, line 49^M
      9 process 30582 at 0x4008bb, file checkpoint.c, line 49^M
      10 process 30583 at 0x4008bb, file checkpoint.c, line 49^M
    ...

    According to the docs, each of these (0-10) is a checkpoint.

    But the pc address (as well as the file name and line number) is missing
for
    checkpoint 0.

    Fix this by sampling the pc value for the current process in
    info_checkpoints_command, such that we have instead:
    ...
    * 0 process 30570 (main process) at 0x4008bb, file checkpoint.c, line 49^M
    ...

    Tested on x86_64-linux.

    Approved-By: Kevin Buettner <kevinb@redhat.com>

    PR gdb/31211
    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31211

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug gdb/31211] [gdb] info checkpoints show incorrect info
  2024-01-04 14:40 [Bug gdb/31211] New: [gdb] info checkpoints show incorrect info vries at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2024-01-10 10:27 ` cvs-commit at gcc dot gnu.org
@ 2024-01-10 10:27 ` vries at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: vries at gcc dot gnu.org @ 2024-01-10 10:27 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=31211

Tom de Vries <vries at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |15.1
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #4 from Tom de Vries <vries at gcc dot gnu.org> ---
Fixed.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-01-10 10:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-04 14:40 [Bug gdb/31211] New: [gdb] info checkpoints show incorrect info vries at gcc dot gnu.org
2024-01-04 14:48 ` [Bug gdb/31211] " vries at gcc dot gnu.org
2024-01-08 15:26 ` vries at gcc dot gnu.org
2024-01-10 10:27 ` cvs-commit at gcc dot gnu.org
2024-01-10 10:27 ` vries at gcc dot gnu.org

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