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
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.
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.
I have a patch.
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.
Fixed.