Use previous count when 'x' command is repeated
authorTom Tromey <tom@tromey.com>
Fri, 27 Apr 2018 21:52:44 +0000 (15:52 -0600)
committerTom Tromey <tom@tromey.com>
Fri, 4 May 2018 18:22:37 +0000 (12:22 -0600)
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.

gdb/ChangeLog
gdb/printcmd.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/long_long.exp

index 60079a13ebb64208a2c42d1c4cac744f2852dd77..7136be6690cdd1134e11f810e48bdd1a4815684f 100644 (file)
@@ -1,3 +1,9 @@
+2018-05-04  Tom Tromey  <tom@tromey.com>
+
+       PR gdb/22619:
+       * printcmd.c (last_count): New global.
+       (x_command): Use saved count when repeating.
+
 2018-05-04  Tom Tromey  <tom@tromey.com>
 
        * nto-procfs.c (do_closedir_cleanup): Remove.
index a6d6d7e12d36fedf1f5aa9c871cd597e6af5d6e6..18c41103bd55b2d0c9e7adc81fa434a95ddad5fa 100644 (file)
@@ -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)
index 73c4a2ca6c260794967956e6d485ba144aeb6df5..62fa5e03c8f7e90ec7d106ac852846174c87bd2b 100644 (file)
@@ -1,3 +1,9 @@
+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.
+
 2018-05-04  Andrew Burgess  <andrew.burgess@embecosm.com>
 
        * gdb.base/maint.exp: Process output from 'maint print registers'
index 85e08f085dff6356958725eef8dbff94f49cd30f..b319c61c5ed4eb7b43a1b5fde35837380981dfd6 100644 (file)
@@ -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
This page took 0.035046 seconds and 4 git commands to generate.