public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [RFA 0/2] Fix a bug in the 'x' command
@ 2018-04-30 20:26 Tom Tromey
  2018-04-30 20:26 ` [RFA 1/2] Use previous count when 'x' command is repeated Tom Tromey
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Tom Tromey @ 2018-04-30 20:26 UTC (permalink / raw)
  To: gdb-patches

This started as a patch to fix a simple bug in the 'x' command, but
then I tacked on a minor cleanup I saw when working here.

Regression tested by the buildbot.

Tom

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [RFA 1/2] Use previous count when 'x' command is repeated
  2018-04-30 20:26 [RFA 0/2] Fix a bug in the 'x' command Tom Tromey
@ 2018-04-30 20:26 ` Tom Tromey
  2018-04-30 20:26 ` [RFA 2/2] Minor cleanups in printcmd.c Tom Tromey
  2018-05-04 18:01 ` [RFA 0/2] Fix a bug in the 'x' command Pedro Alves
  2 siblings, 0 replies; 4+ messages in thread
From: Tom Tromey @ 2018-04-30 20:26 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

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-04-30  Tom Tromey  <tom@tromey.com>

	PR gdb/22619:
	* printcmd.c (last_count): New global.
	(x_command): Use saved count when repeating.

testsuite/ChangeLog
2018-04-30  Tom Tromey  <tom@tromey.com>

	* 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [RFA 2/2] Minor cleanups in printcmd.c
  2018-04-30 20:26 [RFA 0/2] Fix a bug in the 'x' command Tom Tromey
  2018-04-30 20:26 ` [RFA 1/2] Use previous count when 'x' command is repeated Tom Tromey
@ 2018-04-30 20:26 ` Tom Tromey
  2018-05-04 18:01 ` [RFA 0/2] Fix a bug in the 'x' command Pedro Alves
  2 siblings, 0 replies; 4+ messages in thread
From: Tom Tromey @ 2018-04-30 20:26 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes decode_format to use skip_spaces, and changes printcmd.c
not to include tui.h, which apparently is not needed.

ChangeLog
2018-04-30  Tom Tromey  <tom@tromey.com>

	* printcmd.c: Don't include tui.h.
	(decode_format): Use skip_spaces.
---
 gdb/ChangeLog  | 5 +++++
 gdb/printcmd.c | 8 +-------
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index 18c41103bd..4696373b2c 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -50,10 +50,6 @@
 #include "source.h"
 #include "common/byte-vector.h"
 
-#ifdef TUI
-#include "tui/tui.h"		/* For tui_active et al.   */
-#endif
-
 /* Last specified output format.  */
 
 static char last_format = 0;
@@ -215,9 +211,7 @@ decode_format (const char **string_ptr, int oformat, int osize)
 	break;
     }
 
-  while (*p == ' ' || *p == '\t')
-    p++;
-  *string_ptr = p;
+  *string_ptr = skip_spaces (p);
 
   /* Set defaults for format and size if not specified.  */
   if (val.format == '?')
-- 
2.13.6

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFA 0/2] Fix a bug in the 'x' command
  2018-04-30 20:26 [RFA 0/2] Fix a bug in the 'x' command Tom Tromey
  2018-04-30 20:26 ` [RFA 1/2] Use previous count when 'x' command is repeated Tom Tromey
  2018-04-30 20:26 ` [RFA 2/2] Minor cleanups in printcmd.c Tom Tromey
@ 2018-05-04 18:01 ` Pedro Alves
  2 siblings, 0 replies; 4+ messages in thread
From: Pedro Alves @ 2018-05-04 18:01 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 04/30/2018 09:26 PM, Tom Tromey wrote:
> This started as a patch to fix a simple bug in the 'x' command, but
> then I tacked on a minor cleanup I saw when working here.
> 
> Regression tested by the buildbot.

OK.

In patch #1, please add "PR gdb/22619:" to the testsuite
ChangeLog too.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-05-04 18:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-30 20:26 [RFA 0/2] Fix a bug in the 'x' command Tom Tromey
2018-04-30 20:26 ` [RFA 1/2] Use previous count when 'x' command is repeated Tom Tromey
2018-04-30 20:26 ` [RFA 2/2] Minor cleanups in printcmd.c Tom Tromey
2018-05-04 18:01 ` [RFA 0/2] Fix a bug in the 'x' command Pedro Alves

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).