[PATCH v5 2/2] gdb: Improve warning when no native target is available

Guinevere Larsen
2026-03-10T14:26:27Z

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.

Reviewed-By: Ciaran Woodward <ciaranwoodward@xmos.com>
Approved-By: Tom Tromey <tom@tromey.com>
---
gdb/inf-child.c | 7 ++++++-
gdb/target.c | 5 ++++-
gdb/testsuite/gdb.base/auto-connect-native-target.exp | 6 ++++--
3 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/gdb/inf-child.c b/gdb/inf-child.c
index 7983ecb0d92..ae2cadc5e2b 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.\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.")
};

const target_info &
diff --git a/gdb/target.c b/gdb/target.c
index 77a562aa919..6fc1872685f 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -2899,7 +2899,10 @@ find_default_run_target (const char *do_mesg)
return the_native_target;

if (do_mesg != NULL)
- error (_("Don't know how to %s. Try \"help target\"."), do_mesg);
+ error (_("\
+No native target available, unable to %s. Try \"help target native\".\n\
+This may be because your CPU architecture is not supported, use\n\
+\"help set architecture\" for a list of supported architectures."), do_mesg);
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.53.0