This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Remove an instance of MAX_REGISTER_SIZE from record-full.c
- From: Pedro Alves <palves at redhat dot com>
- To: Alan Hayward <Alan dot Hayward at arm dot com>, Yao Qi <qiyaoltc at gmail dot com>
- Cc: "gdb-patches at sourceware dot org" <gdb-patches at sourceware dot org>, nd <nd at arm dot com>
- Date: Wed, 21 Jun 2017 11:52:45 +0100
- Subject: Re: [PATCH] Remove an instance of MAX_REGISTER_SIZE from record-full.c
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx03.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 7A75380F99
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7A75380F99
- References: <69EEE46A-D88C-4B4F-86A2-E35F6DAFD90A@arm.com> <86d1a9a2k9.fsf@gmail.com> <C7AECD2C-570A-4934-A153-FFA8B66E8185@arm.com>
On 06/12/2017 02:59 PM, Alan Hayward wrote:
> diff --git a/gdb/record-full.c b/gdb/record-full.c
> index 31ff558d2a633cff71d3e6082e42f5d6fb88bcf1..4f73e2a5ad0d4a2407b31a1d391e813147e15798 100644
> --- a/gdb/record-full.c
> +++ b/gdb/record-full.c
> @@ -698,7 +698,7 @@ record_full_exec_insn (struct regcache *regcache,
> {
> case record_full_reg: /* reg */
> {
> - gdb_byte reg[MAX_REGISTER_SIZE];
> + gdb_byte *reg = (gdb_byte *) xmalloc (entry->u.reg.len);
>
> if (record_debug > 1)
> fprintf_unfiltered (gdb_stdlog,
> @@ -711,6 +711,7 @@ record_full_exec_insn (struct regcache *regcache,
> regcache_cooked_write (regcache, entry->u.reg.num,
> record_full_get_loc (entry));
> memcpy (record_full_get_loc (entry), reg, entry->u.reg.len);
> + xfree (reg);
You can use
gdb::byte_vector reg (entry->u.reg.len);
to avoid the explicit xfree here.
(and a potential leak if regcache_* throws).
Thanks,
Pedro Alves