Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Stafford Horne <shorne@gmail.com>
To: gdb-patches@sourceware.org
Cc: openrisc@lists.librecores.org, Franck Jullien <franck.jullien@gmail.com>
Subject: [PATCH v2 1/4] gdb: Add tdesc_find_register functions
Date: Sun, 27 Nov 2016 06:17:00 -0000	[thread overview]
Message-ID: <ffdc788c10996edca2b068acd5d43fda1592be01.1480216015.git.shorne@gmail.com> (raw)
In-Reply-To: <cover.1480216015.git.shorne@gmail.com>
In-Reply-To: <cover.1480216015.git.shorne@gmail.com>

From: Franck Jullien <franck.jullien@gmail.com>

In order to get registers names and groups from the target descriptor
file, some new functions are needed.

This patch adds:

- tdesc_find_register_name: Search FEATURE for a register REGNO and
  return its name.

- tdesc_find_register_group_name: Search FEATURE for a register
  REGNO and return its group name.

Also, handle arbitrary strings in tdesc_register_in_reggroup_p

tdesc_register_in_reggroup_p in now able to handle arbitrary
groups. This is useful when groups are created while the
target descriptor file is received from the remote.

This can be the case of a soft core target processor's like OpenRISC
where registers/groups can change.

2013-02-15  Franck Jullien  <franck.jullien@gmail.com>

	* target-descriptions.c: (tdesc_find_register_name) Create.
	(tdesc_find_register_group_name) Create.
	(tdesc_register_in_reggroup_p) Support arbitrary groups.
	* target-descriptions.h: (tdesc_find_register_name) Create.
	(tdesc_find_register_group_name) Create.
---
 gdb/target-descriptions.c | 46 ++++++++++++++++++++++++++++++++++++++++------
 gdb/target-descriptions.h | 12 ++++++++++++
 2 files changed, 52 insertions(+), 6 deletions(-)

diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c
index 40f0478..a542ef9 100644
--- a/gdb/target-descriptions.c
+++ b/gdb/target-descriptions.c
@@ -900,6 +900,40 @@ tdesc_numbered_register (const struct tdesc_feature *feature,
   return 1;
 }
 
+/* Search FEATURE for a register REGNO and return its name. */
+char *
+tdesc_find_register_name (const struct tdesc_feature *feature,
+			   int regno)
+{
+  int ixr;
+  struct tdesc_reg *reg;
+
+  for (ixr = 0;
+       VEC_iterate (tdesc_reg_p, feature->registers, ixr, reg);
+       ixr++)
+    if (ixr == regno)
+      return reg->name;
+
+  return NULL;
+}
+
+/* Search FEATURE for a register REGNO and return its group name. */
+char *
+tdesc_find_register_group_name (const struct tdesc_feature *feature,
+			   int regno)
+{
+  int ixr;
+  struct tdesc_reg *reg;
+
+  for (ixr = 0;
+       VEC_iterate (tdesc_reg_p, feature->registers, ixr, reg);
+       ixr++)
+    if (ixr == regno)
+      return reg->group;
+
+  return NULL;
+}
+
 /* Search FEATURE for a register named NAME, but do not assign a fixed
    register number to it.  */
 
@@ -1084,12 +1118,8 @@ tdesc_remote_register_number (struct gdbarch *gdbarch, int regno)
    return -1 if it does not know; the caller should handle registers
    with no specified group.
 
-   Arbitrary strings (other than "general", "float", and "vector")
-   from the description are not used; they cause the register to be
-   displayed in "info all-registers" but excluded from "info
-   registers" et al.  The names of containing features are also not
-   used.  This might be extended to display registers in some more
-   useful groupings.
+   The names of containing features are also not used.  This might be
+   extended to display registers in some more useful groupings.
 
    The save-restore flag is also implemented here.  */
 
@@ -1118,6 +1148,10 @@ tdesc_register_in_reggroup_p (struct gdbarch *gdbarch, int regno,
 
       if (reggroup == general_reggroup)
 	return general_p;
+
+      if (strcmp (reg->group, reggroup_name (reggroup)) == 0)
+	return 1;
+
     }
 
   if (reg != NULL
diff --git a/gdb/target-descriptions.h b/gdb/target-descriptions.h
index ef97d1d..0d8f03f 100644
--- a/gdb/target-descriptions.h
+++ b/gdb/target-descriptions.h
@@ -111,6 +111,18 @@ struct tdesc_arch_data *tdesc_data_alloc (void);
 
 void tdesc_data_cleanup (void *data_untyped);
 
+/* Search FEATURE for a register REGNO and return its name. */
+
+char *tdesc_find_register_name (const struct tdesc_feature *feature,
+				int regno);
+
+
+/* Search FEATURE for a register REGNO and return its group name. */
+
+char *tdesc_find_register_group_name (const struct tdesc_feature *feature,
+				      int regno);
+
+
 /* Search FEATURE for a register named NAME.  Record REGNO and the
    register in DATA; when tdesc_use_registers is called, REGNO will be
    assigned to the register.  1 is returned if the register was found,
-- 
2.7.4


  reply	other threads:[~2016-11-27  6:17 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-27  6:18 [PATCH v2 0/4] gdb: Port for OpenRISC Stafford Horne
2016-11-27  6:17 ` Stafford Horne [this message]
2016-11-27  6:42   ` [PATCH v2 1/4] gdb: Add tdesc_find_register functions Mike Frysinger
2016-11-27  7:09     ` Stafford Horne
2016-11-27  6:17 ` [PATCH v2 4/4] Add gdb for or1k build Stafford Horne
2016-11-27  6:17 ` [PATCH v2 3/4] gdb: testsuite: Add or1k l.nop inscruction Stafford Horne
2016-11-27  6:18 ` [PATCH v2 2/4] gdb: Add OpenRISC or1k and or1knd target support Stafford Horne
2016-11-29 10:06   ` Yao Qi
2016-12-22 16:11     ` Stafford Horne

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=ffdc788c10996edca2b068acd5d43fda1592be01.1480216015.git.shorne@gmail.com \
    --to=shorne@gmail.com \
    --cc=franck.jullien@gmail.com \
    --cc=gdb-patches@sourceware.org \
    --cc=openrisc@lists.librecores.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