Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] gdb/record: fix "maint print record-instruction" at the start of log
@ 2026-09-01 14:33 Guinevere Larsen
  2026-09-01 16:55 ` Tom Tromey
  0 siblings, 1 reply; 3+ messages in thread
From: Guinevere Larsen @ 2026-09-01 14:33 UTC (permalink / raw)
  To: gdb-patches; +Cc: Guinevere Larsen

My recent commit:

    commit caa9d8df0fca004a48cd9fd5048abaaaf2dd3eb1
    Author: Guinevere Larsen <guinevere@redhat.com>
    Date:   Thu May 28 15:36:33 2026 -0300
    gdb/record: Refactor record history

Caused a regression where, if a user was at the start of the record
history and used the command "maint print record-instruction", GDB
would throw an internal error for trying to print an out-of-bounds
record. This commit fixes this by making the check for out of bounds
printing independent of an argument being supplied.
---
 gdb/record-full.c                                     | 10 +++++-----
 gdb/testsuite/gdb.reverse/maint-print-instruction.exp |  5 +++++
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/gdb/record-full.c b/gdb/record-full.c
index aa451c05a5d..f6d603d2357 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -2796,11 +2796,11 @@ maintenance_print_record_instruction (const char *args, int from_tty)
   if (offset == record_full_log.size ())
     offset--;
   if (args != nullptr)
-    {
-      offset += value_as_long (parse_and_eval (args));
-      if (offset >= record_full_log.size () || offset < 0)
-	error (_("Not enough recorded history"));
-    }
+    offset += value_as_long (parse_and_eval (args));
+
+  if (offset >= record_full_log.size () || offset < 0)
+    error (_("Not enough recorded history"));
+
   auto to_print = record_full_log.begin () + offset;
 
   gdbarch *arch = current_inferior ()->arch ();
diff --git a/gdb/testsuite/gdb.reverse/maint-print-instruction.exp b/gdb/testsuite/gdb.reverse/maint-print-instruction.exp
index edf6ec081cd..199adebf08b 100644
--- a/gdb/testsuite/gdb.reverse/maint-print-instruction.exp
+++ b/gdb/testsuite/gdb.reverse/maint-print-instruction.exp
@@ -73,3 +73,8 @@ test_print true "1" "print following after reversing"
 
 test_print false "-10" "trying to print too far back"
 test_print false "10" "trying to print too far forward"
+
+# Return to the beginning of history and print.
+# This used to cause an internal error.
+gdb_test "reverse-continue" ".*" "moving to start of history"
+test_print false "" "Print at the start of history"

base-commit: 6f24afa4391bd33f1263378280b99385d2c13055
-- 
2.55.0


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

* Re: [PATCH] gdb/record: fix "maint print record-instruction" at the start of log
  2026-09-01 14:33 [PATCH] gdb/record: fix "maint print record-instruction" at the start of log Guinevere Larsen
@ 2026-09-01 16:55 ` Tom Tromey
  2026-09-02 14:20   ` Guinevere Larsen
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2026-09-01 16:55 UTC (permalink / raw)
  To: Guinevere Larsen; +Cc: gdb-patches

>>>>> "Guinevere" == Guinevere Larsen <guinevere@redhat.com> writes:

Guinevere> Caused a regression where, if a user was at the start of the record
Guinevere> history and used the command "maint print record-instruction", GDB
Guinevere> would throw an internal error for trying to print an out-of-bounds
Guinevere> record. This commit fixes this by making the check for out of bounds
Guinevere> printing independent of an argument being supplied.

Looks reasonable to me.
Approved-By: Tom Tromey <tom@tromey.com>

thanks,
Tom

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

* Re: [PATCH] gdb/record: fix "maint print record-instruction" at the start of log
  2026-09-01 16:55 ` Tom Tromey
@ 2026-09-02 14:20   ` Guinevere Larsen
  0 siblings, 0 replies; 3+ messages in thread
From: Guinevere Larsen @ 2026-09-02 14:20 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches


On 9/1/26 1:55 PM, Tom Tromey wrote:
>>>>>> "Guinevere" == Guinevere Larsen <guinevere@redhat.com> writes:
> Guinevere> Caused a regression where, if a user was at the start of the record
> Guinevere> history and used the command "maint print record-instruction", GDB
> Guinevere> would throw an internal error for trying to print an out-of-bounds
> Guinevere> record. This commit fixes this by making the check for out of bounds
> Guinevere> printing independent of an argument being supplied.
>
> Looks reasonable to me.
> Approved-By: Tom Tromey <tom@tromey.com>
Thanks for the quick review, pushed!
> thanks,
> Tom
>
-- 
Cheers,
Guinevere Larsen
it/its
she/her (deprecated)


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

end of thread, other threads:[~2026-09-02 14:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-01 14:33 [PATCH] gdb/record: fix "maint print record-instruction" at the start of log Guinevere Larsen
2026-09-01 16:55 ` Tom Tromey
2026-09-02 14:20   ` Guinevere Larsen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox