From: Yao Qi <qiyaoltc@gmail.com>
To: Pedro Alves <palves@redhat.com>
Cc: Alan Hayward <Alan.Hayward@arm.com>,
"gdb-patches\@sourceware.org" <gdb-patches@sourceware.org>,
nd <nd@arm.com>
Subject: Re: [PATCH 3/11] Add MIPS_MAX_REGISTER_SIZE (2/4)
Date: Thu, 25 May 2017 11:43:00 -0000 [thread overview]
Message-ID: <86wp95p3ev.fsf@gmail.com> (raw)
In-Reply-To: <73b5b4f8-065b-7102-a9d8-0b909b1eb124@redhat.com> (Pedro Alves's message of "Thu, 25 May 2017 11:46:24 +0100")
Pedro Alves <palves@redhat.com> writes:
> Those manual tests would have been perfect candidates for some
> unit tests. All you'd need to do is add this at the bottom
> of gdb/findvar.c:
>
> #if GDB_SELF_TEST
> namespace selftests {
> namespace findvar_tests {
>
> static void
> run_test ()
> {
> // Here, exercise the various code paths of copy_integer_to_size,
> // calling SELF_CHECK.
> }
>
> } // namespace findvar_test
> } // namespace selftests
>
> #endif
>
> void
> _initialize_findvar (void)
> {
> #if GDB_SELF_TEST
> register_self_test (selftests::findvar_tests::run_test);
> #endif
> }
>
>
It is great to have a unit test, and that is what I want to suggest.
>> +/* Supply a single register. The register size might not match, so use
>> + regcache->raw_supply_integer (). */
>>
>> static void
>> mips_fbsd_supply_reg (struct regcache *regcache, int regnum, const void *addr,
>> size_t len)
>> {
>> - struct gdbarch *gdbarch = get_regcache_arch (regcache);
>> -
>> - if (register_size (gdbarch, regnum) == len)
>> - regcache_raw_supply (regcache, regnum, addr);
>> - else
>> - {
>> - enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
>> - gdb_byte buf[MAX_REGISTER_SIZE];
>> - LONGEST val;
>> -
>> - val = extract_signed_integer ((const gdb_byte *) addr, len, byte_order);
>> - store_signed_integer (buf, register_size (gdbarch, regnum), byte_order,
>> - val);
>> - regcache_raw_supply (regcache, regnum, buf);
>> - }
>> + regcache->raw_supply_integer (regnum, (const gdb_byte *) addr, len, true);
>> }
>
> Nice!
>
Can we completely remove mips_fbsd_supply_reg? and use
regcache->raw_supply_integer instead?
>> --- a/gdb/mips-linux-tdep.c
>> +++ b/gdb/mips-linux-tdep.c
>> @@ -116,13 +116,7 @@ mips_linux_get_longjmp_target (struct
>> frame_info *frame, CORE_ADDR *pc)
>> static void
>> supply_32bit_reg (struct regcache *regcache, int regnum, const void *addr)
>> {
>> - struct gdbarch *gdbarch = get_regcache_arch (regcache);
>> - enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
>> - gdb_byte buf[MAX_REGISTER_SIZE];
>> - store_signed_integer (buf, register_size (gdbarch, regnum), byte_order,
>> - extract_signed_integer ((const gdb_byte *) addr, 4,
>> - byte_order));
>> - regcache_raw_supply (regcache, regnum, buf);
>> + regcache->raw_supply_integer (regnum, (const gdb_byte *) addr, 4, true);
>> }
>
> Nice. :-)
> [snip several "nice"s]
>
Likewise, remove supply_32bit_reg and use regcache->raw_supply_integer.
--
Yao (齐尧)
next prev parent reply other threads:[~2017-05-25 11:43 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-04 10:12 [PATCH 3/11] Add MIPS_MAX_REGISTER_SIZE Alan Hayward
2017-04-04 17:19 ` John Baldwin
2017-04-05 10:27 ` Alan Hayward
2017-04-11 15:37 ` Yao Qi
2017-05-05 8:03 ` [PATCH 3/11] Add MIPS_MAX_REGISTER_SIZE (1/4) Alan Hayward
2017-05-05 21:44 ` Yao Qi
2017-05-05 8:04 ` [PATCH 3/11] Add MIPS_MAX_REGISTER_SIZE (4/4) Alan Hayward
[not found] ` <434A7317-C19A-4B53-8CB1-C7B4ACEC7D17@arm.com>
2017-06-08 20:27 ` Maciej W. Rozycki
2017-06-09 10:31 ` Alan Hayward
[not found] ` <ebebb23e-e61b-5eff-b666-f2632e554322@redhat.com>
2017-06-09 11:48 ` Maciej W. Rozycki
2017-06-09 12:05 ` Pedro Alves
2017-06-09 13:23 ` Maciej W. Rozycki
2017-06-09 14:29 ` Pedro Alves
2017-06-12 9:09 ` Alan Hayward
2017-06-12 18:11 ` Pedro Alves
2017-06-12 14:29 ` Maciej W. Rozycki
2017-05-05 8:04 ` [PATCH 3/11] Add MIPS_MAX_REGISTER_SIZE (2/4) Alan Hayward
2017-05-05 19:51 ` John Baldwin
2017-05-12 8:53 ` Yao Qi
2017-05-16 11:16 ` Alan Hayward
2017-05-22 12:07 ` Yao Qi
2017-05-22 16:05 ` Alan Hayward
2017-05-22 17:15 ` Pedro Alves
2017-05-23 17:49 ` Alan Hayward
2017-05-23 18:30 ` Pedro Alves
2017-05-24 9:08 ` Alan Hayward
2017-05-24 9:29 ` Pedro Alves
[not found] ` <40597975-9458-e9af-8915-9d303bb1ed98@redhat.com>
2017-05-24 10:20 ` Alan Hayward
[not found] ` <d32041ef-9df3-316a-68ca-3fe2a2797539@redhat.com>
2017-05-24 19:45 ` Alan Hayward
2017-05-25 10:46 ` Pedro Alves
2017-05-25 11:43 ` Yao Qi [this message]
2017-05-25 11:48 ` Pedro Alves
2017-05-26 8:54 ` Alan Hayward
2017-05-26 10:26 ` Pedro Alves
2017-05-26 15:30 ` Alan Hayward
2017-05-26 15:49 ` Pedro Alves
2017-05-26 16:18 ` Alan Hayward
2017-05-26 16:00 ` John Baldwin
2017-05-05 8:04 ` [PATCH 3/11] Add MIPS_MAX_REGISTER_SIZE (3/4) Alan Hayward
2017-05-05 21:54 ` 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=86wp95p3ev.fsf@gmail.com \
--to=qiyaoltc@gmail.com \
--cc=Alan.Hayward@arm.com \
--cc=gdb-patches@sourceware.org \
--cc=nd@arm.com \
--cc=palves@redhat.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