From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23539 invoked by alias); 30 Apr 2018 20:26:37 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 23419 invoked by uid 89); 30 Apr 2018 20:26:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=2bx X-HELO: gateway33.websitewelcome.com Received: from gateway33.websitewelcome.com (HELO gateway33.websitewelcome.com) (192.185.146.70) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 30 Apr 2018 20:26:34 +0000 Received: from cm16.websitewelcome.com (cm16.websitewelcome.com [100.42.49.19]) by gateway33.websitewelcome.com (Postfix) with ESMTP id AA8B7CF9FF for ; Mon, 30 Apr 2018 15:26:28 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id DFNUfuPIfWCOCDFNUfo1LH; Mon, 30 Apr 2018 15:26:28 -0500 X-Authority-Reason: nr=8 Received: from 97-122-176-117.hlrn.qwest.net ([97.122.176.117]:42256 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1fDFNU-000C6E-Dx; Mon, 30 Apr 2018 15:26:28 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 1/2] Use previous count when 'x' command is repeated Date: Mon, 30 Apr 2018 20:26:00 -0000 Message-Id: <20180430202626.27017-2-tom@tromey.com> In-Reply-To: <20180430202626.27017-1-tom@tromey.com> References: <20180430202626.27017-1-tom@tromey.com> X-BWhitelist: no X-Source-L: No X-Exim-ID: 1fDFNU-000C6E-Dx X-Source-Sender: 97-122-176-117.hlrn.qwest.net (bapiya.Home) [97.122.176.117]:42256 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-SW-Source: 2018-04/txt/msg00666.txt.bz2 About the 'x' command, the manual says: If you use to repeat the 'x' command, the repeat count N is used again; the other arguments default as for successive uses of 'x'. However, PR gdb/22619 points out that this does not work. This patch fixes the problem. ChangeLog 2018-04-30 Tom Tromey PR gdb/22619: * printcmd.c (last_count): New global. (x_command): Use saved count when repeating. testsuite/ChangeLog 2018-04-30 Tom Tromey * gdb.base/long_long.exp (gdb_test_long_long): Add test for repeat behavior. --- gdb/ChangeLog | 6 ++++++ gdb/printcmd.c | 11 +++++++++++ gdb/testsuite/ChangeLog | 5 +++++ gdb/testsuite/gdb.base/long_long.exp | 5 +++++ 4 files changed, 27 insertions(+) diff --git a/gdb/printcmd.c b/gdb/printcmd.c index a6d6d7e12d..18c41103bd 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -62,6 +62,10 @@ static char last_format = 0; static char last_size = 'w'; +/* Last specified count for the 'x' command. */ + +static int last_count; + /* Default address to examine next, and associated architecture. */ static struct gdbarch *next_gdbarch; @@ -1616,6 +1620,11 @@ x_command (const char *exp, int from_tty) fmt.count = 1; fmt.raw = 0; + /* If there is no expression and no format, use the most recent + count. */ + if (exp == nullptr && last_count > 0) + fmt.count = last_count; + if (exp && *exp == '/') { const char *tmp = exp + 1; @@ -1624,6 +1633,8 @@ x_command (const char *exp, int from_tty) exp = (char *) tmp; } + last_count = fmt.count; + /* If we have an expression, evaluate it and use it as the address. */ if (exp != 0 && *exp != 0) diff --git a/gdb/testsuite/gdb.base/long_long.exp b/gdb/testsuite/gdb.base/long_long.exp index 85e08f085d..b319c61c5e 100644 --- a/gdb/testsuite/gdb.base/long_long.exp +++ b/gdb/testsuite/gdb.base/long_long.exp @@ -280,5 +280,10 @@ gdb_test_ptr "x/2ga g" "" "" "0x89abcdef.*0x77053977" "0x123456789abcdef.*0xa72e gdb_test "x/2gc g" "-17 '.\[0-9\]*'.*119 'w'" gdb_test "x/2gf g" "3.5127005640885037e-303.*-5.9822653797615723e-120" +# Repeat behavior. +gdb_test "x/2bx b" "0x01.*0xa7" "set up for repeat" +send_gdb "\n" +gdb_test "" "0x00.*0x00" "repeat x command" + gdb_exit return 0 -- 2.13.6