[PATCH] Use std::vector on tdesc->reg_defs (gdbserver/tdesc.h)

Simon Marchi simon.marchi@polymtl.ca
Sun Sep 10 18:43:00 GMT 2017


On 2017-09-10 19:12, Sergio Durigan Junior wrote:
> This is a followup patch to the build breakage fix on AArch64.  While
> doing the fix, I found it better to convert tdesc->reg_defs (on
> gdbserver/tdesc.h) from using VEC to using std::vector.  This makes
> the code easier to read and maintain, and also is one more step
> towards the C++fication.
> 
> Regtested on BuildBot.

Hi Sergio,

Thanks for the patch.  It looks good to me, but Yao might want to look 
at it since it changes an area he knows well.  So leave the patch up for 
a few days just in case, if you haven't heard anything new in a week, 
you can push.

I just noted a nit below.

> diff --git a/gdb/gdbserver/tdesc.h b/gdb/gdbserver/tdesc.h
> index 71249e4eda..ec4d6b38dc 100644
> --- a/gdb/gdbserver/tdesc.h
> +++ b/gdb/gdbserver/tdesc.h
> @@ -22,9 +22,7 @@
>  #include "arch/tdesc.h"
> 
>  #include "regdef.h"
> -
> -typedef struct reg *tdesc_reg_p;
> -DEF_VEC_P(tdesc_reg_p);
> +#include <vector>
> 
>  struct tdesc_feature
>  {};
> @@ -36,7 +34,7 @@ struct target_desc : tdesc_feature
>  {
>    /* A vector of elements of register definitions that
>       describe the inferior's register set.  */
> -  VEC(tdesc_reg_p) *reg_defs;
> +  std::vector<struct reg *> reg_defs;
> 
>    /* The register cache size, in bytes.  */
>    int registers_size;
> @@ -66,17 +64,16 @@ struct target_desc : tdesc_feature
> 
>  public:
>    target_desc ()
> -    : reg_defs (NULL), registers_size (0)
> +    : registers_size (0)
>    {}
> 
>    ~target_desc ()
>    {
>      int i;
> -    struct reg *reg;
> 
> -    for (i = 0; VEC_iterate (tdesc_reg_p, reg_defs, i, reg); i++)
> +    for (reg *reg : reg_defs)
>        xfree (reg);
> -    VEC_free (tdesc_reg_p, reg_defs);
> +    reg_defs.clear ();

The clear is unnecessary.

Thanks,

Simon



More information about the Gdb-patches mailing list