]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb] Fix info checkpoints
authorTom de Vries <tdevries@suse.de>
Wed, 10 Jan 2024 10:27:34 +0000 (11:27 +0100)
committerTom de Vries <tdevries@suse.de>
Wed, 10 Jan 2024 10:27:34 +0000 (11:27 +0100)
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

gdb/linux-fork.c
gdb/testsuite/gdb.base/checkpoint.exp

index 177a012ec08ce30b99909ee5e4a5bac7f7e711c2..659264ab712922cbacf2f96e18d1004b98027fcd 100644 (file)
@@ -594,16 +594,27 @@ info_checkpoints_command (const char *arg, int from_tty)
        continue;
       printed = true;
 
-      if (fi.ptid == inferior_ptid)
+      bool is_current = fi.ptid == inferior_ptid;
+      if (is_current)
        gdb_printf ("* ");
       else
        gdb_printf ("  ");
 
-      ULONGEST pc = fi.pc;
       gdb_printf ("%d %s", fi.num, target_pid_to_str (fi.ptid).c_str ());
       if (fi.num == 0)
        gdb_printf (_(" (main process)"));
+
+      if (is_current && inferior_thread ()->state == THREAD_RUNNING)
+       {
+         gdb_printf (_(" <running>\n"));
+         continue;
+       }
+
       gdb_printf (_(" at "));
+      ULONGEST pc
+       = (is_current
+          ? regcache_read_pc (get_thread_regcache (inferior_thread ()))
+          : fi.pc);
       gdb_puts (paddress (gdbarch, pc));
 
       symtab_and_line sal = find_pc_line (pc, 0);
index a4ea94354b724bc65740e996f017372774225f6c..9ba5b3e82ec3cc1df05e85fa86a3e86edae4f8ad 100644 (file)
@@ -84,9 +84,11 @@ gdb_test "checkpoint" "" "checkpoint nine"
 gdb_test "continue 10" "breakpoint 1.*" "break1 ten"
 gdb_test "checkpoint" "" "checkpoint ten"
 
-gdb_test "info checkpoints" \
-    " 1 .* 2 .* 3 .* 4 .* 5 .* 6 .* 7 .* 8 .* 9 .* 10 .*" \
-    "info checkpoints one"
+set info_checkpoints_re ""
+for { set i 0 } { $i <= 10 } { incr i } {
+    append info_checkpoints_re " $i .* file .*"
+}
+gdb_test "info checkpoints" $info_checkpoints_re "info checkpoints one"
 
 delete_breakpoints
 gdb_breakpoint $break2_loc