[PATCH] gdb: improve command completion for 'print', 'x', and 'display'

Andrew Burgess andrew.burgess@embecosm.com
Thu Nov 19 10:14:31 GMT 2020


* Tom Tromey <tom@tromey.com> [2020-11-18 09:11:56 -0700]:

> >>>>> "Andrew" == Andrew Burgess <andrew.burgess@embecosm.com> writes:
> 
> Andrew> The /FMT specification on the print command currently breaks command
> Andrew> completion, so:
> 
> Note that this is PR cli/16256
> 
> Andrew> +      if (ISALNUM (text[1]) || ISSPACE(text[1]))
> 
> Missing space before a paren here.
> 
> Andrew> +	{
> Andrew> +	  /* Skip over the actual format specification.  */
> Andrew> +	  while (*text != '\0' && !ISSPACE (*text))
> Andrew> +	    ++text;
> 
> There's skip_spaces and skip_to_space for this kind of thing..

Thanks for the suggestion.  I pushed the patch below to address
this issue.

Thanks,
Andrew

---

commit b3ff61f8155f296633f96206c926b545b97053b3
Author: Andrew Burgess <andrew.burgess@embecosm.com>
Date:   Thu Nov 19 10:09:42 2020 +0000

    gdb: make use of skip_to_space and skip_spaces
    
    Some late feedback on this commit:
    
      commit 037d7135de575c9e0c20e9158c105979bfee339c
      Date:   Mon Nov 16 11:36:56 2020 +0000
    
          gdb: improve command completion for 'print', 'x', and 'display'
    
    Suggested making use of the skip_to_space and skip_spaces helper
    functions.  There should be no user visible changes after this commit.
    
    gdb/ChangeLog:
    
            * printcmd.c (skip_over_slash_fmt): Make use of skip_to_space and
            skip_spaces.

diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index 8c05ac8c833..a9c64b97c81 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -1261,8 +1261,7 @@ skip_over_slash_fmt (completion_tracker &tracker, const char **args)
       if (ISALNUM (text[1]) || ISSPACE (text[1]))
 	{
 	  /* Skip over the actual format specification.  */
-	  while (*text != '\0' && !ISSPACE (*text))
-	    ++text;
+	  text = skip_to_space (text);
 
 	  if (*text == '\0')
 	    {
@@ -1272,8 +1271,7 @@ skip_over_slash_fmt (completion_tracker &tracker, const char **args)
 	  else
 	    {
 	      in_fmt = false;
-	      while (ISSPACE (*text))
-		++text;
+	      text = skip_spaces (text);
 	    }
 	}
       else if (text[1] == '\0')


More information about the Gdb-patches mailing list