Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Yao Qi <qiyaoltc@gmail.com>
To: Alan Hayward <Alan.Hayward@arm.com>
Cc: "gdb-patches\@sourceware.org" <gdb-patches@sourceware.org>,
	 nd <nd@arm.com>
Subject: Re: [PATCH] Remove an instance of MAX_REGISTER_SIZE from record-full.c
Date: Mon, 12 Jun 2017 11:05:00 -0000	[thread overview]
Message-ID: <86d1a9a2k9.fsf@gmail.com> (raw)
In-Reply-To: <69EEE46A-D88C-4B4F-86A2-E35F6DAFD90A@arm.com> (Alan Hayward's	message of "Mon, 12 Jun 2017 09:34:30 +0000")

Alan Hayward <Alan.Hayward@arm.com> writes:

> -        regcache_cooked_read (regcache, entry->u.reg.num, reg);
> -        regcache_cooked_write (regcache, entry->u.reg.num,
> -			       record_full_get_loc (entry));
> -        memcpy (record_full_get_loc (entry), reg, entry->u.reg.len);

The original code is about swapping contents of register REG in regcache
and record_full_get_loc (entry), and the length is known entry->u.reg.len.

> +	value = regcache->cooked_read_value (entry->u.reg.num);
> +	gdb_assert (value != NULL);
> +	regcache->cooked_write (entry->u.reg.num, record_full_get_loc (entry));
> +	memcpy (record_full_get_loc (entry), value_contents_all (value),
> +		entry->u.reg.len);
> +	release_value (value);
> +	value_free (value);

It is a overkill to use value to swap these two buffers, IMO.  How about
xmalloc "reg" instead?

-- 
Yao (齐尧)


  reply	other threads:[~2017-06-12 11:05 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-12  9:34 Alan Hayward
2017-06-12 11:05 ` Yao Qi [this message]
2017-06-12 13:59   ` Alan Hayward
2017-06-21  9:31     ` Alan Hayward
2017-06-21 10:33     ` Yao Qi
2017-06-21 10:52     ` Pedro Alves
2017-06-22 13:44       ` Alan Hayward
2017-06-22 13:45         ` Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86d1a9a2k9.fsf@gmail.com \
    --to=qiyaoltc@gmail.com \
    --cc=Alan.Hayward@arm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=nd@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox