This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFC PATCH 2/2] fix py-value-cc.exp test for big endian target
- From: Pedro Alves <palves at redhat dot com>
- To: Yao Qi <yao at codesourcery dot com>, Victor Kamensky <victor dot kamensky at linaro dot org>
- Cc: gdb-patches at sourceware dot org, Andrew Pinski <pinskia at gmail dot com>
- Date: Wed, 29 Oct 2014 09:13:18 +0000
- Subject: Re: [RFC PATCH 2/2] fix py-value-cc.exp test for big endian target
- Authentication-results: sourceware.org; auth=none
- References: <1414379778-5478-1-git-send-email-victor dot kamensky at linaro dot org> <1414379778-5478-3-git-send-email-victor dot kamensky at linaro dot org> <87oasvtmax dot fsf at codesourcery dot com>
On 10/29/2014 06:36 AM, Yao Qi wrote:
> Victor Kamensky <victor.kamensky@linaro.org> writes:
>
>> The reason is that test case is not endian agnostic.
>> Test program variable 'u' has type of 'union U { int a;
>> char c; };'. Test program writes 99 into u.a and expects to see
>> it in field 'u.c'. But it would only work on little endian
>> system where 'c' field of U union conicide with least
>> significant byte of 'a' field.
...
>> U u;
>> - u.a = 99;
>> + u.a = 0x55000055; /* c is the same for big and little endian */
>
> I'd like c is shown differently on big endian and little endian, and
> check c's value in different endianness. It can be something like,
>
> u.a = 0x55000056 or u.a = 0x55565758
I noticed that the proposed changes assume all supported architectures
have sizeof (int) == 4, but that's not valid assumption. E.g.,:
(gdb) set architecture m68hc11
The target architecture is assumed to be m68hc11
(gdb) p sizeof (int)
$1 = 2
(gdb) set architecture h8300
The target architecture is assumed to be h8300
(gdb) p sizeof (int)
$2 = 2
(gdb) set architecture m32c
The target architecture is assumed to be m32c
(gdb) p sizeof (int)
$3 = 2
(gdb) set architecture avr
The target architecture is assumed to be avr
(gdb) p sizeof (int)
$4 = 2
etc.
Maybe the simplest is to make the unions use uint32_t instead
of int.
Thanks,
Pedro Alves