From: Guinevere Larsen <guinevere@redhat.com>
To: gdb-patches@sourceware.org
Cc: Guinevere Larsen <guinevere@redhat.com>
Subject: [PATCH] gdb/record: fix "maint print record-instruction" at the start of log
Date: Tue, 1 Sep 2026 11:33:16 -0300 [thread overview]
Message-ID: <20260901143316.42661-1-guinevere@redhat.com> (raw)
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
next reply other threads:[~2026-09-01 14:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-01 14:33 Guinevere Larsen [this message]
2026-09-01 16:55 ` Tom Tromey
2026-09-02 14:20 ` Guinevere Larsen
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=20260901143316.42661-1-guinevere@redhat.com \
--to=guinevere@redhat.com \
--cc=gdb-patches@sourceware.org \
/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