From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 104441 invoked by alias); 18 Nov 2017 22:58:09 -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 104426 invoked by uid 89); 18 Nov 2017 22:58:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=BAYES_00,KB_WAM_FROM_NAME_SINGLEWORD,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=no version=3.3.2 spammy=H*f:CAH, H*i:CAH, aug, Hx-languages-length:1593 X-HELO: simark.ca Received: from simark.ca (HELO simark.ca) (158.69.221.121) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 18 Nov 2017 22:58:07 +0000 Received: from [10.0.0.11] (192-222-251-162.qc.cable.ebox.net [192.222.251.162]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 254721E4F2; Sat, 18 Nov 2017 17:58:06 -0500 (EST) Subject: Re: [PATCH] Fix type casts losing typedefs and reimplement "whatis" typedef stripping To: Yao Qi , Pedro Alves Cc: GDB Patches , Phil Muldoon References: <1498837699-20897-1-git-send-email-palves@redhat.com> <5225ca30-ef69-040d-3f96-be2e5e87b80b@redhat.com> From: Simon Marchi Message-ID: <4b73fb98-b8c2-9d2f-1981-4660e3c202e6@simark.ca> Date: Sat, 18 Nov 2017 22:58:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2017-11/txt/msg00382.txt.bz2 On 2017-11-18 03:57 PM, Yao Qi wrote: > On Mon, Aug 21, 2017 at 11:38 AM, Pedro Alves wrote: > > Hi Pedro, > The new tests in gdb.base/whatis-ptype-typedefs.exp fail on 32-bit target. > > https://gdb-build.sergiodj.net/builders/Ubuntu-AArch32-m32/builds/1175/steps/test%20gdb/logs/stdio > https://gdb-build.sergiodj.net/builders/Fedora-i686/builds/6867/steps/test%20gdb/logs/stdio > https://gdb-build.sergiodj.net/builders/Fedora-x86_64-m32/builds/6849/steps/test%20gdb/logs/stdio > > Can you take a look? > I took a quick look. The issue (at least one of them) boils down to the fact that on 64 bits, you can't do this: (gdb) p (float_typedef) v_uchar_array_t_struct_typedef Invalid cast. but on 32 bits you can: (gdb) p (float_typedef) v_uchar_array_t_struct_typedef $1 = 1.16251721e-41 The expression basically tries to cast an array (which decays to a pointer) to a float. The cast works on 32 bits (doesn't give Invalid cast) because a float and a pointer are of the same size, and the execution enters this if branch: https://github.com/bminor/binutils-gdb/blob/master/gdb/valops.c#L554 On 64 bits, they are not the same size, so it ends up in the invalid cast branch. I don't really know what to do from there. Should we leave the behavior as-is and update the test, or prevent this kind of cast (the compiler doesn't accept that anyway, and I don't see any real use case to this). This function (value_cast) is a bit convoluted, I'm always afraid to touch it... Simon