From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id MUiwGJhp1mpt/jMAWB0awg (envelope-from ) for ; Mon, 19 Oct 2026 15:03:52 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=W1ekGMDh; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 5F4F91E04E; Mon, 19 Oct 2026 15:03:52 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id DA3071E04E for ; Mon, 19 Oct 2026 15:03:50 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0408A4BA23D6 for ; Mon, 19 Oct 2026 19:03:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0408A4BA23D6 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=W1ekGMDh Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id EBCCC4BA2E1E for ; Mon, 19 Oct 2026 19:03:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EBCCC4BA2E1E Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org EBCCC4BA2E1E Authentication-Results: sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1792436598; cv=none; b=plALo8CGRT/bweOVkYfZcEPW0OfmDYdHXJ09CWViK3BMhWV7DHQMh4FCbIwI6f29jR2iBAgPtk00vIR4ECC52Tl/F7mDTre6/uJGnesC2pMFgon+hP+ey0oI44nX1TAvNB+03eS1CMNtFit4S08mc4UXbU8MKuJmAEPtJb+iS2g= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1792436598; c=relaxed/simple; bh=7ZfOK1PBv99F5mRsBJZluYV7HTMSa1ObZpjsUnUBMxY=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=QnToVumlZtVniA3eMAf3I06iVvIhDMrHP5OvGpEoiPobIbstY89TTkvQISvEkRdTO1tN7RHVFV3WB77BQO2UViteGI6pXXVw7cbh9l3nM3IPfi40R1LVjhdMXtTfhmXI2LkRT9XjhCPXcgsm6qXKJh/nfUDkpICW9whqKd5Oeto= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=W1ekGMDh DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EBCCC4BA2E1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1792436597; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Ky3SitsfoWW4IS7gF3zU90w9kL4b77yZRG7uEJ4UrTI=; b=W1ekGMDhb/Si8JzfjjaYR3OOKYxmiz6ajNm9UVvgaTooXUT8jEmpIUUrLxFabsdlqbF2LA nSeVtOyB/823PlMC5l/DVcK6W3c4o5JSvqGC+tE/JY7EGP5hAta0HhcZ1KOnagYtj7hJan 7ES2nEFE2c5y8LCMPQPPIRKe8xQGwj0= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-633-tk3btgRKOaCF179rxmmGgg-1; Mon, 19 Oct 2026 19:03:16 +0000 X-MC-Unique: tk3btgRKOaCF179rxmmGgg-1 X-Mimecast-MFC-AGG-ID: tk3btgRKOaCF179rxmmGgg_1792436595 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 494CF1800A3C for ; Mon, 19 Oct 2026 19:03:15 +0000 (UTC) Received: from glarsen-thinkpadp16vgen1.rmtbr.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 09FA430001A4; Mon, 19 Oct 2026 19:03:13 +0000 (UTC) From: Guinevere Larsen To: gdb-patches@sourceware.org Cc: Guinevere Larsen Subject: [PATCH v3] gdb/record: fix missing "no history" message in some situations Date: Mon, 19 Oct 2026 15:56:41 -0300 Message-ID: <20261019185640.2520434-2-guinevere@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: sXCQi0eef1icl9DzWdWnG7Y2Lx_g7PC9H-nS9uV2-EI_1792436595 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org 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 . */ + +/* 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 . */ + +# 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 -- 2.56.0