From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id XFREA/51oGqgBTgAWB0awg (envelope-from ) for ; Tue, 08 Sep 2026 16:54:22 -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=YDJcG24l; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id E97541E09E; Tue, 08 Sep 2026 16:54:21 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.1 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,RCVD_IN_SBL_CSS autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.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 D0B621E033 for ; Tue, 08 Sep 2026 16:54:20 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4F4AD4C900F5 for ; Tue, 8 Sep 2026 20:54:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4F4AD4C900F5 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=YDJcG24l 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 9BD124BB24C4 for ; Tue, 8 Sep 2026 20:53:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9BD124BB24C4 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 9BD124BB24C4 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=1788900835; cv=none; b=oA/IYVYYgRKyjQncF6Vkot/oHaAKBO3LfaXyL0E1ATQgM0/rStoobhPCCi5ZUjyZ+trLS2DBnnAFT+FELKeKFaNkuzYXNYTkngFgo8YGfCGNehQvEr2jWyz2Xj97J0CiGR4lLOKOdmnDSg7sf+0NrOnEPTItWxEialVvstqIiQw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1788900835; c=relaxed/simple; bh=Nbsjt2unSopp7kl7e25lukOO/Qvsa98EEJzcAtcCCV0=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=ZIFMhK+yGypS82KUlI5yr910UyGDKAspBEg8TU30+yr8qmDdwUATKTLrKR6SSl8fkPfLvbP0A7e5y7B201qj22mcxhEo5BKJ7wvP6AftNBkZT60FX6LgAcOUTEc7htCuInP0qQcbeLWF/leXjuf4Nr9IHW8dvFWfW1CVbJrBV4A= 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=YDJcG24l DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9BD124BB24C4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1788900835; 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=60ch4/hSGJodLq7H5tIsJqK1sHgo9OUwx0JdyDQEVbE=; b=YDJcG24luXMIbtbFmVY2k1JELlH5/jrkbQfWd8egwiboIXUVPv1UGj3ClWbZh3OkP7pFVG P7jsS51Eiu4El2w9Y8dMb21OFee3Zwe1YKK2lgf0l9tGs4eFYLyrUiaAscy+2F0k+eLc2z /iJcc+DZf9DPqAHSsV3Po8wpLgpp3Sw= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-445-pgnpcsU1Mny_FUpMt_7UmA-1; Tue, 08 Sep 2026 16:53:54 -0400 X-MC-Unique: pgnpcsU1Mny_FUpMt_7UmA-1 X-Mimecast-MFC-AGG-ID: pgnpcsU1Mny_FUpMt_7UmA_1788900833 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C5CC91944E40 for ; Tue, 8 Sep 2026 20:53:52 +0000 (UTC) Received: from glarsen-thinkpadp16vgen1.rmtbr.csb (headnet03.pony-001.prod.iad2.dc.redhat.com [10.2.32.114]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 78B5618005AC; Tue, 8 Sep 2026 20:53:50 +0000 (UTC) From: Guinevere Larsen To: gdb-patches@sourceware.org Cc: Guinevere Larsen Subject: [PATCH v2] gdb/record: fix missing "no history" message in some situations Date: Tue, 8 Sep 2026 17:53:44 -0300 Message-ID: <20260908205344.95713-1-guinevere@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: ZpfXZZTPF2lICQz1SuXiep3T8y067Zb7ACWuu5AMq9Q_1788900833 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 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 . */ + +/* 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 . */ + +# 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