aboutsummaryrefslogtreecommitdiff
path: root/gdb/target-descriptions.c
diff options
context:
space:
mode:
authorStafford Horne <shorne@gmail.com>2017-12-27 23:36:31 +0900
committerStafford Horne <shorne@gmail.com>2017-12-27 23:36:31 +0900
commitcef0f8684e818f8b6c71c44dc9cc28a6d0ac3754 (patch)
treef39a9a5943b9dc8de588826f0d4914b1abb9abd2 /gdb/target-descriptions.c
parentf7efd549485db1fd84dbd2f2ee36d80c2739f224 (diff)
downloadbinutils-cef0f8684e818f8b6c71c44dc9cc28a6d0ac3754.zip
binutils-cef0f8684e818f8b6c71c44dc9cc28a6d0ac3754.tar.gz
binutils-cef0f8684e818f8b6c71c44dc9cc28a6d0ac3754.tar.bz2
tdesc: 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 where registers/groups can change. gdb/ChangeLog: yyyy-mm-dd Franck Jullien <franck.jullien@gmail.com> Stafford Horne <shorne@gmail.com> * target-descriptions.c (tdesc_register_in_reggroup_p): Support arbitrary strings. (tdesc_use_registers): Add logic to register new reggroups. (tdesc_reg::group): Update comment to indicate we allow arbitrary strings. * NEWS (Changes since GDB 8.0): Announce that GDB supports arbitrary reggroups. gdb/testsuite/ChangeLog: yyyy-mm-dd Stafford Horne <shorne@gmail.com> * gdb.xml/extra-regs.xml: Add example foo reggroup. * gdb.xml/tdesc-regs.exp: Add test to check for foo reggroup. gdb/doc/ChangeLog: yyyy-mm-dd Stafford Horne <shorne@gmail.com> * gdb.texinfo (Target Description Format): Explain that arbitrary strings are now allowed for register groups.
Diffstat (limited to 'gdb/target-descriptions.c')
-rw-r--r--gdb/target-descriptions.c58
1 files changed, 21 insertions, 37 deletions
diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c
index b37f4f0..e8f098e 100644
--- a/gdb/target-descriptions.c
+++ b/gdb/target-descriptions.c
@@ -111,12 +111,11 @@ struct tdesc_reg : tdesc_element
int save_restore;
/* The name of the register group containing this register, or empty
- if the group should be automatically determined from the
- register's type. If this is "general", "float", or "vector", the
- corresponding "info" command should display this register's
- value. It can be an arbitrary string, but should be limited to
- alphanumeric characters and internal hyphens. Currently other
- strings are ignored (treated as empty). */
+ if the group should be automatically determined from the register's
+ type. This is traditionally "general", "float", "vector" but can
+ also be an arbitrary string. If defined the corresponding "info"
+ command should display this register's value. The string should be
+ limited to alphanumeric characters and internal hyphens. */
std::string group;
/* The size of the register, in bits. */
@@ -1279,17 +1278,13 @@ tdesc_remote_register_number (struct gdbarch *gdbarch, int regno)
}
/* Check whether REGNUM is a member of REGGROUP. Registers from the
- target description may be classified as general, float, or vector.
- Unlike a gdbarch register_reggroup_p method, this function will
- 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.
+ target description may be classified as general, float, vector or other
+ register groups registered with reggroup_add(). Unlike a gdbarch
+ register_reggroup_p method, this function will return -1 if it does not
+ know; the caller should handle registers with no specified group.
+
+ The names of containing features are not used. This might be extended
+ to display registers in some more useful groupings.
The save-restore flag is also implemented here. */
@@ -1299,26 +1294,9 @@ 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 ())
- {
- int general_p = 0, float_p = 0, vector_p = 0;
-
- if (reg->group == "general")
- general_p = 1;
- else if (reg->group == "float")
- float_p = 1;
- else if (reg->group == "vector")
- vector_p = 1;
-
- if (reggroup == float_reggroup)
- return float_p;
-
- if (reggroup == vector_reggroup)
- return vector_p;
-
- if (reggroup == general_reggroup)
- return general_p;
- }
+ if (reg != NULL && !reg->group.empty ()
+ && (reg->group == reggroup_name (reggroup)))
+ return 1;
if (reg != NULL
&& (reggroup == save_reggroup || reggroup == restore_reggroup))
@@ -1421,6 +1399,12 @@ tdesc_use_registers (struct gdbarch *gdbarch,
void **slot = htab_find_slot (reg_hash, reg.get (), INSERT);
*slot = reg.get ();
+ /* Add reggroup if its new. */
+ if (!reg->group.empty ())
+ if (reggroup_find (gdbarch, reg->group.c_str ()) == NULL)
+ reggroup_add (gdbarch, reggroup_gdbarch_new (gdbarch,
+ reg->group.c_str (),
+ USER_REGGROUP));
}
/* Remove any registers which were assigned numbers by the