aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Burgess <aburgess@redhat.com>2022-08-11 12:43:08 +0100
committerAndrew Burgess <aburgess@redhat.com>2022-08-31 16:07:05 +0100
commitb49d7aa74466fb73529ebf0e6c907c2142505610 (patch)
tree4dd5a8cb2bb7725b23d07b8680623fe4811c2088
parent3095d92634a938d447eed1ef2c5d59f40f44078e (diff)
downloadgdb-b49d7aa74466fb73529ebf0e6c907c2142505610.zip
gdb-b49d7aa74466fb73529ebf0e6c907c2142505610.tar.gz
gdb-b49d7aa74466fb73529ebf0e6c907c2142505610.tar.bz2
gdb: Add tdesc_found_register function to tdesc API
This commit adds a new function to the target description API within GDB. This new function is not used in this commit, but will be used in the next commit, I'm splitting it out into a separate patch for easier review. What I want to do in the next commit is check to see if a target description supplied a particular register, however, the register in question could appear in one of two possible features. The new function allows me to ask the tdesc_arch_data whether a register was found and assigned a particular GDB register number once all of the features have been checked. I think this is a much simpler solution than adding code such that, while checking each feature, I spot if the register I'm processing is the one I care about. No tests here as the new code is not used, but this code will be exercised in the next commit.
-rw-r--r--gdb/target-descriptions.c11
-rw-r--r--gdb/target-descriptions.h4
2 files changed, 15 insertions, 0 deletions
diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c
index d5d7958..044b171 100644
--- a/gdb/target-descriptions.c
+++ b/gdb/target-descriptions.c
@@ -849,6 +849,17 @@ tdesc_numbered_register_choices (const struct tdesc_feature *feature,
return 0;
}
+/* See target-descriptions.h. */
+
+bool
+tdesc_found_register (struct tdesc_arch_data *data, int regno)
+{
+ gdb_assert (regno >= 0);
+
+ return (regno < data->arch_regs.size ()
+ && data->arch_regs[regno].reg != nullptr);
+}
+
/* Search FEATURE for a register named NAME, and return its size in
bits. The register must exist. */
diff --git a/gdb/target-descriptions.h b/gdb/target-descriptions.h
index 3b90ded..3ab0ae2 100644
--- a/gdb/target-descriptions.h
+++ b/gdb/target-descriptions.h
@@ -170,6 +170,10 @@ int tdesc_numbered_register_choices (const struct tdesc_feature *feature,
struct tdesc_arch_data *data,
int regno, const char *const names[]);
+/* Return true if DATA contains an entry for REGNO, a GDB register
+ number. */
+
+extern bool tdesc_found_register (struct tdesc_arch_data *data, int regno);
/* Accessors for target descriptions. */