gdb: move struct reggroup into reggroups.h header

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.
This commit is contained in:
Andrew Burgess 2022-03-31 18:10:34 +01:00
parent c30c0f062e
commit af7ce09b76
9 changed files with 36 additions and 57 deletions

View file

@ -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));
}

View file

@ -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;

View file

@ -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));
}

View file

@ -136,8 +136,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.

View file

@ -196,8 +196,7 @@ protected:
{
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 = ",";
}
}

View file

@ -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. */

View file

@ -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);

View file

@ -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

View file

@ -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");