Bug 22619 - repeat count is forgotten by newline to extend previous 'x' command (examine memory)
Summary: repeat count is forgotten by newline to extend previous 'x' command (examine ...
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: gdb (show other bugs)
Version: HEAD
: P2 normal
Target Milestone: 8.2
Assignee: Tom Tromey
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-12-16 17:49 UTC by John Reiser
Modified: 2018-05-04 18:32 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed: 2018-04-27 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description John Reiser 2017-12-16 17:49:09 UTC
The command sequence
  (gdb) x/12xw $sp
  (gdb)     ## newline to show the next 12 words
forgets the repeat count "12"; it displays only one word instead of the expected 12.

Example:
$ gdb hello
GNU gdb (GNU gdb (GDB) 8.0.50.20171216-git
  <<snip>>
(gdb) b main
(gdb) run
Breakpoint 1, main (argc=0x1, argv=0xbefff454) at hello.c:5

(gdb) x/12xw $sp
0xbefff2e8:	0x00010460	0x00000000	0xbefff454	0x00000001
0xbefff2f8:	0x00000000	0x00000000	0x00000000	0xb6e63c40
0xbefff308:	0xb6fb5000	0xbefff454	0x00000001	0x00010404
(gdb)    ## type <Enter> or <Return> to ask for the next 12 words
0xbefff318:	0x9fea1ea9   ## only one (1) word shown instead of twelve (12)
(gdb)

gdb was built from git tip:
commit 09da3ecf04d75084ea7d9c43e3cc0b18b2443ea3 (HEAD -> master, origin/master, origin/HEAD)
Author: GDB Administrator <gdbadmin@sourceware.org>
Date:   Sat Dec 16 00:00:33 2017 +0000

    Automatic date update in version.in
Comment 1 Tom Tromey 2018-04-27 21:32:29 UTC
The docs say that the default is 1, so I guess this was intended.
However I expected it to work the way you did and so I tend
to think this ought to be changed.  I suppose the way it should
work is that plain RET should use the old count, but a new 'x'
command should default to 1 again.
Comment 2 Tom Tromey 2018-04-27 21:33:19 UTC
Actually the manual says:

 If you use <RET> to repeat the 'x' command, the repeat count N
is used again; the other arguments default as for successive uses of
'x'.


... so this seems like just a plain bug.
Comment 3 Tom Tromey 2018-04-28 04:28:21 UTC
I have a patch.
Comment 4 Sourceware Commits 2018-05-04 18:31:22 UTC
The master branch has been updated by Tom Tromey <tromey@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=9be2ae8fc6b908746d9d7ebaf77aec8abba5dd2c

commit 9be2ae8fc6b908746d9d7ebaf77aec8abba5dd2c
Author: Tom Tromey <tom@tromey.com>
Date:   Fri Apr 27 15:52:44 2018 -0600

    Use previous count when 'x' command is repeated
    
    About the 'x' command, the manual says:
    
        If you use <RET> 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-05-04  Tom Tromey  <tom@tromey.com>
    
    	PR gdb/22619:
    	* printcmd.c (last_count): New global.
    	(x_command): Use saved count when repeating.
    
    testsuite/ChangeLog
    2018-05-04  Tom Tromey  <tom@tromey.com>
    
    	PR gdb/22619:
    	* gdb.base/long_long.exp (gdb_test_long_long): Add test for repeat
    	behavior.
Comment 5 Tom Tromey 2018-05-04 18:32:02 UTC
Fixed.