This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 2/6] Add constructor and destructor to regcache
- From: Pedro Alves <palves at redhat dot com>
- To: Yao Qi <qiyaoltc at gmail dot com>, gdb-patches at sourceware dot org
- Date: Thu, 27 Apr 2017 18:34:03 +0100
- Subject: Re: [PATCH 2/6] Add constructor and destructor to regcache
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=palves at redhat dot com
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 2C83C80E7E
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2C83C80E7E
- References: <1493152106-3246-1-git-send-email-yao.qi@linaro.org> <1493152106-3246-3-git-send-email-yao.qi@linaro.org>
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