From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13628 invoked by alias); 24 Apr 2018 19:17:39 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 13252 invoked by uid 89); 24 Apr 2018 19:17:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,SPF_HELO_PASS autolearn=no version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx3-rdu2.redhat.com (HELO mx1.redhat.com) (66.187.233.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 24 Apr 2018 19:17:36 +0000 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3C820FB650; Tue, 24 Apr 2018 19:17:35 +0000 (UTC) Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 73A0383B67; Tue, 24 Apr 2018 19:17:34 +0000 (UTC) Subject: Re: [RFA 2/6] Handle alignof and _Alignof To: Tom Tromey , gdb-patches@sourceware.org References: <20180424152222.8053-1-tom@tromey.com> <20180424152222.8053-3-tom@tromey.com> From: Pedro Alves Message-ID: Date: Tue, 24 Apr 2018 19:17:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180424152222.8053-3-tom@tromey.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2018-04/txt/msg00486.txt.bz2 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