This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 8/11] Add FRV_MAX_REGISTER_SIZE
- From: Yao Qi <qiyaoltc at gmail dot com>
- To: Alan Hayward <Alan dot Hayward at arm dot com>
- Cc: "gdb-patches\@sourceware.org" <gdb-patches at sourceware dot org>,
- Date: Tue, 11 Apr 2017 11:02:48 +0100
- Subject: Re: [PATCH 8/11] Add FRV_MAX_REGISTER_SIZE
- Authentication-results: sourceware.org; auth=none
- References: <3B3BD949-1C9D-44FF-AB6A-03091ECA49D0@arm.com>
Alan Hayward <Alan.Hayward@arm.com> writes:
> - char zerobuf[MAX_REGISTER_SIZE];
> + char zerobuf[FRV_MAX_REGISTER_SIZE];
>
> - memset (zerobuf, 0, MAX_REGISTER_SIZE);
> + memset (zerobuf, 0, FRV_MAX_REGISTER_SIZE);
>
> /* gr0 always contains 0. Also, the kernel passes the TBR value in
> this slot. */
The code here fills some gr registers with zeros,
/* gr0 always contains 0. Also, the kernel passes the TBR value in
this slot. */
regcache_raw_supply (regcache, first_gpr_regnum, zerobuf);
/* Fill gr32, ..., gr63 with zeros. */
for (regi = first_gpr_regnum + 32; regi <= last_gpr_regnum; regi++)
regcache_raw_supply (regcache, regi, zerobuf);
the size of these gr registers are know, 8 bytes. It won't be changed.
We can do,
gdb_byte zerobuf[8] = { 0 };
the code is still easy to read. If you really dislike magic number (IMO, 8
is not a magic number in this context), you can define FRR_GR_REGISTER_SIZE.
Alternatively, you can add a new regache api, regcache_raw_supply_zero.
Many places can use this api, and some uses of MAX_REGISTER_SIZE can be
removed too, for example,
regcache_raw_supply (regcache, MIPS_ZERO_REGNUM, zerobuf);
--
Yao (齐尧)