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

Guinevere Larsen
2026-01-09T11:58:45Z

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);
+ opt ++;
+ }
+ }
}
else
{
--
2.52.0