From: Guinevere Larsen <guinevere@redhat.com>
To: gdb-patches@sourceware.org
Subject: Re: [PATCH v3] gdb/record: fix missing "no history" message in some situations
Date: Thu, 29 Oct 2026 10:51:33 -0300 [thread overview]
Message-ID: <26ca93f6-a237-47ee-be03-3b4003cf995b@redhat.com> (raw)
In-Reply-To: <e9e823ea-7554-4654-a4ca-9b329adb7a40@redhat.com>
I have pushed this patch. Let me know if this causes any further issues,
and I'll be happy to fix them
On 10/26/26 3:38 PM, Guinevere Larsen wrote:
> Ping!
>
> If there are no further feedbacks on this, I plan to push this series
> early thursday.
>
> On 10/19/26 3:56 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
>> 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;
>>
>> 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
>>
>> 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)
>>
>> 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 don't regress again.
>> ---
>>
>> I seem to have forgotten to send or push this patch. I've fixed all
>> comments from Andrew on v2, but seeing as it's been a while and he
>> never replied with an explicit ok for pushing, I figure it's safer to
>> send a v3, just to be sure.
>>
>> ---
>> gdb/record-full.c | 21 +++++--------
>> gdb/testsuite/gdb.reverse/no-history.c | 26 +++++++++++++++
>> gdb/testsuite/gdb.reverse/no-history.exp | 40 ++++++++++++++++++++++++
>> 3 files changed, 73 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 50da022bb52..7b1d64069c7 100644
>> --- a/gdb/record-full.c
>> +++ b/gdb/record-full.c
>> @@ -1362,19 +1362,10 @@ 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 +1415,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..cb23e3b397e
>> --- /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;
>> +}
>> diff --git a/gdb/testsuite/gdb.reverse/no-history.exp
>> b/gdb/testsuite/gdb.reverse/no-history.exp
>> new file mode 100644
>> index 00000000000..264ca7f84bf
>> --- /dev/null
>> +++ b/gdb/testsuite/gdb.reverse/no-history.exp
>> @@ -0,0 +1,40 @@
>> +# 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/>. */
>> +
>> +# 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: 91dc787c65d9f5f9aba59bcadbee8c3d14a53236
>
--
Cheers,
Guinevere Larsen
it/its
she/her (deprecated)
prev parent reply other threads:[~2026-10-29 13:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-19 18:56 Guinevere Larsen
2026-10-26 18:38 ` Guinevere Larsen
2026-10-29 13:51 ` Guinevere Larsen [this message]
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=26ca93f6-a237-47ee-be03-3b4003cf995b@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