gdb/record: fix "maint print record-instruction" at the start of log
Checks
| Context |
Check |
Description |
| linaro-tcwg-bot/tcwg_gdb_build--master-arm |
success
|
Build passed
|
| linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 |
success
|
Build passed
|
| linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 |
success
|
Test passed
|
Commit Message
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(-)
base-commit: 6f24afa4391bd33f1263378280b99385d2c13055
Comments
>>>>> "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
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
>
@@ -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 ();
@@ -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"