* [PATCH v6 1/2] gdb: improve help text for set commands with limited options
2026-05-11 20:01 [PATCH v6 0/2] Add warning if the native target is not supported Guinevere Larsen
@ 2026-05-11 20:01 ` Guinevere Larsen
2026-05-11 20:01 ` [PATCH v6 2/2] gdb: Improve warning when no native target is available Guinevere Larsen
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Guinevere Larsen @ 2026-05-11 20:01 UTC (permalink / raw)
To: gdb-patches; +Cc: Guinevere Larsen, Ciaran Woodward
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.
Reviewed-By: Ciaran Woodward <ciaranwoodward@xmos.com>
---
gdb/cli/cli-decode.c | 12 ++++++++++++
gdb/testsuite/gdb.base/help.exp | 9 +++++++++
gdb/testsuite/gdb.python/py-doc-reformat.exp | 2 +-
gdb/testsuite/gdb.python/py-parameter.exp | 17 +++++++++++++----
4 files changed, 35 insertions(+), 5 deletions(-)
diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c
index de40faeed59..928c476eaaf 100644
--- a/gdb/cli/cli-decode.c
+++ b/gdb/cli/cli-decode.c
@@ -1875,6 +1875,18 @@ 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 ("\nAvailable options are:\n", &expander);
+ gdb_printf (&expander, " ");
+ for (const char * const *opt = c->enums;
+ *opt != nullptr; opt ++)
+ {
+ expander.wrap_here (2);
+ const char *suffix = (*(opt + 1) == nullptr) ? "." : ", ";
+ gdb_printf (&expander, "%s%s", *opt, suffix);
+ }
+ }
}
else
{
diff --git a/gdb/testsuite/gdb.base/help.exp b/gdb/testsuite/gdb.base/help.exp
index a8c55721ef2..9512523c1df 100644
--- a/gdb/testsuite/gdb.base/help.exp
+++ b/gdb/testsuite/gdb.base/help.exp
@@ -174,3 +174,12 @@ gdb_test "help mybt" " alias mybt = backtrace \[\r\n\]+An alias of command backt
# Check pre-defined aliases cannot be documented.
gdb_test "document where" "Alias \"where\" is built-in.*" \
"documenting builtin where alias disallowed"
+
+# Check help of a command with limited options lists all the options
+# as expected. The command "set breakpoint condition-evaluation" was
+# chosen because it has few options and isn't dependent on configure
+# options.
+gdb_test "help set breakpoint condition-evaluation" \
+ [multi_line ".*" \
+ "Available options are:" \
+ " auto, host, target."]
diff --git a/gdb/testsuite/gdb.python/py-doc-reformat.exp b/gdb/testsuite/gdb.python/py-doc-reformat.exp
index 8b0a27f4937..4692ac44624 100644
--- a/gdb/testsuite/gdb.python/py-doc-reformat.exp
+++ b/gdb/testsuite/gdb.python/py-doc-reformat.exp
@@ -126,7 +126,7 @@ proc test { input_docs expected_output } {
-re "^This is the set doc line\r\n" {
exp_continue
}
- -re "^$expected_output\r\n$::gdb_prompt $" {
+ -re "^$expected_output\r\nAvailable options are:\r\n on, off.\r\n$::gdb_prompt $" {
pass $gdb_test_name
}
}
diff --git a/gdb/testsuite/gdb.python/py-parameter.exp b/gdb/testsuite/gdb.python/py-parameter.exp
index e8b0ef24efb..e8cecf5ca43 100644
--- a/gdb/testsuite/gdb.python/py-parameter.exp
+++ b/gdb/testsuite/gdb.python/py-parameter.exp
@@ -367,7 +367,10 @@ proc_with_prefix test_empty_doc_parameter {} {
# Setting the __doc__ string to empty means GDB will completely
# elide it from the output.
gdb_test "help set print test-empty-doc-param" \
- "^Set the current value of 'print test-empty-doc-param'\\."
+ [multi_line \
+ "^Set the current value of 'print test-empty-doc-param'\\." \
+ "Available options are:" \
+ " on, off."]
gdb_test_multiline "None __doc__ parameter" \
"python" "" \
@@ -384,7 +387,9 @@ proc_with_prefix test_empty_doc_parameter {} {
gdb_test "help set print test-none-doc-param" \
[multi_line \
"^Set the current value of 'print test-none-doc-param'\\." \
- "This command is not documented\\."]
+ "This command is not documented\\." \
+ "Available options are:" \
+ " on, off."]
}
# Test a parameter in which the set_doc/show_doc strings are either
@@ -406,7 +411,9 @@ proc_with_prefix test_empty_set_show_doc_parameter {} {
gdb_test "help set print test-empty-set-show-param" \
[multi_line \
"^Set the current value of 'print test-empty-set-show-param'\\." \
- "This command is not documented\\."]
+ "This command is not documented\\." \
+ "Available options are:" \
+ " on, off."]
gdb_test "help show print test-empty-set-show-param" \
[multi_line \
@@ -429,7 +436,9 @@ proc_with_prefix test_empty_set_show_doc_parameter {} {
gdb_test "help set print test-none-set-show-param" \
[multi_line \
"^Set the current value of 'print test-none-set-show-param'\\." \
- "This command is not documented\\."]
+ "This command is not documented\\." \
+ "Available options are:" \
+ " on, off."]
gdb_test "help show print test-none-set-show-param" \
[multi_line \
--
2.54.0
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH v6 2/2] gdb: Improve warning when no native target is available
2026-05-11 20:01 [PATCH v6 0/2] Add warning if the native target is not supported Guinevere Larsen
2026-05-11 20:01 ` [PATCH v6 1/2] gdb: improve help text for set commands with limited options Guinevere Larsen
@ 2026-05-11 20:01 ` Guinevere Larsen
2026-06-22 20:34 ` [PING][PATCH v6 0/2] Add warning if the native target is not supported Guinevere Larsen
2026-07-27 12:05 ` Guinevere Larsen
3 siblings, 0 replies; 5+ messages in thread
From: Guinevere Larsen @ 2026-05-11 20:01 UTC (permalink / raw)
To: gdb-patches; +Cc: Guinevere Larsen, Ciaran Woodward, Tom Tromey
Currently, if a user attempts to debug a program without access to a
native debugger, the error message will just be:
Don't know how to <command>. Try "help target".
This message is too generic, and doesn't help a user without internal
knowledge of GDB.
The present commit changes that message to be more informative for a
user who is unfamiliar with GDB and installed it in an unsupported
system, such as in a mac with M-series chips.
The new error now reads:
No native target available, unable to <command>. Try "help target native".
This may be because your CPU architecture is not supported, use
"help set architecture" for a list of supported architectures.
Reviewed-By: Ciaran Woodward <ciaranwoodward@xmos.com>
Approved-By: Tom Tromey <tom@tromey.com>
---
gdb/inf-child.c | 7 ++++++-
gdb/target.c | 10 +++++++---
gdb/testsuite/gdb.base/auto-connect-native-target.exp | 6 ++++--
3 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/gdb/inf-child.c b/gdb/inf-child.c
index a87aa925133..cbe5fecb78f 100644
--- a/gdb/inf-child.c
+++ b/gdb/inf-child.c
@@ -42,7 +42,12 @@
static const target_info inf_child_target_info = {
"native",
N_("Native process"),
- N_("Native process (started by the \"run\" command).")
+ N_("Native process. Controls native processes in this computer.\n\
+\n\
+This gives GDB the ability to control the execution of binaries in the\n\
+current CPU architecture. It is installed automatically when you attempt\n\
+to \"run\" or \"start\" a program, if the CPU architecure is supported by\n\
+GDB and there is no other target capable of executing those commands.")
};
const target_info &
diff --git a/gdb/target.c b/gdb/target.c
index 5d937f3ae85..e08de38e0ea 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -2907,9 +2907,13 @@ find_default_run_target (const char *do_mesg)
return the_native_target;
if (do_mesg != NULL)
- error (_("Don't know how to %s. Try \"%ps\"."),
- do_mesg,
- styled_string (command_style.style (), "help target"));
+ error (_("\
+No native target available, unable to %s. Try \"%ps\".\n\
+This may be because your CPU architecture is not supported, use\n\
+\"%ps\" for a list of supported architectures."),
+ do_mesg,
+ styled_string (command_style.style (), "help target native"),
+ styled_string (command_style.style (), "help set architecture"));
return NULL;
}
diff --git a/gdb/testsuite/gdb.base/auto-connect-native-target.exp b/gdb/testsuite/gdb.base/auto-connect-native-target.exp
index 26434396cc6..65696f0167c 100644
--- a/gdb/testsuite/gdb.base/auto-connect-native-target.exp
+++ b/gdb/testsuite/gdb.base/auto-connect-native-target.exp
@@ -105,7 +105,8 @@ kill_program "kill"
gdb_test_no_output "set auto-connect-native-target off"
# Commands that rely on the native target auto-connecting should no longer work.
-gdb_test "start" "Don't know how to run.*" "start no longer works"
+gdb_test "start" "No native target available, unable to run.*" \
+ "start no longer works"
# Explicitly connect to the native target.
gdb_test "target native" \
@@ -181,7 +182,8 @@ with_test_prefix "disconnect" {
fail $test
}
- gdb_test "start" "Don't know how to run.*" "start no longer works"
+ gdb_test "start" "No native target available, unable to run.*" \
+ "start no longer works"
}
# Reenable auto-connecting to the native target. Plain "start" should
--
2.54.0
^ permalink raw reply [flat|nested] 5+ messages in thread* [PING][PATCH v6 0/2] Add warning if the native target is not supported
2026-05-11 20:01 [PATCH v6 0/2] Add warning if the native target is not supported Guinevere Larsen
2026-05-11 20:01 ` [PATCH v6 1/2] gdb: improve help text for set commands with limited options Guinevere Larsen
2026-05-11 20:01 ` [PATCH v6 2/2] gdb: Improve warning when no native target is available Guinevere Larsen
@ 2026-06-22 20:34 ` Guinevere Larsen
2026-07-27 12:05 ` Guinevere Larsen
3 siblings, 0 replies; 5+ messages in thread
From: Guinevere Larsen @ 2026-06-22 20:34 UTC (permalink / raw)
To: gdb-patches
Ping! :)
On 5/11/26 5:01 PM, Guinevere Larsen wrote:
> Recently I was trying to conduct a new-user test, to figure out what
> things were stumbling blocks, and one of the users had a macbook. The
> user on their own would not have been able to understand what was the
> reason that they couldn't execute the inferior to debug it.
>
> This series aims to make it a little more obvious, by making the warning
> about not being able to "run" more self-explanatory, and instructs the user
> on how to get a list of supported architectures, to know what they'll be
> able to remotely debug.
>
> For v6, I updated the warning messages on the second patch, based on
> Andrew's feedback. I did *not* implement the changes sugested for patch
> 1, telling the user to use "set <option>". That's because not giving an
> option triggers an error, especially printing the emoji if the user has
> them enabled, and I believe we shouldn't be teaching users to run
> commands that expect to throw an error.
>
> For v5, some tests were updated as Linaro CI correctly pointed out that
> they were failing. The updates were just to expected output, no real
> logic change was required.
>
> v4 has minor cosmetic changes and a test for the help text changes.
>
> For v3, the warning is now only emitted if the user tries to do
> something that requires the native target, such as trying to run. And
> the help text now emits a comma separated list instead of 1 item per
> line.
>
> For v2, instead of adding a new command, this series changes the help
> command, to make it print all available options if a command only
> accepts specific options.
>
>
> Guinevere Larsen (2):
> gdb: improve help text for set commands with limited options
> gdb: Improve warning when no native target is available
>
> gdb/cli/cli-decode.c | 12 ++++++++++++
> gdb/inf-child.c | 7 ++++++-
> gdb/target.c | 10 +++++++---
> .../gdb.base/auto-connect-native-target.exp | 6 ++++--
> gdb/testsuite/gdb.base/help.exp | 9 +++++++++
> gdb/testsuite/gdb.python/py-doc-reformat.exp | 2 +-
> gdb/testsuite/gdb.python/py-parameter.exp | 17 +++++++++++++----
> 7 files changed, 52 insertions(+), 11 deletions(-)
>
>
> base-commit: 9e6e0c3cd9e6d5ee4953f72a805cff5f150aa2fd
--
Cheers,
Guinevere Larsen
it/its
she/her (deprecated)
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PING][PATCH v6 0/2] Add warning if the native target is not supported
2026-05-11 20:01 [PATCH v6 0/2] Add warning if the native target is not supported Guinevere Larsen
` (2 preceding siblings ...)
2026-06-22 20:34 ` [PING][PATCH v6 0/2] Add warning if the native target is not supported Guinevere Larsen
@ 2026-07-27 12:05 ` Guinevere Larsen
3 siblings, 0 replies; 5+ messages in thread
From: Guinevere Larsen @ 2026-07-27 12:05 UTC (permalink / raw)
To: gdb-patches
Ping! :)
On 5/11/26 5:01 PM, Guinevere Larsen wrote:
> Recently I was trying to conduct a new-user test, to figure out what
> things were stumbling blocks, and one of the users had a macbook. The
> user on their own would not have been able to understand what was the
> reason that they couldn't execute the inferior to debug it.
>
> This series aims to make it a little more obvious, by making the warning
> about not being able to "run" more self-explanatory, and instructs the user
> on how to get a list of supported architectures, to know what they'll be
> able to remotely debug.
>
> For v6, I updated the warning messages on the second patch, based on
> Andrew's feedback. I did *not* implement the changes sugested for patch
> 1, telling the user to use "set <option>". That's because not giving an
> option triggers an error, especially printing the emoji if the user has
> them enabled, and I believe we shouldn't be teaching users to run
> commands that expect to throw an error.
>
> For v5, some tests were updated as Linaro CI correctly pointed out that
> they were failing. The updates were just to expected output, no real
> logic change was required.
>
> v4 has minor cosmetic changes and a test for the help text changes.
>
> For v3, the warning is now only emitted if the user tries to do
> something that requires the native target, such as trying to run. And
> the help text now emits a comma separated list instead of 1 item per
> line.
>
> For v2, instead of adding a new command, this series changes the help
> command, to make it print all available options if a command only
> accepts specific options.
>
>
> Guinevere Larsen (2):
> gdb: improve help text for set commands with limited options
> gdb: Improve warning when no native target is available
>
> gdb/cli/cli-decode.c | 12 ++++++++++++
> gdb/inf-child.c | 7 ++++++-
> gdb/target.c | 10 +++++++---
> .../gdb.base/auto-connect-native-target.exp | 6 ++++--
> gdb/testsuite/gdb.base/help.exp | 9 +++++++++
> gdb/testsuite/gdb.python/py-doc-reformat.exp | 2 +-
> gdb/testsuite/gdb.python/py-parameter.exp | 17 +++++++++++++----
> 7 files changed, 52 insertions(+), 11 deletions(-)
>
>
> base-commit: 9e6e0c3cd9e6d5ee4953f72a805cff5f150aa2fd
--
Cheers,
Guinevere Larsen
it/its
she/her (deprecated)
^ permalink raw reply [flat|nested] 5+ messages in thread