[PATCH v5 3/8] GDB: Add `NUMBER' completion to `set' integer commands

Maciej W. Rozycki macro@embecosm.com
Thu May 26 10:09:38 GMT 2022


Hi Bruno,

> > Index: src/gdb/cli/cli-decode.c
> > ===================================================================
> > --- src.orig/gdb/cli/cli-decode.c
> > +++ src/gdb/cli/cli-decode.c
> > @@ -989,6 +989,8 @@ integer_unlimited_completer (struct cmd_
> >         NULL,
> >       };
> >   +  if (*text == '\0')
> > +    tracker.add_completion (make_unique_xstrdup ("NUMBER"));
> >     complete_on_enum (tracker, keywords, text, word);
> >   }
> 
> Seeing as the point of "complete_on_enum" is to add all keywords to the
> tracker, why not add "NUMBER" as a keyword? The only possible unfavorable side
> effect I can think of would be GDB completing N<TAB> to NUMBER, and personally
> I feel abstracting away how the option would be added is more important than
> not adding this completion option.

 This just follows the existing logic in `parse_option' and is really a 
special case.  I am inconvinced that there is a benefit from getting the 
completion broken visibly to the user for the sake of avoiding a manual 
call in the code.  Sorry.

> Another option would be having the function like this:
> 
> void
> integer_unlimited_completer(...)
> {
>   static const char * const keywords [] =
>     {
>       "NUMBER",
>       "unlimited",
>       NULL
>     }
>   if (*text != '\0')
>     complete_on_enum (tracker, keywords + 1, text, word);
>   else
>     complete_on_enum (tracker, keywords, text, word);
> }
> 
> Or some more concise way of writing it.

 And then with 6/8 (which removes `integer_unlimited_completer' entirely) 
that "NUMBER" entry would have to be added to all the keyword lists passed 
along rather than a single place in `integer_literals_completer', and 
still handled as a rather fragile special case where people writing any 
new keyword lists will have to remember to put a "NUMBER" entry first.  I 
really fail to see the advantage of such approach.  Sorry again.

 Thank you for your input however, it's always good to have a look from a 
different angle!

  Maciej


More information about the Gdb-patches mailing list