On Sat, 2012-12-22 at 01:00 +0100, Franck Jullien wrote: 
> 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.

This is good - the above description should go in ChangeLog.or32 for
target-descriptions.c and target-descriptions.h.

However, I'm not sure these functions are all needed generically, in
which case they belong in or32-tdep.c. target-descriptions.h already has
a wide range of functions, and if you extend this, you need to explain
why they must be generic and not specific to a particular architecture.

I think it is because you are introducing the concept of register
groups, which as far as I know is an OR1K specific concept. I'm not yet
really clear how your use of groups relates to the general concept of
features - could you explain a bit more about this.

Best wishes,


Jeremy

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

-- 
Tel:      +44 (1590) 610184
Cell:     +44 (7970) 676050
SkypeID: jeremybennett
Email:   [email protected]
Web:     www.embecosm.com

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

Reply via email to