public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Alan Hayward <Alan.Hayward@arm.com>
To: Yao Qi <qiyaoltc@gmail.com>
Cc: Pedro Alves <palves@redhat.com>,
	Joel Brobecker <brobecker@adacore.com>,
	"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>,
	nd <nd@arm.com>
Subject: Re: [PATCH] Removal of uses of MAX_REGISTER_SIZE
Date: Mon, 13 Feb 2017 11:59:00 -0000	[thread overview]
Message-ID: <D187F6CE-9768-4559-9773-154D5F25E031@arm.com> (raw)
In-Reply-To: <861sv8pote.fsf@gmail.com>


> On 8 Feb 2017, at 17:36, Yao Qi <qiyaoltc@gmail.com> wrote:
> 
> Alan Hayward <Alan.Hayward@arm.com> writes:
> 
>> @@ -1279,7 +1335,7 @@ regcache_dump (struct regcache *regcache, struct ui_file *file,
>>   int footnote_register_offset = 0;
>>   int footnote_register_type_name_null = 0;
>>   long register_offset = 0;
>> -  gdb_byte buf[MAX_REGISTER_SIZE];
>> +  std::vector<gdb_byte> buf (max_register_size (gdbarch));
>> 
>> #if 0
>>   fprintf_unfiltered (file, "nr_raw_registers %d\n",
>> @@ -1406,8 +1462,8 @@ regcache_dump (struct regcache *regcache, struct ui_file *file,
>> 	    fprintf_unfiltered (file, "<unavailable>");
>> 	  else
>> 	    {
>> -	      regcache_raw_read (regcache, regnum, buf);
>> -	      print_hex_chars (file, buf,
>> +	      regcache_raw_update (regcache, regnum);
>> +	      print_hex_chars (file, register_buffer (regcache, regnum),
>> 			       regcache->descr->sizeof_register[regnum],
>> 			       gdbarch_byte_order (gdbarch));
>> 	    }
>> @@ -1422,13 +1478,13 @@ regcache_dump (struct regcache *regcache, struct ui_file *file,
>> 	    {
>> 	      enum register_status status;
>> 
>> -	      status = regcache_cooked_read (regcache, regnum, buf);
>> +	      status = regcache_cooked_read (regcache, regnum, buf.data ());
> 
> Can we use regcache_cooked_read_value so that we don't need buf at all.

Yes, that would work.
However, this cooked read is in the middle of a for() loop of every register value.

With the patch currently, we have the allocation of buf once, and then re-use it for each
iteration.

Switching to regcache_cooked_read_value() would result in a call to allocate_value()
(within the regcache_cooked_read_value code) every iteration, which would then be freed
after printing it.


> 
>> 	      if (status == REG_UNKNOWN)
>> 		fprintf_unfiltered (file, "<invalid>");
>> 	      else if (status == REG_UNAVAILABLE)
>> 		fprintf_unfiltered (file, "<unavailable>");
>> 	      else
>> -		print_hex_chars (file, buf,
>> +		print_hex_chars (file, buf.data (),
>> 				 regcache->descr->sizeof_register[regnum],
>> 				 gdbarch_byte_order (gdbarch));
>> 	    }
> 
> -- 
> Yao (齐尧)


      reply	other threads:[~2017-02-13 11:59 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-24 10:31 Alan Hayward
2017-01-27 11:49 ` Pedro Alves
2017-01-27 12:11 ` Pedro Alves
2017-01-27 16:46   ` Alan Hayward
2017-02-01 15:49     ` Pedro Alves
2017-02-01 12:45   ` Yao Qi
2017-02-01 15:48     ` Pedro Alves
2017-02-02  9:40       ` Joel Brobecker
2017-02-03  9:59         ` Alan Hayward
2017-02-03 10:28           ` Yao Qi
2017-02-03 11:00             ` Pedro Alves
2017-02-03 11:25               ` Alan Hayward
2017-02-03 16:50                 ` Yao Qi
2017-02-06  9:33                   ` Alan Hayward
     [not found]                     ` <20170206152635.GE11916@E107787-LIN>
2017-02-07 16:33                       ` Alan Hayward
2017-02-08 10:47                         ` Yao Qi
2017-02-08 14:17                           ` Alan Hayward
2017-02-08 12:06                         ` Yao Qi
2017-02-08 12:24                         ` Yao Qi
2017-02-08 14:44                           ` Alan Hayward
2017-02-18 23:19                             ` Yao Qi
2017-02-20 11:19                               ` Alan Hayward
2017-02-08 15:32                         ` Yao Qi
2017-02-08 17:10                         ` Yao Qi
2017-02-09 13:26                           ` Alan Hayward
2017-02-14 11:24                           ` Alan Hayward
2017-02-08 17:36                         ` Yao Qi
2017-02-13 11:59                           ` Alan Hayward [this message]

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=D187F6CE-9768-4559-9773-154D5F25E031@arm.com \
    --to=alan.hayward@arm.com \
    --cc=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=nd@arm.com \
    --cc=palves@redhat.com \
    --cc=qiyaoltc@gmail.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).