public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Yao Qi <yao@codesourcery.com>,
	       Victor Kamensky <victor.kamensky@linaro.org>
Cc: gdb-patches@sourceware.org, Andrew Pinski <pinskia@gmail.com>
Subject: Re: [RFC PATCH 2/2] fix py-value-cc.exp test for big endian target
Date: Wed, 29 Oct 2014 09:13:00 -0000	[thread overview]
Message-ID: <5450AFAE.6080701@redhat.com> (raw)
In-Reply-To: <87oasvtmax.fsf@codesourcery.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

      reply	other threads:[~2014-10-29  9:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-27  3:16 [RFC PATCH 0/2] couple big endian fixes in testsuites Victor Kamensky
2014-10-27  3:16 ` [RFC PATCH 1/2] fix implptrpiece.exp test for big endian target Victor Kamensky
2014-10-29  8:15   ` Yao Qi
2014-10-27  3:16 ` [RFC PATCH 2/2] fix py-value-cc.exp " Victor Kamensky
2014-10-29  6:40   ` Yao Qi
2014-10-29  9:13     ` Pedro Alves [this message]

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=5450AFAE.6080701@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=pinskia@gmail.com \
    --cc=victor.kamensky@linaro.org \
    --cc=yao@codesourcery.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).