This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Removal of uses of MAX_REGISTER_SIZE
- From: Alan Hayward <Alan dot Hayward at arm dot com>
- To: Pedro Alves <palves at redhat dot com>
- Cc: Yao Qi <qiyaoltc at gmail dot com>, Joel Brobecker <brobecker at adacore dot com>, "gdb-patches at sourceware dot org" <gdb-patches at sourceware dot org>, nd <nd at arm dot com>
- Date: Fri, 3 Feb 2017 11:25:43 +0000
- Subject: Re: [PATCH] Removal of uses of MAX_REGISTER_SIZE
- Authentication-results: sourceware.org; auth=none
- Authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alan dot Hayward at arm dot com;
- Nodisclaimer: True
- References: <7CF07197-4FED-4970-BB4B-2FE828E29A63@arm.com> <45e3a5e1-a9aa-1bc0-5d08-526b89fc458e@redhat.com> <20170201124123.GA27498@E107787-LIN> <dcfc96df-1917-8371-9069-4276dc3141fa@redhat.com> <20170202094012.dge4r6rsl2skdrii@adacore.com> <D06782D9-66E9-4194-86C4-275341686DB8@arm.com> <20170203102819.GA11916@E107787-LIN> <25716edf-096e-20c5-4170-fb8ca04d897b@redhat.com>
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
> On 3 Feb 2017, at 10:59, Pedro Alves <palves@redhat.com> wrote:
>
> On 02/03/2017 10:28 AM, Yao Qi wrote:
>
>> I don't think we have to replace all MAX_REGISTER_SIZE with std::vector.
>> MAX_REGISTER_SIZE is mostly used in arch-dependent code (*-tdep.c
>> and *-nat.c), where the register size or max register size is known. For
>> example, MAX_REGISTER_SIZE is used only once in arm-tdep.c, and
>> it can be replaced with FP_REGISTER_SIZE, because 'buf' is to get the
>> contents for FPA register. Similarly, MAX_REGISTER_SIZE is used three
>> times in aarch64-tdep.c, all of them can be repalced by V_REGISTER_SIZE.
>> Also, MAX_REGISTER_SIZE can be replaced by
>> I386_MAX_REGISTER_SIZE in i386-tdep.c. I would like to examine the
>> usages of MAX_REGISTER_SIZE in each target-dependent code, and
>> replace MAX_REGISTER_SIZE with known constants as much as we can.
>> I don't think anyone has objections on replacing one constant
>> MAX_REGISTER_SIZE with other smaller constants :)
>>
>> Then, let us discuss how to remove MAX_REGISTER_SIZE from
>> arch-independent code after all above is done.
>>
>
> +1.
>
> Thanks,
> Pedro Alves
>
If someone can ok the common patch, then I’ll make a second patch with the
replacement of all remaining uses of MAX_REGISTER_SIZE in common code.
Ensuring it’s not used in common code will allow me to continue moving with the
aarch64 SVE code.
There are quite a lot of arch specific functions where we have a register number
from which the register size could be extracted. Eg:
void
SOMEARCH_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
int regnum, const gdb_byte *buf)
{
gdb_byte raw_buf[MAX_REGISTER_SIZE];
This could become:
void
SOMEARCH_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
int regnum, const gdb_byte *buf)
{
gdb_byte buf[SOMEARCH_MAX_REGISTER_SIZE];
Or:
void
SOMEARCH_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
int regnum, const gdb_byte *buf)
{
std::vector<gdb_byte> buf (register_size (gdbarch, regnum));
I suspect people will want the first approach? It will result in quite a few new
defines - ALPHA_MAX_REGISTER_SIZE, PPC_MAX_REGISTER_SIZE etc etc.
Alan.