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_nb_feature: Return the number of features available in the
  target descriptor.

- tdesc_feature_idx_name: Return the name of feature given it's index.

- tdesc_set_register_group_early: Search FEATURE for a register named
  NAME and set its group to GROUP.

- tdesc_register_group: Search GDBARCH for a register REGNO and return
  its group.

Signed-off-by: Franck Jullien <[email protected]>
---
 gdb/target-descriptions.c |   69 +++++++++++++++++++++++++++++++++++++++++++++
 gdb/target-descriptions.h |   24 +++++++++++++++
 2 files changed, 93 insertions(+), 0 deletions(-)

diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c
index 7206166..b8cd05b 100644
--- a/gdb/target-descriptions.c
+++ b/gdb/target-descriptions.c
@@ -455,6 +455,27 @@ tdesc_find_feature (const struct target_desc *target_desc,
   return NULL;
 }
 
+/* Return the number of features available in the target descriptor.  */
+int
+tdesc_nb_feature (const struct target_desc *target_desc)
+{
+  return VEC_length(tdesc_feature_p, target_desc->features);
+}
+
+/* Return the name of feature given it's index. */
+const char *
+tdesc_feature_idx_name (const struct target_desc *target_desc, int index)
+{
+  struct tdesc_feature *feature;
+
+  feature = VEC_index(tdesc_feature_p, target_desc->features, index);
+
+  if (feature != NULL)
+    return feature->name;
+  else
+    return NULL;
+}
+
 /* Return the name of FEATURE.  */
 
 const char *
@@ -779,6 +800,42 @@ tdesc_find_register_early (const struct tdesc_feature 
*feature,
   return NULL;
 }
 
+/* Search FEATURE for a register named NAME and set its group to GROUP. */
+int
+tdesc_set_register_group_early (const struct tdesc_feature *feature,
+                               const char *name, const char *group)
+{
+  int ixr;
+  struct tdesc_reg *reg;
+
+  for (ixr = 0;
+       VEC_iterate (tdesc_reg_p, feature->registers, ixr, reg);
+       ixr++)
+    if (strcasecmp (reg->name, name) == 0) {
+       reg->group = strdup(group);
+       return 1;
+    }
+
+  return 0;
+}
+
+/* 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 named NAME.  Assign REGNO to it.  */
 
 int
@@ -892,6 +949,18 @@ tdesc_register_name (struct gdbarch *gdbarch, int regno)
   return "";
 }
 
+/* Search GDBARCH for a register REGNO and return its group. */
+const char *
+tdesc_register_group (struct gdbarch *gdbarch, int regno)
+{
+  struct tdesc_reg *reg = tdesc_find_register (gdbarch, regno);
+
+  if (reg != NULL)
+    return reg->group;
+  else
+    return "";
+}
+
 struct type *
 tdesc_register_type (struct gdbarch *gdbarch, int regno)
 {
diff --git a/gdb/target-descriptions.h b/gdb/target-descriptions.h
index caa7230..c4b87dd 100644
--- a/gdb/target-descriptions.h
+++ b/gdb/target-descriptions.h
@@ -187,6 +187,30 @@ struct type *tdesc_find_type (struct gdbarch *gdbarch, 
const char *id);
 int tdesc_register_in_reggroup_p (struct gdbarch *gdbarch, int regno,
                                  struct reggroup *reggroup);
 
+/* Search FEATURE for a register REGNO and return its name. */
+
+char *tdesc_find_register_name (const struct tdesc_feature *feature,
+                               int regno);
+
+/* Return the number of features available in the target descriptor. */
+
+int tdesc_nb_feature (const struct target_desc *target_desc);
+
+/* Return the name of feature given it's index. */
+
+const char *
+tdesc_feature_idx_name (const struct target_desc *target_desc, int index);
+
+/* Search FEATURE for a register named NAME and set its group to GROUP. */
+
+int tdesc_set_register_group_early (const struct tdesc_feature *feature,
+                                   const char *name, const char *group);
+
+/* Search GDBARCH for a register REGNO and return its group. */
+
+const char *
+tdesc_register_group (struct gdbarch *gdbarch, int regno);
+
 /* Methods for constructing a target description.  */
 
 struct target_desc *allocate_target_description (void);
-- 
1.7.1

_______________________________________________
OpenRISC mailing list
[email protected]
http://lists.openrisc.net/listinfo/openrisc

Reply via email to