* [PATCH v2] gdb/record: fix missing "no history" message in some situations
@ 2026-09-08 20:53 Guinevere Larsen
2026-09-24 12:52 ` [PING][PATCH " Guinevere Larsen
2026-09-28 20:11 ` [PATCH " Andrew Burgess
0 siblings, 2 replies; 4+ messages in thread
From: Guinevere Larsen @ 2026-09-08 20:53 UTC (permalink / raw)
To: gdb-patches; +Cc: Guinevere Larsen
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
--
2.55.0
^ permalink raw reply [flat|nested] 4+ messages in thread* [PING][PATCH v2] gdb/record: fix missing "no history" message in some situations
2026-09-08 20:53 [PATCH v2] gdb/record: fix missing "no history" message in some situations Guinevere Larsen
@ 2026-09-24 12:52 ` Guinevere Larsen
2026-09-28 20:11 ` [PATCH " Andrew Burgess
1 sibling, 0 replies; 4+ messages in thread
From: Guinevere Larsen @ 2026-09-24 12:52 UTC (permalink / raw)
To: gdb-patches, guinevere
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)
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v2] gdb/record: fix missing "no history" message in some situations
2026-09-08 20:53 [PATCH v2] gdb/record: fix missing "no history" message in some situations Guinevere Larsen
2026-09-24 12:52 ` [PING][PATCH " Guinevere Larsen
@ 2026-09-28 20:11 ` Andrew Burgess
2026-09-29 13:44 ` Guinevere Larsen
1 sibling, 1 reply; 4+ messages in thread
From: Andrew Burgess @ 2026-09-28 20:11 UTC (permalink / raw)
To: Guinevere Larsen, gdb-patches; +Cc: Guinevere Larsen
Guinevere Larsen <guinevere@redhat.com> writes:
> 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.
This sentence seem hard to parse. You initially seem to be talking
about replaying, so forward execution, but then finish by talking about
reverse execution.
> Executing forward past the end will not warn the user that
> recording is going to start again, it just does so. This is the
Maybe I'm not understanding, but ... are your examples below switched
around? The "before the change" text DOES warn when reaching the last
location going forward, while the "after the change" text does not. The
"before" behaviour seems to be more inline with what you say your change
delivers.
> 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.
Typo: dont -> don't
> ---
> 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;
> +
Please delete this blank line.
> + 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 */
The 'END OF MAIN' marker is not used and can be removed.
> +}
> 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.
Probably need to update this copyright date.
With the nits fixed this change looks fine. It's just the commit
message which to me seems to be the reverse of the change.
Thanks,
Andrew
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v2] gdb/record: fix missing "no history" message in some situations
2026-09-28 20:11 ` [PATCH " Andrew Burgess
@ 2026-09-29 13:44 ` Guinevere Larsen
0 siblings, 0 replies; 4+ messages in thread
From: Guinevere Larsen @ 2026-09-29 13:44 UTC (permalink / raw)
To: Andrew Burgess, gdb-patches
On 9/28/26 5:11 PM, Andrew Burgess wrote:
> Guinevere Larsen <guinevere@redhat.com> writes:
>
>> 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.
> This sentence seem hard to parse. You initially seem to be talking
> about replaying, so forward execution, but then finish by talking about
> reverse execution.
Replaying is not only forward execution, it can also refer to executing
backwards. That word is used to mean "we are using the recorded
instruction log to pretend the inferior has moved, as opposed to
actually executing"
The message was missing for both replay directions, and could only be
printed in backwards replaying.
>
>> Executing forward past the end will not warn the user that
>> recording is going to start again, it just does so. This is the
> Maybe I'm not understanding, but ... are your examples below switched
> around? The "before the change" text DOES warn when reaching the last
> location going forward, while the "after the change" text does not. The
> "before" behaviour seems to be more inline with what you say your change
> delivers.
Yes, the examples are swapped around, thanks for catching that.
>> 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.
> Typo: dont -> don't
Fixed
>
>> ---
>> 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;
>> +
> Please delete this blank line.
Fixed
>> + 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 */
> The 'END OF MAIN' marker is not used and can be removed.
Fixed
>
>> +}
>> 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.
> Probably need to update this copyright date.
Fixed
>
> With the nits fixed this change looks fine. It's just the commit
> message which to me seems to be the reverse of the change.
I'll give some time before pushing, so that you have time to respond to
the confusion at the start before I push it.
>
> Thanks,
> Andrew
--
Cheers,
Guinevere Larsen
it/its
she/her (deprecated)
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-09-29 13:44 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-08 20:53 [PATCH v2] gdb/record: fix missing "no history" message in some situations Guinevere Larsen
2026-09-24 12:52 ` [PING][PATCH " Guinevere Larsen
2026-09-28 20:11 ` [PATCH " Andrew Burgess
2026-09-29 13:44 ` Guinevere Larsen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox