From: Guinevere Larsen <guinevere@redhat.com>
To: gdb-patches@sourceware.org
Cc: Guinevere Larsen <guinevere@redhat.com>
Subject: [PATCH 1/2] gdb: introduce command "info architecture"
Date: Thu, 6 Nov 2025 16:45:13 -0300 [thread overview]
Message-ID: <20251106194514.1857177-2-guinevere@redhat.com> (raw)
In-Reply-To: <20251106194514.1857177-1-guinevere@redhat.com>
There is no convenient way to tell a user how to check which
architectures are supported by their build of GDB. This hasn't really
been a problem, but now that GDB isn't ported to Apple's new CPU
architectures, a user could run into a situation where they're trying to
debug an unsupported CPU.
This commit adds a way to list supported architectures, and filter them
using a regular expression. No test is added because I couldn't think
of a good way to verify functionality when we can't control the
configure line.
---
gdb/NEWS | 4 ++++
gdb/arch-utils.c | 28 ++++++++++++++++++++++++++++
gdb/doc/gdb.texinfo | 5 +++++
3 files changed, 37 insertions(+)
diff --git a/gdb/NEWS b/gdb/NEWS
index 64e35f1a438..8d87e2473f7 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -45,6 +45,10 @@ maintenance test-remote-args ARGS
Test splitting and joining of inferior arguments ARGS as they would
be split and joined when being passed to a remote target.
+info architectures [REGEXP]
+ List CPU microarchitectures supported by this build of GDB. If
+ REGEXP is provided, filter to microarchitectures that match it.
+
* Changed commands
maintenance info program-spaces
diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c
index 8e3f79089d4..4367e26c02b 100644
--- a/gdb/arch-utils.c
+++ b/gdb/arch-utils.c
@@ -682,6 +682,28 @@ static enum bfd_endian default_byte_order = BFD_ENDIAN_UNKNOWN;
"set arch" command. */
static std::vector<const char *> arches;
+/* Implementation of "info architectures" command. */
+
+static void
+info_architectures_command (const char *args, int from_tty)
+{
+ bool filtered = false;
+ if (args != nullptr && args[0] != '\0')
+ {
+ char *re_err = re_comp (args);
+ if (re_err != nullptr)
+ error (_("Invalid regexp: %s"), re_err);
+ filtered = true;
+ }
+ for (const char *s : arches)
+ {
+ if (s == nullptr)
+ break;
+ if (!filtered || re_exec (s))
+ gdb_printf ("%s\n", s);
+ }
+}
+
void
initialize_current_architecture (void)
{
@@ -767,6 +789,12 @@ initialize_current_architecture (void)
&setlist, &showlist);
add_alias_cmd ("processor", architecture_cmds.set, class_support, 1,
&setlist);
+ add_info ("architectures", info_architectures_command,
+ _("List supported CPU microarchitectures.\n\
+\n\
+Usage: info architectures [REGEXP]\n\
+If REGEXP is supplied, list supported microarchitectures that match the\n\
+regular expresion. Otherwise list all supported microarchitectures."));
}
}
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 854f22b612e..a4576ca3703 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -23428,6 +23428,11 @@ Show the current target architecture.
@kindex show processor
These are alias commands for, respectively, @code{set architecture}
and @code{show architecture}.
+
+@item info architectures
+@item info architectures @var{regexp}
+List architectures supported by GDB. If @var{regexp} is provided, filter
+results through the regular expression, otherwise list all architectures.
@end table
@menu
--
2.51.0
next prev parent reply other threads:[~2025-11-06 19:47 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-06 19:45 [PATCH 0/2] Add warning if the native target is not supported Guinevere Larsen
2025-11-06 19:45 ` Guinevere Larsen [this message]
2025-11-06 23:24 ` [PATCH 1/2] gdb: introduce command "info architecture" Maciej W. Rozycki
2025-11-07 13:10 ` Guinevere Larsen
2025-11-07 15:51 ` Maciej W. Rozycki
2025-11-07 16:05 ` Hannes Domani
2025-11-08 2:02 ` Maciej W. Rozycki
2025-11-27 19:51 ` Guinevere Larsen
2025-11-27 20:00 ` Maciej W. Rozycki
2025-11-27 20:09 ` Guinevere Larsen
2025-11-28 9:20 ` Maciej W. Rozycki
2025-12-01 16:49 ` Guinevere Larsen
2025-11-07 7:46 ` Eli Zaretskii
2025-11-07 13:41 ` Guinevere Larsen
2025-11-07 14:23 ` Eli Zaretskii
2025-11-08 2:25 ` Maciej W. Rozycki
2025-11-27 20:01 ` Guinevere Larsen
2025-11-28 9:20 ` Maciej W. Rozycki
2025-11-06 19:45 ` [PATCH 2/2] gdb: add warning when no native target is available Guinevere Larsen
2025-11-07 7:48 ` Eli Zaretskii
2025-11-07 13:24 ` Guinevere Larsen
2025-11-07 14:21 ` Eli Zaretskii
2025-11-27 20:15 ` 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=20251106194514.1857177-2-guinevere@redhat.com \
--to=guinevere@redhat.com \
--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