From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12464 invoked by alias); 29 Aug 2007 04:36:44 -0000 Received: (qmail 12183 invoked by uid 22791); 29 Aug 2007 04:36:42 -0000 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 29 Aug 2007 04:36:38 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 636902AAA07; Wed, 29 Aug 2007 00:36:36 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id NGOVecZeaeyd; Wed, 29 Aug 2007 00:36:36 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 2056E2AAA04; Wed, 29 Aug 2007 00:36:36 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id 41AFAE7B58; Tue, 28 Aug 2007 21:36:33 -0700 (PDT) Date: Wed, 29 Aug 2007 04:36:00 -0000 From: Joel Brobecker To: Carlos Eduardo Seo , Luis Machado , gdb-patches@sourceware.org Subject: Re: [patch] ptype: show members of an unnamed struct inside an union Message-ID: <20070829043633.GD3795@adacore.com> References: <46C4D20E.1010703@linux.vnet.ibm.com> <20070828171422.GB3874@adacore.com> <46D47155.5000403@linux.vnet.ibm.com> <20070828200356.GA3795@adacore.com> <46D4818C.1030001@linux.vnet.ibm.com> <20070828203420.GB3795@adacore.com> <20070829025618.GA26311@caradoc.them.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20070829025618.GA26311@caradoc.them.org> User-Agent: Mutt/1.4.2.2i 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 X-SW-Source: 2007-08/txt/msg00508.txt.bz2 > > Does this case actually make any sense? I don't think you can access > > this union in your C program either, or can you? > > GCC supports anonymous unions. There's a test for it in the GDB > testsuite, too. But how can you access this union if the field doesn't have a name? More precisely, using the example that Carlos sent: struct my_page { union { struct { int mapping; }; }; }; How do you access the union? That's why I gave the union field a name "u" as follow: struct my_page { union { struct { int mapping; }; } u; }; So that I can reference it using "my_page.u". Just to be clear, I am not trying to object to the idea of enhancing GDB for such situations, I'm just trying to understand whether these situations correspond to something actually useful. I've seen this being used in the past, when some fields were inserted as a way of inserting some padding. I don't think it's really essential in that case to show the actual description of the padding, or maybe it is? -- Joel