From: Alan Hayward <Alan.Hayward@arm.com>
To: Yao Qi <qiyaoltc@gmail.com>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>,
nd <nd@arm.com>
Subject: Re: [PATCH] Remove MAX_REGISTER_SIZE from regcache.c
Date: Wed, 05 Apr 2017 18:10:00 -0000 [thread overview]
Message-ID: <F89B7D56-912C-4AF5-9770-F6EFF6DC25F4@arm.com> (raw)
In-Reply-To: <868tneq1xj.fsf@gmail.com>
> On 5 Apr 2017, at 17:00, Yao Qi <qiyaoltc@gmail.com> wrote:
<snip Msp430 and nds32 changes>
Moved these out to a different patch
>> @@ -379,7 +388,7 @@ regcache_restore (struct regcache *dst,
>> void *cooked_read_context)
>> {
>> struct gdbarch *gdbarch = dst->descr->gdbarch;
>> - gdb_byte buf[MAX_REGISTER_SIZE];
>> + std::vector<gdb_byte> buf (max_register_size (gdbarch));
>> int regnum;
>>
>> /* The dst had better not be read-only. If it is, the `restore'
>> @@ -395,9 +404,9 @@ regcache_restore (struct regcache *dst,
>> {
>> enum register_status status;
>
> Can we move "buf" here? and initialize it with the register_size,
>
> std::vector<gdb_byte> buf (register_size (gdbarch, regnum));
>
> then, we don't need max_register_size ().
>
Problem with this is that we are then creating a brand new buffer for each
iteration of the loop, which is a little heavyweight.
We could create an empty buf outside the loop and re-size it each iteration,
but that's still going to cost.
We'll still need to keep max_register_size () if we want to add checks
that the FOO_MAX_REGISTER size defines are big enough.
(see the BFIN_MAX_REGISTER_SIZE email thread)
>> @@ -1480,17 +1488,19 @@ regcache_dump (struct regcache *regcache, struct ui_file *file,
>> fprintf_unfiltered (file, "Cooked value");
>> else
>> {
>> - enum register_status status;
>> + struct value *value = regcache_cooked_read_value (regcache,
>> + regnum);
>>
>> - status = regcache_cooked_read (regcache, regnum, buf);
>> - if (status == REG_UNKNOWN)
>> - fprintf_unfiltered (file, "<invalid>");
>> - else if (status == REG_UNAVAILABLE)
>> + if (value_optimized_out (value)
>> + || !value_entirely_available (value))
>> fprintf_unfiltered (file, "<unavailable>");
>
> It is still not right to me. With your changes to msp430 and nds32, we
> won't get REG_UNKNOWN for pseudo registers, but we may still get
> REG_UNKNOWN from raw registers (from regcache->register_status[]). How
> is this?
>
> gdb_byte *buf = NULL;
> enum register_status status;
> struct value * value = NULL;
>
> if (regnum < regcache->descr->nr_raw_registers)
> {
> regcache_raw_update (regcache, regnum);
>
> status = regcache->register_status[regnum];
> buf = register_buffer (regcache, regnum);
> }
> else
> {
> value = regcache_cooked_read_value (regcache, regnum);
>
> if (value_entirely_available (value))
> {
> status = REG_VALID;
> buf = value_contents_all (value);
> }
> else
> status = REG_REG_UNAVAILABLE;
> }
>
> if (status == REG_UNKNOWN)
> fprintf_unfiltered (file, "<invalid>");
> else if (status == REG_UNAVAILABLE)
> fprintf_unfiltered (file, "<unavailable>");
> else
> print_hex_chars (file, buf,
> regcache->descr->sizeof_register[regnum],
> gdbarch_byte_order (gdbarch));
>
> if (value != NULL)
> {
> release_value (value);
> value_free (value);
> }
>
Yes, I’ll add those changes.
next prev parent reply other threads:[~2017-04-05 18:10 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-24 10:19 Alan Hayward
2017-03-23 14:45 ` Alan Hayward
2017-03-24 8:49 ` Yao Qi
2017-03-24 10:28 ` Alan Hayward
2017-04-05 14:53 ` Alan Hayward
2017-04-05 16:01 ` Yao Qi
2017-04-05 18:10 ` Alan Hayward [this message]
2017-04-10 8:59 ` Yao Qi
2017-04-10 10:53 ` Alan Hayward
2017-04-21 14:01 ` Yao Qi
2017-04-26 14:03 ` Alan Hayward
2017-04-27 9:43 ` Yao Qi
2017-04-27 9:52 ` Alan Hayward
2017-05-03 8:21 ` Yao Qi
2017-05-03 10:42 ` Alan Hayward
2017-06-07 8:49 ` Alan Hayward
2017-06-07 9:12 ` Yao Qi
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=F89B7D56-912C-4AF5-9770-F6EFF6DC25F4@arm.com \
--to=alan.hayward@arm.com \
--cc=gdb-patches@sourceware.org \
--cc=nd@arm.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).