From patchwork Wed Jan 4 14:54:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guinevere Larsen X-Patchwork-Id: 62705 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 760043858C53 for ; Wed, 4 Jan 2023 15:13:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 760043858C53 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1672845210; bh=OT1jmQuIwFppUCIeDVUeZkcZCKRpiCELjejFpvaLDd4=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=Ptx1OXjncB2QdpgCjHQpeLkB0LeScOAL0oB+aW8fFWjSA7my/bvst1F3K85rmlx3z Yr3CpqueczkAne5BSSTCkBKUIyEO3RyV9ecu8KqdzD7UkMHcfyLWwqvVtliwbDPxqr BVllpG5IRJbgwathEukoVXn7PLGfuDwPRJdH+iNk= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 09DA63858D39 for ; Wed, 4 Jan 2023 15:13:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 09DA63858D39 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-126-mDKMkIMnMvGa-1UyG3iCmA-1; Wed, 04 Jan 2023 10:13:05 -0500 X-MC-Unique: mDKMkIMnMvGa-1UyG3iCmA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7436D85A588 for ; Wed, 4 Jan 2023 15:13:05 +0000 (UTC) Received: from fedora.redhat.com (ovpn-192-134.brq.redhat.com [10.40.192.134]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AEE80C15BA0; Wed, 4 Jan 2023 15:13:04 +0000 (UTC) To: gdb-patches@sourceware.org Cc: Bruno Larsen Subject: [PATCH v2] gdb/mi: add no-history stop reason Date: Wed, 4 Jan 2023 15:54:33 +0100 Message-Id: <20230104145432.1191789-1-blarsen@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Bruno Larsen via Gdb-patches From: Guinevere Larsen Reply-To: Bruno Larsen Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" When executing in reverse and runs out of recorded history, GDB prints a warning to the user, but does not add a reason in the stopped record, for example: *stopped,frame={addr="0x000000000040113e",func="main",args=[],file="/home/blarsen/Documents/fsf_build/gdb/testsuite/../../../binutils-gdb/gdb/testsuite/gdb.reverse/solib-reverse.c",fullname="/home/blarsen/Documents/binutils-gdb/gdb/testsuite/gdb.reverse/solib-reverse.c",line="27",arch="i386:x86-64"},thread-id="1",stopped-threads="all",core="1" This problem was reported as record/29260. This commit adds the reason no-history to the record, making it easier for interfaces using the mi interpreter to report the result. It also changes the test gdb.mi/mi-reverse.exp to test that the reason shows up correctly. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29260 --- Relevant changes for v2: * Changed the gdb.mi test to confirm the stop reason shows up correctly. * Used the correct method to report mi stop reason. --- gdb/NEWS | 5 +++++ gdb/doc/gdb.texinfo | 2 ++ gdb/infrun.c | 5 ++++- gdb/mi/mi-common.c | 1 + gdb/mi/mi-common.h | 1 + gdb/testsuite/gdb.mi/mi-reverse.exp | 2 +- 6 files changed, 14 insertions(+), 2 deletions(-) diff --git a/gdb/NEWS b/gdb/NEWS index d8f4f396712..c0aac212e30 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -17,6 +17,11 @@ maintenance print record-instruction [ N ] prints how GDB would undo the N-th previous instruction, and if N is positive, it prints how GDB will redo the N-th following instruction. +* MI changes + +** mi now reports 'no-history' as a stop reason when hitting the end of the + reverse execution history. + *** Changes in GDB 13 * MI version 1 is deprecated, and will be removed in GDB 14. diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index dd8f8bc757c..2f5b4bb4c61 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -30860,6 +30860,8 @@ The inferior returned from a system call. This is reported when @item exec The inferior called @code{exec}. This is reported when @code{catch exec} (@pxref{Set Catchpoints}) has been used. +@item no-history +There isn't enough history recorded to continue reverse execution. @end table The @var{id} field identifies the global thread ID of the thread diff --git a/gdb/infrun.c b/gdb/infrun.c index d5f97e33625..181d961d80d 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -8406,7 +8406,10 @@ print_signal_received_reason (struct ui_out *uiout, enum gdb_signal siggnal) void print_no_history_reason (struct ui_out *uiout) { - uiout->text ("\nNo more reverse-execution history.\n"); + if (uiout->is_mi_like_p ()) + uiout->field_string ("reason", async_reason_lookup (EXEC_ASYNC_NO_HISTORY)); + else + uiout->text ("\nNo more reverse-execution history.\n"); } /* Print current location without a level number, if we have changed diff --git a/gdb/mi/mi-common.c b/gdb/mi/mi-common.c index 51a8aaa8d0e..ce70d11a912 100644 --- a/gdb/mi/mi-common.c +++ b/gdb/mi/mi-common.c @@ -39,6 +39,7 @@ static const char * const async_reason_string_lookup[] = "syscall-entry", "syscall-return", "exec", + "no-history", NULL }; diff --git a/gdb/mi/mi-common.h b/gdb/mi/mi-common.h index 6a1aea3539d..dfb83535b0b 100644 --- a/gdb/mi/mi-common.h +++ b/gdb/mi/mi-common.h @@ -42,6 +42,7 @@ enum async_reply_reason EXEC_ASYNC_SYSCALL_ENTRY, EXEC_ASYNC_SYSCALL_RETURN, EXEC_ASYNC_EXEC, + EXEC_ASYNC_NO_HISTORY, /* This is here only to represent the number of enums. */ EXEC_ASYNC_LAST }; diff --git a/gdb/testsuite/gdb.mi/mi-reverse.exp b/gdb/testsuite/gdb.mi/mi-reverse.exp index e761ede03f5..d631beb17c8 100644 --- a/gdb/testsuite/gdb.mi/mi-reverse.exp +++ b/gdb/testsuite/gdb.mi/mi-reverse.exp @@ -159,7 +159,7 @@ proc test_controlled_execution_reverse {} { "reverse-continue at callee3" mi_execute_to "exec-continue --reverse" \ - "" "main" "" \ + "no-history" "main" "" \ "basics.c" $line_main_body "" \ "reverse-continue at main" }