public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Andrew Burgess <aburgess@redhat.com>
To: gdb-patches@sourceware.org
Cc: Andrew Burgess <aburgess@redhat.com>
Subject: [PATCHv2 15/16] gdb: move struct reggroup into reggroups.h header
Date: Wed,  6 Apr 2022 13:04:48 +0100	[thread overview]
Message-ID: <4facdadcd217fac81bc2a1f351cc14ce444a8279.1649246539.git.aburgess@redhat.com> (raw)
In-Reply-To: <cover.1649246538.git.aburgess@redhat.com>

Move 'struct reggroup' into the reggroups.h header.  Remove the
reggroup_name and reggroup_type accessor functions, and just use the
name/type member functions within 'struct reggroup', update all uses
of these removed functions.

There should be no user visible changes after this commit.
---
 gdb/completer.c           |  2 +-
 gdb/infcmd.c              |  2 +-
 gdb/nds32-tdep.c          |  2 +-
 gdb/python/py-registers.c |  3 +--
 gdb/regcache-dump.c       |  3 +--
 gdb/reggroups.c           | 41 ---------------------------------------
 gdb/reggroups.h           | 32 +++++++++++++++++++++++++-----
 gdb/target-descriptions.c |  2 +-
 gdb/tui/tui-regs.c        |  6 +++---
 9 files changed, 36 insertions(+), 57 deletions(-)

diff --git a/gdb/completer.c b/gdb/completer.c
index f4b5917095d..fea3eb9329d 100644
--- a/gdb/completer.c
+++ b/gdb/completer.c
@@ -1821,7 +1821,7 @@ reg_or_group_completer_1 (completion_tracker &tracker,
     {
       for (const struct reggroup *group : gdbarch_reggroups (gdbarch))
 	{
-	  name = reggroup_name (group);
+	  name = group->name ();
 	  if (strncmp (word, name, len) == 0)
 	    tracker.add_completion (make_unique_xstrdup (name));
 	}
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 9abb91f2faa..719bd6888a8 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -2301,7 +2301,7 @@ registers_info (const char *addr_exp, int fpregs)
 	    /* Don't bother with a length check.  Should the user
 	       enter a short register group name, go with the first
 	       group that matches.  */
-	    if (strncmp (start, reggroup_name (g), end - start) == 0)
+	    if (strncmp (start, g->name (), end - start) == 0)
 	      {
 		group = g;
 		break;
diff --git a/gdb/nds32-tdep.c b/gdb/nds32-tdep.c
index 06b129bdd31..e95ad7cc662 100644
--- a/gdb/nds32-tdep.c
+++ b/gdb/nds32-tdep.c
@@ -390,7 +390,7 @@ nds32_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
   /* The NDS32 reggroup contains registers whose name is prefixed
      by reggroup name.  */
   reg_name = gdbarch_register_name (gdbarch, regnum);
-  group_name = reggroup_name (reggroup);
+  group_name = reggroup->name ();
   return !strncmp (reg_name, group_name, strlen (group_name));
 }
 \f
diff --git a/gdb/python/py-registers.c b/gdb/python/py-registers.c
index 7a9d2e22403..725cab5d6fb 100644
--- a/gdb/python/py-registers.c
+++ b/gdb/python/py-registers.c
@@ -137,8 +137,7 @@ gdbpy_reggroup_to_string (PyObject *self)
   reggroup_object *group = (reggroup_object *) self;
   const reggroup *reggroup = group->reggroup;
 
-  const char *name = reggroup_name (reggroup);
-  return PyUnicode_FromString (name);
+  return PyUnicode_FromString (reggroup->name ());
 }
 
 /* Implement gdb.RegisterGroup.name (self) -> String.
diff --git a/gdb/regcache-dump.c b/gdb/regcache-dump.c
index 409a868be76..0c5da0e241d 100644
--- a/gdb/regcache-dump.c
+++ b/gdb/regcache-dump.c
@@ -196,8 +196,7 @@ class register_dump_groups : public register_dump
 	  {
 	    if (gdbarch_register_reggroup_p (m_gdbarch, regnum, group))
 	      {
-		gdb_printf (file,
-			    "%s%s", sep, reggroup_name (group));
+		gdb_printf (file, "%s%s", sep, group->name ());
 		sep = ",";
 	      }
 	  }
diff --git a/gdb/reggroups.c b/gdb/reggroups.c
index dfae60773bb..96d4ae4d1f8 100644
--- a/gdb/reggroups.c
+++ b/gdb/reggroups.c
@@ -28,33 +28,6 @@
 #include "gdbcmd.h"		/* For maintenanceprintlist.  */
 #include "gdbsupport/gdb_obstack.h"
 
-/* Individual register groups.  */
-
-struct reggroup
-{
-  /* Create a new register group object.  The NAME is not owned by the new
-     reggroup object, so must outlive the object.  */
-  reggroup (const char *name, enum reggroup_type type)
-    : m_name (name),
-      m_type (type)
-  { /* Nothing.  */ }
-
-  /* Return the name for this register group.  */
-  const char *name () const
-  { return m_name; }
-
-  /* Return the type of this register group.  */
-  enum reggroup_type type () const
-  { return m_type; }
-
-private:
-  /* The name of this register group.  */
-  const char *m_name;
-
-  /* The type of this register group.  */
-  enum reggroup_type m_type;
-};
-
 const reggroup *
 reggroup_new (const char *name, enum reggroup_type type)
 {
@@ -72,20 +45,6 @@ reggroup_gdbarch_new (struct gdbarch *gdbarch, const char *name,
 				       name, type);
 }
 
-/* Register group attributes.  */
-
-const char *
-reggroup_name (const struct reggroup *group)
-{
-  return group->name ();
-}
-
-enum reggroup_type
-reggroup_type (const struct reggroup *group)
-{
-  return group->type ();
-}
-
 /* A container holding all the register groups for a particular
    architecture.  */
 
diff --git a/gdb/reggroups.h b/gdb/reggroups.h
index ec1d79dfc30..db5625a53bd 100644
--- a/gdb/reggroups.h
+++ b/gdb/reggroups.h
@@ -23,10 +23,36 @@
 #define REGGROUPS_H
 
 struct gdbarch;
-struct reggroup;
 
 enum reggroup_type { USER_REGGROUP, INTERNAL_REGGROUP };
 
+/* Individual register group.  */
+
+struct reggroup
+{
+  /* Create a new register group object.  The NAME is not owned by the new
+     reggroup object, so must outlive the object.  */
+  reggroup (const char *name, enum reggroup_type type)
+    : m_name (name),
+      m_type (type)
+  { /* Nothing.  */ }
+
+  /* Return the name for this register group.  */
+  const char *name () const
+  { return m_name; }
+
+  /* Return the type of this register group.  */
+  enum reggroup_type type () const
+  { return m_type; }
+
+private:
+  /* The name of this register group.  */
+  const char *m_name;
+
+  /* The type of this register group.  */
+  enum reggroup_type m_type;
+};
+
 /* Pre-defined, user visible, register groups.  */
 extern const reggroup *const general_reggroup;
 extern const reggroup *const float_reggroup;
@@ -50,10 +76,6 @@ extern const reggroup *reggroup_gdbarch_new (struct gdbarch *gdbarch,
 /* Add a register group (with attribute values) to the pre-defined list.  */
 extern void reggroup_add (struct gdbarch *gdbarch, const reggroup *group);
 
-/* Register group attributes.  */
-extern const char *reggroup_name (const struct reggroup *reggroup);
-extern enum reggroup_type reggroup_type (const struct reggroup *reggroup);
-
 /* Return the list of all register groups for GDBARCH.  */
 extern const std::vector<const reggroup *>
 	gdbarch_reggroups (struct gdbarch *gdbarch);
diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c
index 33277c3d02d..85954ac2939 100644
--- a/gdb/target-descriptions.c
+++ b/gdb/target-descriptions.c
@@ -1012,7 +1012,7 @@ tdesc_register_in_reggroup_p (struct gdbarch *gdbarch, int regno,
   struct tdesc_reg *reg = tdesc_find_register (gdbarch, regno);
 
   if (reg != NULL && !reg->group.empty ()
-      && (reg->group == reggroup_name (reggroup)))
+      && (reg->group == reggroup->name ()))
 	return 1;
 
   if (reg != NULL
diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index acffc75238a..2ee197fe192 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -216,7 +216,7 @@ tui_data_window::show_register_group (const reggroup *group,
   int regnum, pos;
 
   /* Make a new title showing which group we display.  */
-  title = string_printf ("Register group: %s", reggroup_name (group));
+  title = string_printf ("Register group: %s", group->name ());
 
   /* See how many registers must be displayed.  */
   nr_regs = 0;
@@ -595,7 +595,7 @@ tui_reg_command (const char *args, int from_tty)
 	     group then the switch is made.  */
 	  for (const struct reggroup *group : gdbarch_reggroups (gdbarch))
 	    {
-	      if (strncmp (reggroup_name (group), args, len) == 0)
+	      if (strncmp (group->name (), args, len) == 0)
 		{
 		  if (match != NULL)
 		    error (_("ambiguous register group name '%s'"), args);
@@ -621,7 +621,7 @@ tui_reg_command (const char *args, int from_tty)
 	  if (!first)
 	    gdb_printf (", ");
 	  first = false;
-	  gdb_printf ("%s", reggroup_name (group));
+	  gdb_printf ("%s", group->name ());
 	}
 
       gdb_printf ("\n");
-- 
2.25.4


  parent reply	other threads:[~2022-04-06 12:05 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-31 21:04 [PATCH 00/16] Default register groups, and general related cleanup Andrew Burgess
2022-03-31 21:04 ` [PATCH 01/16] gdb: don't try to use readline before it's initialized Andrew Burgess
2022-03-31 21:04 ` [PATCH 02/16] gdb: add some const in gdb/reggroups.c Andrew Burgess
2022-03-31 21:04 ` [PATCH 03/16] gdb: make gdbarch_register_reggroup_p take a const reggroup * Andrew Burgess
2022-04-04 22:35   ` Lancelot SIX
2022-04-05  8:24     ` Andrew Burgess
2022-03-31 21:04 ` [PATCH 04/16] gdb: switch to using 'const reggroup *' in tui-regs.{c, h} Andrew Burgess
2022-03-31 21:04 ` [PATCH 05/16] gdb: use 'const reggroup *' in python/py-registers.c file Andrew Burgess
2022-03-31 21:04 ` [PATCH 06/16] gdb: have reggroup_find return a const Andrew Burgess
2022-03-31 21:04 ` [PATCH 07/16] gdb/tui: avoid theoretical bug with 'tui reg' command Andrew Burgess
2022-03-31 21:04 ` [PATCH 08/16] gdb/tui: fix 'tui reg next/prev' command when data window is hidden Andrew Burgess
2022-03-31 21:04 ` [PATCH 09/16] gdb: always add the default register groups Andrew Burgess
2022-03-31 21:04 ` [PATCH 10/16] gdb: convert reggroups to use a std::vector Andrew Burgess
2022-03-31 21:04 ` [PATCH 11/16] gdb: remove reggroup_next and reggroup_prev Andrew Burgess
2022-04-05 23:11   ` Lancelot SIX
2022-04-06 12:06     ` Andrew Burgess
2022-03-31 21:04 ` [PATCH 12/16] gdb: more 'const' in gdb/reggroups.{c,h} Andrew Burgess
2022-03-31 21:04 ` [PATCH 13/16] gdb: make the pre-defined register groups const Andrew Burgess
2022-03-31 21:04 ` [PATCH 14/16] gdb: convert reggroup to a C++ class with constructor, etc Andrew Burgess
2022-03-31 21:04 ` [PATCH 15/16] gdb: move struct reggroup into reggroups.h header Andrew Burgess
2022-03-31 21:04 ` [PATCH 16/16] gdb: update comments throughout reggroups.{c,h} files Andrew Burgess
2022-04-06 14:28   ` Simon Marchi
2022-04-06 12:04 ` [PATCHv2 00/16] Default register groups, and general related cleanup Andrew Burgess
2022-04-06 12:04   ` [PATCHv2 01/16] gdb: don't try to use readline before it's initialized Andrew Burgess
2022-04-06 12:57     ` Simon Marchi
2022-04-06 12:04   ` [PATCHv2 02/16] gdb: add some const in gdb/reggroups.c Andrew Burgess
2022-04-06 12:58     ` Simon Marchi
2022-04-06 12:04   ` [PATCHv2 03/16] gdb: make gdbarch_register_reggroup_p take a const reggroup * Andrew Burgess
2022-04-06 12:04   ` [PATCHv2 04/16] gdb: switch to using 'const reggroup *' in tui-regs.{c, h} Andrew Burgess
2022-04-06 12:04   ` [PATCHv2 05/16] gdb: use 'const reggroup *' in python/py-registers.c file Andrew Burgess
2022-04-06 12:04   ` [PATCHv2 06/16] gdb: have reggroup_find return a const Andrew Burgess
2022-04-06 12:04   ` [PATCHv2 07/16] gdb/tui: avoid theoretical bug with 'tui reg' command Andrew Burgess
2022-04-06 13:02     ` Simon Marchi
2022-04-06 12:04   ` [PATCHv2 08/16] gdb/tui: fix 'tui reg next/prev' command when data window is hidden Andrew Burgess
2022-04-06 13:13     ` Simon Marchi
2022-04-06 12:04   ` [PATCHv2 09/16] gdb: always add the default register groups Andrew Burgess
2022-04-06 13:22     ` Simon Marchi
2022-04-06 12:04   ` [PATCHv2 10/16] gdb: convert reggroups to use a std::vector Andrew Burgess
2022-04-06 12:04   ` [PATCHv2 11/16] gdb: remove reggroup_next and reggroup_prev Andrew Burgess
2022-04-06 14:22     ` Simon Marchi
2022-04-06 14:23       ` Simon Marchi
2022-04-06 12:04   ` [PATCHv2 12/16] gdb: more 'const' in gdb/reggroups.{c,h} Andrew Burgess
2022-04-06 12:04   ` [PATCHv2 13/16] gdb: make the pre-defined register groups const Andrew Burgess
2022-04-06 12:04   ` [PATCHv2 14/16] gdb: convert reggroup to a C++ class with constructor, etc Andrew Burgess
2022-04-06 12:04   ` Andrew Burgess [this message]
2022-04-06 12:04   ` [PATCHv2 16/16] gdb: update comments throughout reggroups.{c, h} files Andrew Burgess
2022-04-06 14:34   ` [PATCHv2 00/16] Default register groups, and general related cleanup Simon Marchi
2022-04-07 15:16     ` Andrew Burgess

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=4facdadcd217fac81bc2a1f351cc14ce444a8279.1649246539.git.aburgess@redhat.com \
    --to=aburgess@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).