This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 2/6] Add constructor and destructor to regcache


A few minor nits below, but looks good to me otherwise.

On 04/25/2017 09:28 PM, Yao Qi wrote:

> diff --git a/gdb/regcache.c b/gdb/regcache.c
> index 966f0c7..e0554c7 100644
> --- a/gdb/regcache.c
> +++ b/gdb/regcache.c
> @@ -191,6 +191,17 @@ regcache_register_size (const struct regcache *regcache, int n)
>  
>  struct regcache
>  {
> +public:
> +  explicit regcache (struct gdbarch *gdbarch, struct address_space *aspace_)
> +    : regcache (gdbarch, aspace_, true)

There's no real good reason to use "explicit" when you have more than
one parameter.

> +  {}
> +
> +  ~regcache ()
> +  {
> +    xfree (registers);
> +    xfree (register_status);
> +  }
> +
>    struct regcache_descr *descr;
>  
>    /* The address space of this register cache (for registers where it
> @@ -213,6 +224,33 @@ struct regcache
>    /* If this is a read-write cache, which thread's registers is
>       it connected to?  */
>    ptid_t ptid;
> +
> +private:
> +  explicit regcache (struct gdbarch *gdbarch, struct address_space *aspace_,
> +		     bool readonly_p_)

Ditto.

> +    : aspace (aspace_), readonly_p (readonly_p_)
> +  {
> +    gdb_assert (gdbarch != NULL);
> +    descr = regcache_descr (gdbarch);
> +
> +  if (readonly_p)
> +    {
> +      registers = XCNEWVEC (gdb_byte, descr->sizeof_cooked_registers);
> +      register_status = XCNEWVEC (signed char,
> +				  descr->sizeof_cooked_register_status);
> +    }
> +  else
> +    {
> +      registers = XCNEWVEC (gdb_byte, descr->sizeof_raw_registers);
> +      register_status = XCNEWVEC (signed char,
> +				  descr->sizeof_raw_register_status);
> +    }
> +  ptid = minus_one_ptid;
> +  }
> +
> +  friend struct regcache *
> +  get_thread_arch_aspace_regcache (ptid_t ptid, struct gdbarch *gdbarch,
> +				   struct address_space *aspace);
>  };

(I'd drop the "struct" in the aspace parameters.)

Thanks,
Pedro Alves


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]