From: Andrew Burgess Date: Thu, 31 Mar 2022 17:10:34 +0000 (+0100) Subject: gdb: move struct reggroup into reggroups.h header X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=af7ce09b7685050d2ca1a8a746bb8a8c080fff69;p=binutils-gdb.git 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. --- 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)); } diff --git a/gdb/python/py-registers.c b/gdb/python/py-registers.c index 6255ddac9e7..bbb322f068c 100644 --- a/gdb/python/py-registers.c +++ b/gdb/python/py-registers.c @@ -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. 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 @@ 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 = ","; } } diff --git a/gdb/reggroups.c b/gdb/reggroups.c index 643337e3aee..42232811087 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 2f38b67e9a2..5f8a8a395b3 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 & 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 2e597d061dc..5106a3b9670 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");