From: Sergio Durigan Junior <sergiodj@redhat.com>
To: Pedro Alves <palves@redhat.com>
Cc: GDB Patches <gdb-patches@sourceware.org>,
Tom Tromey <tom@tromey.com>, Eli Zaretskii <eliz@gnu.org>,
Simon Marchi <simon.marchi@ericsson.com>,
Keith Seitz <keiths@redhat.com>
Subject: Re: [PATCH v5 2/2] Implement pahole-like 'ptype /o' option
Date: Wed, 13 Dec 2017 21:34:00 -0000 [thread overview]
Message-ID: <87fu8eia6b.fsf@redhat.com> (raw)
In-Reply-To: <e61c3781-e22c-4667-afed-7cad73cc9182@redhat.com> (Pedro Alves's message of "Wed, 13 Dec 2017 21:22:14 +0000")
On Wednesday, December 13 2017, Pedro Alves wrote:
> On 12/13/2017 08:36 PM, Sergio Durigan Junior wrote:
>> On Wednesday, December 13 2017, I wrote:
>
>>> OK, I'll confirm on PPC64BE.
>
> Thanks.
>
>>
>> It seems like the algorithm for calculating bitfield offsets is not
>> working correctly on BE machines. This is not only for "ptype /o", but
>> also for regular print commands. For example, consider this test:
>>
>> struct tyu
>> {
>> int a1 : 1;
>>
>> int a2 : 3;
>>
>> int a3 : 23;
>>
>> char a4 : 2;
>>
>> int64_t a5;
>>
>> int a6 : 5;
>>
>> int64_t a7 : 3;
>> };
>>
>> int
>> main (int argc, char *argv[])
>> {
>> struct tyu e;
>>
>> e.a1 = e.a2 = e.a3 = e.a4 = e.a6 = e.a7 = -1;
>>
>> return 0;
>> }
>>
>> After stopping GDB at the "return 0;" line, here's what we see when we
>> print "e" on x86_64:
>>
>> (gdb) p e
>> $1 = {a1 = -1, a2 = -1, a3 = -1, a4 = -1 '\377', a5 = 140737488344880, a6 = -1, a7 = -1}
>>
>> While on PPC64BE:
>>
>> (gdb) p e
>> $1 = {a1 = -1, a2 = 3, a3 = 3, a4 = 3 '\003', a5 = 70367536153528, a6 = -1, a7 = -1}
>>
>
> You didn't initialize e.a5, so even the x86_64 version looks
> wrong at first. You're seeing stack/register garbage in
> the padding holes.
I should have initialized e.a5 to 0 in order to make the problem easier
to spot. I did that now:
$1 = {a1 = -1, a2 = 3, a3 = 3, a4 = 3 '\003', a5 = 0, a6 = -1, a7 = -1}
> You should make that "e" a global to make sure all its
> underlying bytes are clear, including padding. Or memset it.
> The former is easier.
>
> a2, a3 and a4 in the PPC64 version do look odd. Though
> maybe that's something do to with the expression you used.
>
> Does it make a difference if you initialize all fields
> with separate statements, like:
>
> e.a1 = -1;
> e.a2 = -1;
> etc.
After memset'ing the variable to 0, and separating all assignments, I
get:
[sergiodj@gcc1-power7 build-gdb]$ g++ -g ptype-offsets.cc
ptype-offsets.cc: In function ‘int main(int, char**)’:
ptype-offsets.cc:170:8: warning: large integer implicitly truncated to unsigned type [-Woverflow]
e.a4 = -1;
^
$1 = {a1 = -1, a2 = -1, a3 = -1, a4 = 3 '\003', a5 = 0, a6 = -1, a7 = -1}
After changing the declaration of a4 to "signed char a4 : 2;":
$1 = {a1 = -1, a2 = -1, a3 = -1, a4 = -1 '\377', a5 = 0, a6 = -1, a7 = -1}
>> As for "ptype /o", the offsets printed on x86_64 and PPC64BE are the
>> same:
>
> So it sounds like we could remove the x86-64 check in the
> testcase and let it run on all lp64 targets? Does it pass
> cleanly on PPC64?
I'm checking this right now, because I have to readjust the test due to
the changes in the output format.
--
Sergio
GPG key ID: 237A 54B1 0287 28BF 00EF 31F4 D0EB 7628 65FC 5E36
Please send encrypted e-mail if possible
http://sergiodj.net/
next prev parent reply other threads:[~2017-12-13 21:34 UTC|newest]
Thread overview: 75+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-21 16:07 [PATCH] " Sergio Durigan Junior
2017-11-21 16:16 ` Sergio Durigan Junior
2017-11-21 16:50 ` Eli Zaretskii
2017-11-21 17:00 ` Sergio Durigan Junior
2017-11-21 19:14 ` Eli Zaretskii
2017-11-26 19:27 ` Tom Tromey
2017-11-27 19:54 ` Sergio Durigan Junior
2017-11-27 22:20 ` Tom Tromey
2017-11-28 0:39 ` Sergio Durigan Junior
2017-11-28 21:21 ` [PATCH v2] " Sergio Durigan Junior
2017-11-29 3:28 ` Eli Zaretskii
2017-12-04 15:03 ` Sergio Durigan Junior
2017-12-04 15:41 ` Eli Zaretskii
2017-12-04 16:47 ` Sergio Durigan Junior
2017-12-08 21:32 ` Sergio Durigan Junior
2017-12-11 15:43 ` Simon Marchi
2017-12-11 18:59 ` Sergio Durigan Junior
2017-12-11 20:45 ` Simon Marchi
2017-12-11 21:07 ` Sergio Durigan Junior
2017-12-11 22:42 ` Pedro Alves
2017-12-11 22:50 ` Sergio Durigan Junior
2017-12-11 23:46 ` Pedro Alves
2017-12-12 0:25 ` Sergio Durigan Junior
2017-12-12 0:52 ` Pedro Alves
2017-12-12 1:25 ` Simon Marchi
2017-12-12 15:50 ` John Baldwin
2017-12-12 17:04 ` Sergio Durigan Junior
2017-12-11 19:58 ` [PATCH v3 0/2] Implement pahole-like 'ptype /o' option (and do some code reorg) Sergio Durigan Junior
2017-12-11 19:58 ` [PATCH v3 1/2] Reorganize code to handle TYPE_CODE_{STRUCT,UNION} on 'c_type_print_base' Sergio Durigan Junior
2017-12-11 20:55 ` Simon Marchi
2017-12-11 23:05 ` Sergio Durigan Junior
2017-12-11 19:58 ` [PATCH v3 2/2] Implement pahole-like 'ptype /o' option Sergio Durigan Junior
2017-12-11 21:50 ` Simon Marchi
2017-12-11 23:24 ` Sergio Durigan Junior
2017-12-12 1:32 ` Simon Marchi
2017-12-12 6:19 ` Sergio Durigan Junior
2017-12-12 18:14 ` Pedro Alves
2017-12-12 18:40 ` Sergio Durigan Junior
2017-12-12 20:12 ` Pedro Alves
2017-12-11 23:43 ` [PATCH v4 0/2] Implement pahole-like 'ptype /o' option (and do some code reorg) Sergio Durigan Junior
2017-12-11 23:44 ` [PATCH v4 1/2] Reorganize code to handle TYPE_CODE_{STRUCT,UNION} on 'c_type_print_base' Sergio Durigan Junior
2017-12-11 23:44 ` [PATCH v4 2/2] Implement pahole-like 'ptype /o' option Sergio Durigan Junior
2017-12-12 0:27 ` Sergio Durigan Junior
2017-12-12 0:29 ` Sergio Durigan Junior
2017-12-12 1:59 ` Simon Marchi
2017-12-12 3:39 ` Eli Zaretskii
2017-12-13 3:17 ` [PATCH v5 0/2] Implement pahole-like 'ptype /o' option (and do some code reorg) Sergio Durigan Junior
2017-12-13 3:17 ` [PATCH v5 2/2] Implement pahole-like 'ptype /o' option Sergio Durigan Junior
2017-12-13 4:50 ` Simon Marchi
2017-12-13 16:42 ` Sergio Durigan Junior
2017-12-13 16:17 ` Eli Zaretskii
2017-12-13 17:14 ` Sergio Durigan Junior
2017-12-13 16:19 ` Pedro Alves
2017-12-13 17:13 ` Sergio Durigan Junior
2017-12-13 20:36 ` Sergio Durigan Junior
2017-12-13 21:22 ` Pedro Alves
2017-12-13 21:30 ` Pedro Alves
2017-12-13 21:34 ` Sergio Durigan Junior [this message]
2017-12-13 16:20 ` Pedro Alves
2017-12-13 17:41 ` Sergio Durigan Junior
2017-12-13 3:17 ` [PATCH v5 1/2] Reorganize code to handle TYPE_CODE_{STRUCT,UNION} on 'c_type_print_base' Sergio Durigan Junior
2017-12-14 2:48 ` [PATCH v6 0/2] Implement pahole-like 'ptype /o' option (and do some code reorg) Sergio Durigan Junior
2017-12-14 2:48 ` [PATCH v6 1/2] Reorganize code to handle TYPE_CODE_{STRUCT,UNION} on 'c_type_print_base' Sergio Durigan Junior
2017-12-14 2:48 ` [PATCH v6 2/2] Implement pahole-like 'ptype /o' option Sergio Durigan Junior
2017-12-14 14:19 ` Pedro Alves
2017-12-14 20:31 ` Sergio Durigan Junior
2017-12-14 14:50 ` Pedro Alves
2017-12-14 20:29 ` Sergio Durigan Junior
2017-12-14 16:30 ` Eli Zaretskii
2017-12-15 1:12 ` [PATCH v7 0/2] Implement pahole-like 'ptype /o' option (and do some code reorg) Sergio Durigan Junior
2017-12-15 1:12 ` [PATCH v7 1/2] Reorganize code to handle TYPE_CODE_{STRUCT,UNION} on 'c_type_print_base' Sergio Durigan Junior
2017-12-15 1:13 ` [PATCH v7 2/2] Implement pahole-like 'ptype /o' option Sergio Durigan Junior
2017-12-15 17:24 ` Pedro Alves
2017-12-15 20:04 ` Sergio Durigan Junior
2017-12-15 20:11 ` [PATCH v7 0/2] Implement pahole-like 'ptype /o' option (and do some code reorg) Sergio Durigan Junior
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=87fu8eia6b.fsf@redhat.com \
--to=sergiodj@redhat.com \
--cc=eliz@gnu.org \
--cc=gdb-patches@sourceware.org \
--cc=keiths@redhat.com \
--cc=palves@redhat.com \
--cc=simon.marchi@ericsson.com \
--cc=tom@tromey.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).