Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Guinevere Larsen <guinevere@redhat.com>
To: gdb-patches@sourceware.org
Cc: Guinevere Larsen <guinevere@redhat.com>,
	Ciaran Woodward <ciaranwoodward@xmos.com>,
	Tom Tromey <tom@tromey.com>
Subject: [PATCH v6 2/2] gdb: Improve warning when no native target is available
Date: Mon, 11 May 2026 17:01:26 -0300	[thread overview]
Message-ID: <20260511200126.75554-3-guinevere@redhat.com> (raw)
In-Reply-To: <20260511200126.75554-1-guinevere@redhat.com>

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


  parent reply	other threads:[~2026-05-11 20:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260511200126.75554-3-guinevere@redhat.com \
    --to=guinevere@redhat.com \
    --cc=ciaranwoodward@xmos.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox