public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Tom Tromey <tom@tromey.com>, gdb-patches@sourceware.org
Subject: Re: [RFA 2/6] Handle alignof and _Alignof
Date: Tue, 24 Apr 2018 19:17:00 -0000	[thread overview]
Message-ID: <bed9b13b-1ac2-7b06-d72c-002555c9e4cc@redhat.com> (raw)
In-Reply-To: <20180424152222.8053-3-tom@tromey.com>

Hi Tom,

What's in the patch looks good to me.  I have comments on the
tests -- I think it'd be good to extend them a bit more.

On 04/24/2018 04:22 PM, Tom Tromey wrote:

> +
> +# The types we're going to test.
> +
> +set typelist {
> +    char {unsigned char}
> +    short {unsigned short}
> +    int {unsigned int}
> +    long {unsigned long}
> +    {long long} {unsigned long long}
> +    float
> +    double

Shouldn't we test "long double"?  Patch #1 handles it.
Not sure all GCC ports support it, may require separate compilation.

Also, I'm wondering about "__int128" if the target
supports it.

In C++, do we get the alignment of non-standard layout classes right?
E.g., structs with references.  And structs with virtual methods, like:

 struct S
 {
   virtual ~S ();
   char c;
 };

This should print 8 instead of 1 on x86-64, due to the vtable pointer.

I think it'd be good to cover those things in the tests too.

Likewise arrays, bitfields and typedefs?

I didn't spot any test for the
 "could not determine alignment of type"
case to make that that works gracefully without crashing.  

What do we do with _Alignof(void)?  We treat sizeof(void) == 1,
like gcc, so I assume the _Alignof will return 1 too instead
of erroring out.

Finally, for completeness, GCC allows _Alignof applied to
expressions, so I guess we should to.  Does the series allow that?
I.e., can we do _Alignof(1 + 1)?  Does the parser handle that?

Shouldn't we test _Alignof applied to the structure fields too?

There was a snippet in the patch that made me wonder if the patch
handles alignof of a no-debug-info variable and and the return-type
of a no-debug-info function correctly (instead of e.g., crashing).
I'd be nice to add a couples test to gdb.base/nodebug.exp
to make sure.  E.g.:
   p _Alignof (dataglobal64_1)
   p _Alignof (middle())"

Also, please add intro comments to the testcase .exp files, so
that later on people can find out what the testcase is
about easily.

Thanks,
Pedro Alves

  parent reply	other threads:[~2018-04-24 19:17 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-24 15:22 [RFA 0/6] Teach gdb about type alignment Tom Tromey
2018-04-24 15:22 ` [RFA 2/6] Handle alignof and _Alignof Tom Tromey
2018-04-24 17:04   ` Eli Zaretskii
2018-04-24 19:17   ` Pedro Alves [this message]
2018-04-24 20:23     ` Tom Tromey
2018-04-27 18:02       ` Pedro Alves
2018-04-27 20:53         ` Tom Tromey
2018-04-30 16:46         ` Tom Tromey
2018-04-26 20:45     ` Tom Tromey
2018-04-27 18:05       ` Pedro Alves
2018-04-26 20:54     ` Tom Tromey
2018-04-24 15:22 ` [RFA 5/6] Remove rust_type_alignment Tom Tromey
2018-04-24 15:22 ` [RFA 3/6] Reindent type_object_getset in py-type.c Tom Tromey
2018-04-24 15:22 ` [RFA 6/6] Remove long_long_align_bit gdbarch attribute Tom Tromey
2018-04-24 15:24   ` Tom Tromey
2018-04-24 17:17   ` Anton Kolesov
2018-04-26 20:56     ` Tom Tromey
2018-04-24 15:22 ` [RFA 1/6] Add initial type alignment support Tom Tromey
2018-04-24 19:16   ` Pedro Alves
2018-04-24 20:23     ` Tom Tromey
2018-04-24 15:22 ` [RFA 4/6] Expose type alignment on gdb.Type Tom Tromey
2018-04-24 16:59   ` Eli Zaretskii

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=bed9b13b-1ac2-7b06-d72c-002555c9e4cc@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --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).