From: Alan Hayward <Alan.Hayward@arm.com>
To: Andreas Schwab <schwab@suse.de>
Cc: Yao Qi <qiyaoltc@gmail.com>,
"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>,
nd <nd@arm.com>
Subject: Re: [PATCH 7/11] Add BFIN_MAX_REGISTER_SIZE
Date: Wed, 05 Apr 2017 13:57:00 -0000 [thread overview]
Message-ID: <FE02138A-E6BE-4EEF-B2A7-9CFD8F4EDB16@arm.com> (raw)
In-Reply-To: <mvm60ijezf9.fsf@suse.de>
> On 5 Apr 2017, at 14:50, Andreas Schwab <schwab@suse.de> wrote:
>
> On Apr 05 2017, Alan Hayward <Alan.Hayward@arm.com> wrote:
>
>>> On 5 Apr 2017, at 11:28, Yao Qi <qiyaoltc@gmail.com> wrote:
>>>
>>> Alan Hayward <Alan.Hayward@arm.com> writes:
>>>
>>>> diff --git a/gdb/bfin-tdep.c b/gdb/bfin-tdep.c
>>>> index 3df1ba387a323dc6827b1189432f8877d1833184..9b45633cab15b8e0adb0d51a2fa650dc2bc6339b 100644
>>>> --- a/gdb/bfin-tdep.c
>>>> +++ b/gdb/bfin-tdep.c
>>>> @@ -689,7 +689,7 @@ static enum register_status
>>>> bfin_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
>>>> int regnum, gdb_byte *buffer)
>>>> {
>>>> - gdb_byte *buf = (gdb_byte *) alloca (MAX_REGISTER_SIZE);
>>>> + gdb_byte *buf = (gdb_byte *) alloca (BFIN_MAX_REGISTER_SIZE);
>>>
>>> Why don't you do "gdb_byte buf[4];"? It is only for CC register which
>>> is 32-bit.
>>>
>>
>> Is it not clearer code to add and use a macro rather than a magic number ?
>>
>> It’s also not obvious anywhere that the astat register is 32bits. I had to go
>> digging inside regformats/reg-bfin.dat before I found it out.
>>
>> Given that BFIN_MAX_REGISTER_SIZE is also 4, it compiles to the same size anyway.
>
> Since BFIN_MAX_REGISTER_SIZE is a constant you don't need alloca either
> way.
>
Sorry, yes, I meant to say:
Why not use:
gdb_byte buf[BFIN_MAX_REGISTER_SIZE];
Rather than
gdb_byte buf[4];
Given that a macro is clearer than a magic number.
Alan.
next prev parent reply other threads:[~2017-04-05 13:57 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-04 10:14 Alan Hayward
[not found] ` <86tw63p2rx.fsf@gmail.com>
[not found] ` <EDE97F7B-EFCE-4B4D-B996-C458F1DC7E56@arm.com>
2017-04-05 13:50 ` Andreas Schwab
2017-04-05 13:57 ` Alan Hayward [this message]
[not found] ` <86d1croshn.fsf@gmail.com>
2017-04-07 8:32 ` Alan Hayward
[not found] ` <3239de71-1e7c-22dd-172d-56a3baad292b@redhat.com>
2017-04-05 15:51 ` Alan Hayward
2017-04-07 16:04 ` Yao Qi
2017-04-07 16:22 ` Alan Hayward
2017-04-14 17:26 ` Mike Frysinger
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=FE02138A-E6BE-4EEF-B2A7-9CFD8F4EDB16@arm.com \
--to=alan.hayward@arm.com \
--cc=gdb-patches@sourceware.org \
--cc=nd@arm.com \
--cc=qiyaoltc@gmail.com \
--cc=schwab@suse.de \
/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