Re: [PATCH v2 1/2] gdb: improve help text for set commands with limited options

Andrew Burgess
2026-01-12T15:36:33Z

Guinevere Larsen <guinevere@redhat.com> writes:

> Some "set" commands only allow a select few options, such as the "set
> architecture" command, however, there is no way for a user to know which
> options are allowed without trying to set something and getting an
> error. This commit improves the situation by making the help command list
> all the available options.
> ---
> gdb/cli/cli-decode.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c
> index 04935575b67..06313ba6c49 100644
> --- a/gdb/cli/cli-decode.c
> +++ b/gdb/cli/cli-decode.c
> @@ -1884,6 +1884,16 @@ help_cmd (const char *command, struct ui_file *stream)
> /* Be sure to expand TABs in the documentation. */
> tab_expansion_file expander (stream);
> gdb_puts (c->doc, &expander);
> + if (c->enums != nullptr)
> + {
> + gdb_puts ("Available options are:\n", &expander);
> + const char * const *opt = c->enums;
> + while (opt != nullptr)
> + {
> + gdb_printf (&expander, "%s\n", *opt);

Have you tried this on a build of GDB with all-targets enabled? I
suspect this is going to result in rather a long list. It might be
better if the options were printed as a comma separated list maybe?

Thanks,
Andrew

> + opt ++;
> + }
> + }
> }
> else
> {
> --
> 2.52.0