public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: gdb-patches@sourceware.org
Subject: [PATCH] sim: add --info-target for listing supported BFD targets
Date: Mon,  4 Oct 2021 02:20:39 -0400	[thread overview]
Message-ID: <20211004062039.7431-1-vapier@gentoo.org> (raw)

It can be difficult to guess the exact bfd name, so add an option to
list all the targets that the current build supports.  This aligns with
other simulator options like --info-architecture.
---
 sim/common/sim-options.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/sim/common/sim-options.c b/sim/common/sim-options.c
index e6d1107f7c55..e82ac33fe764 100644
--- a/sim/common/sim-options.c
+++ b/sim/common/sim-options.c
@@ -93,6 +93,7 @@ typedef enum {
   OPTION_DO_COMMAND,
   OPTION_ARCHITECTURE,
   OPTION_TARGET,
+  OPTION_TARGET_INFO,
   OPTION_ARCHITECTURE_INFO,
   OPTION_ENVIRONMENT,
   OPTION_ALIGNMENT,
@@ -161,6 +162,10 @@ static const OPTION standard_options[] =
   { {"target", required_argument, NULL, OPTION_TARGET},
       '\0', "BFDNAME", "Specify the object-code format for the object files",
       standard_option_handler },
+  { {"target-info", no_argument, NULL, OPTION_TARGET_INFO},
+      '\0', NULL, "List supported targets", standard_option_handler },
+  { {"info-target", no_argument, NULL, OPTION_TARGET_INFO},
+      '\0', NULL, NULL, standard_option_handler },
 
   { {"load-lma", no_argument, NULL, OPTION_LOAD_LMA},
       '\0', NULL,
@@ -365,6 +370,20 @@ standard_option_handler (SIM_DESC sd, sim_cpu *cpu, int opt,
 	break;
       }
 
+    case OPTION_TARGET_INFO:
+      {
+	const char **list = bfd_target_list ();
+	const char **lp;
+	if (list == NULL)
+	  abort ();
+	sim_io_printf (sd, "Possible targets:");
+	for (lp = list; *lp != NULL; lp++)
+	  sim_io_printf (sd, " %s", *lp);
+	sim_io_printf (sd, "\n");
+	free (list);
+	break;
+      }
+
     case OPTION_LOAD_LMA:
       {
 	STATE_LOAD_AT_LMA_P (sd) = 1;
-- 
2.33.0


                 reply	other threads:[~2021-10-04  6:20 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20211004062039.7431-1-vapier@gentoo.org \
    --to=vapier@gentoo.org \
    --cc=gdb-patches@sourceware.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).