This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Use std::vector on tdesc->reg_defs (gdbserver/tdesc.h)
- From: Sergio Durigan Junior <sergiodj at redhat dot com>
- To: Simon Marchi <simon dot marchi at polymtl dot ca>
- Cc: GDB Patches <gdb-patches at sourceware dot org>, Yao Qi <yao dot qi at linaro dot org>
- Date: Sun, 10 Sep 2017 17:35:10 -0400
- Subject: Re: [PATCH] Use std::vector on tdesc->reg_defs (gdbserver/tdesc.h)
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=sergiodj at redhat dot com
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1D23436DAC4
- References: <20170910171249.28470-1-sergiodj@redhat.com> <e28227bbecf218daaeb28d82d7409574@polymtl.ca>
On Sunday, September 10 2017, Simon Marchi wrote:
> 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.
Thanks for the review.
> 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.
You're right, removed.
Thanks,
--
Sergio
GPG key ID: 237A 54B1 0287 28BF 00EF 31F4 D0EB 7628 65FC 5E36
Please send encrypted e-mail if possible
http://sergiodj.net/