Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Guinevere Larsen <guinevere@redhat.com>
To: Andrew Burgess <aburgess@redhat.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH v2] gdb/record: fix missing "no history" message in some situations
Date: Tue, 29 Sep 2026 10:44:03 -0300	[thread overview]
Message-ID: <15fb5e35-fd04-4d2c-836a-468507a9542e@redhat.com> (raw)
In-Reply-To: <87bj9h16hq.fsf@redhat.com>

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)


      reply	other threads:[~2026-09-29 13:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-08 20:53 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 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=15fb5e35-fd04-4d2c-836a-468507a9542e@redhat.com \
    --to=guinevere@redhat.com \
    --cc=aburgess@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