Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andrew Burgess via Gdb-patches <gdb-patches@sourceware.org>
To: gdb-patches@sourceware.org
Cc: Andrew Burgess <aburgess@redhat.com>
Subject: [PATCH 2/3] gdb: Add tdesc_found_register function to tdesc API
Date: Tue, 16 Aug 2022 11:09:57 +0100	[thread overview]
Message-ID: <8d6f1d573eefa6949ff1b72f58d4c0366d34951c.1660644464.git.aburgess@redhat.com> (raw)
In-Reply-To: <cover.1660644464.git.aburgess@redhat.com>

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.
---
 gdb/target-descriptions.c | 11 +++++++++++
 gdb/target-descriptions.h |  4 ++++
 2 files changed, 15 insertions(+)

diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c
index d5d795875c2..044b171ecd2 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 3b90dedcd80..3ab0ae2542d 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.  */
 
-- 
2.25.4


  parent reply	other threads:[~2022-08-16 10:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-16 10:09 [PATCH 0/3] RISC-V fflags, frm, and fcsr (includes small tdesc change) Andrew Burgess via Gdb-patches
2022-08-16 10:09 ` [PATCH 1/3] gdb/riscv: improve (and fix) display of frm field in 'info registers' Andrew Burgess via Gdb-patches
2022-08-16 10:09 ` Andrew Burgess via Gdb-patches [this message]
2022-08-16 10:09 ` [PATCH 3/3] gdb/riscv: better support for fflags and frm registers Andrew Burgess via Gdb-patches
2022-08-31 15:11   ` Andrew Burgess via Gdb-patches
2022-08-16 16:26 ` [PATCH 0/3] RISC-V fflags, frm, and fcsr (includes small tdesc change) John Baldwin
2022-08-31 15:33 ` Andrew Burgess via Gdb-patches

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=8d6f1d573eefa6949ff1b72f58d4c0366d34951c.1660644464.git.aburgess@redhat.com \
    --to=gdb-patches@sourceware.org \
    --cc=aburgess@redhat.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