From: Guinevere Larsen <guinevere@redhat.com>
To: gdb-patches@sourceware.org, guinevere@redhat.com
Subject: [PING][PATCH v2] gdb/record: fix missing "no history" message in some situations
Date: Thu, 24 Sep 2026 09:52:03 -0300 [thread overview]
Message-ID: <3b277d88-0eb9-40e2-890c-44cb6135148d@redhat.com> (raw)
In-Reply-To: <20260908205344.95713-1-guinevere@redhat.com>
Ping!
I plan on pushing this change next week if there's no comments
On 9/8/26 5:53 PM, Guinevere Larsen wrote:
> I recently noticed that the end of recorded history message wasn't
> shown when replaying an inferior until the end for the first time, it
> was only shown when trying to reverse past the start of
> history. Executing forward past the end will not warn the user that
> recording is going to start again, it just does so. This is the
> behavior before the change:
>
> (gdb) start
> Temporary breakpoint 1 at 0x40044a: file t.c, line 2.
> Starting program: /home/glarsen/a.out
> [Thread debugging using libthread_db enabled]
> Using host libthread_db library "/lib64/libthread_db.so.1".
>
> Temporary breakpoint 1, main () at t.c:2
> 2 int x = 0;
> (gdb) record
> (gdb) n
> 3 x ++;
> (gdb) rn
>
> Reached end of recorded history; stopping.
> Backward execution from here not possible.
> main () at t.c:2
> 2 int x = 0;
> (gdb) n
>
> Reached end of recorded history; stopping.
> Following forward execution will be added to history.
> main () at t.c:3
> 3 x ++;
> (gdb)
>
> And this is the behavior after the change:
>
> (gdb) start
> Temporary breakpoint 1 at 0x40044a: file t.c, line 2.
> Starting program: /home/glarsen/a.out
> [Thread debugging using libthread_db enabled]
> Using host libthread_db library "/lib64/libthread_db.so.1".
>
> Temporary breakpoint 1, main () at t.c:2
> 2 int x = 0;
> (gdb) record
> (gdb) n
> 3 x ++;
> (gdb) rn
> 2 int x = 0;
> (gdb) rn
>
> Reached end of recorded history; stopping.
> Backward execution from here not possible.
> main () at t.c:2
> 2 int x = 0;
> (gdb) n
> 3 x ++;
> (gdb) n
> 4 return x;
>
> This was happening because the out-of-history was only set when it
> caused the execution loop to stop, so using "next" to reach the end of
> history, for example, wouldn't trigger it as I expected. This commit
> fixes that to make out-of-history check only happen after the loop is
> finished.
>
> Also add a test to ensure we dont regress again.
> ---
> gdb/record-full.c | 22 +++++--------
> gdb/testsuite/gdb.reverse/no-history.c | 26 +++++++++++++++
> gdb/testsuite/gdb.reverse/no-history.exp | 40 ++++++++++++++++++++++++
> 3 files changed, 74 insertions(+), 14 deletions(-)
> create mode 100644 gdb/testsuite/gdb.reverse/no-history.c
> create mode 100644 gdb/testsuite/gdb.reverse/no-history.exp
>
> diff --git a/gdb/record-full.c b/gdb/record-full.c
> index 26bd85d34f6..e9ec65b161b 100644
> --- a/gdb/record-full.c
> +++ b/gdb/record-full.c
> @@ -1362,19 +1362,11 @@ record_full_wait_1 (struct target_ops *ops,
> /* Check for beginning and end of log. */
> if (execution_direction == EXEC_REVERSE
> && record_full_next_insn < 0)
> - {
> - /* Hit beginning of record log in reverse. */
> - status->set_no_history ();
> - record_full_next_insn = 0;
> - break;
> - }
> - if (execution_direction != EXEC_REVERSE
> - && record_full_next_insn == record_full_log.size ())
> - {
> - /* Hit end of record log going forward. */
> - status->set_no_history ();
> - break;
> - }
> + break;
> +
> + else if (execution_direction != EXEC_REVERSE
> + && record_full_next_insn == record_full_log.size ())
> + break;
>
> record_full_log[record_full_next_insn].exec_insn (regcache);
>
> @@ -1424,11 +1416,13 @@ record_full_wait_1 (struct target_ops *ops,
> {
> gdb_assert (execution_direction == EXEC_REVERSE);
> record_full_next_insn = 0;
> + status->set_no_history ();
> }
> - else if (record_full_next_insn > record_full_log.size ())
> + else if (record_full_next_insn >= record_full_log.size ())
> {
> gdb_assert (execution_direction == EXEC_FORWARD);
> record_full_next_insn = record_full_log.size ();
> + status->set_no_history ();
> }
> /* Reset the current instruction to point to the one to be replayed
> moving forward. */
> diff --git a/gdb/testsuite/gdb.reverse/no-history.c b/gdb/testsuite/gdb.reverse/no-history.c
> new file mode 100644
> index 00000000000..4e7cf3786fd
> --- /dev/null
> +++ b/gdb/testsuite/gdb.reverse/no-history.c
> @@ -0,0 +1,26 @@
> +/* This testcase is part of GDB, the GNU debugger.
> +
> + Copyright 2026 Free Software Foundation, Inc.
> +
> + This program is free software; you can redistribute it and/or modify
> + it under the terms of the GNU General Public License as published by
> + the Free Software Foundation; either version 3 of the License, or
> + (at your option) any later version.
> +
> + This program is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + GNU General Public License for more details.
> +
> + You should have received a copy of the GNU General Public License
> + along with this program. If not, see <http://www.gnu.org/licenses/>. */
> +
> +/* Test that GDB is printing the no-history messages as it should. */
> +
> +int
> +main ()
> +{
> + int x = 0;
> + x++;
> + return 0; /* END OF MAIN */
> +}
> diff --git a/gdb/testsuite/gdb.reverse/no-history.exp b/gdb/testsuite/gdb.reverse/no-history.exp
> new file mode 100644
> index 00000000000..443d3b66497
> --- /dev/null
> +++ b/gdb/testsuite/gdb.reverse/no-history.exp
> @@ -0,0 +1,40 @@
> +# Copyright 2008-2026 Free Software Foundation, Inc.
> +
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 3 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program. If not, see <http://www.gnu.org/licenses/>. */
> +
> +# This file is part of the GDB testsuite. It tests the printing of
> +# the "out of history" warnings.
> +
> +require supports_reverse
> +
> +standard_testfile
> +
> +if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
> + return
> +}
> +
> +runto_main
> +
> +if {[supports_process_record]} {
> + # Activate process record/replay
> + gdb_test_no_output "record" "turn on process record"
> +}
> +
> +gdb_test "next" "x\\\+\\\+;" "Record a line of execution"
> +gdb_test "reverse-next" \
> + ".*Reached end of recorded history; stopping.*" \
> + "Reverse to start of history"
> +gdb_test "next" \
> + ".*Reached end of recorded history; stopping.*" \
> + "Forward to end of history"
>
> base-commit: 0ca0b8de31ec76ff71f4a051db3dc1fcc9325154
--
Cheers,
Guinevere Larsen
it/its
she/her (deprecated)
next prev parent reply other threads:[~2026-09-24 12:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-08 20:53 [PATCH " Guinevere Larsen
2026-09-24 12:52 ` Guinevere Larsen [this message]
2026-09-28 20:11 ` Andrew Burgess
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=3b277d88-0eb9-40e2-890c-44cb6135148d@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