From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22288 invoked by alias); 24 Aug 2007 16:02:00 -0000 Received: (qmail 22192 invoked by uid 22791); 24 Aug 2007 16:01:47 -0000 X-Spam-Check-By: sourceware.org Received: from igw1.br.ibm.com (HELO igw1.br.ibm.com) (32.104.18.24) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 24 Aug 2007 16:01:34 +0000 Received: from mailhub1.br.ibm.com (mailhub1 [9.18.232.109]) by igw1.br.ibm.com (Postfix) with ESMTP id D4D991481BE for ; Fri, 24 Aug 2007 12:44:28 -0300 (BRT) Received: from d24av02.br.ibm.com (d24av02.br.ibm.com [9.18.232.47]) by mailhub1.br.ibm.com (8.13.8/8.13.8/NCO v8.5) with ESMTP id l7OG1WCf2105422 for ; Fri, 24 Aug 2007 13:01:32 -0300 Received: from d24av02.br.ibm.com (loopback [127.0.0.1]) by d24av02.br.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id l7OG1VqH018574 for ; Fri, 24 Aug 2007 13:01:31 -0300 Received: from [9.18.238.45] ([9.18.238.45]) by d24av02.br.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id l7OG1VDh018571; Fri, 24 Aug 2007 13:01:31 -0300 Message-ID: <46CF00DB.6050100@linux.vnet.ibm.com> Date: Fri, 24 Aug 2007 16:02:00 -0000 From: Carlos Eduardo Seo User-Agent: Thunderbird 2.0.0.6 (X11/20070802) MIME-Version: 1.0 To: Joel Brobecker CC: gdb-patches@sourceware.org Subject: Re: [patch] ptype: show members of an unnamed struct inside an union References: <46C4D20E.1010703@linux.vnet.ibm.com> <20070824155210.GN7552@adacore.com> In-Reply-To: <20070824155210.GN7552@adacore.com> OpenPGP: id=8BFFA900 Content-Type: multipart/mixed; boundary="------------050505060400080404070109" X-IsSubscribed: yes 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/msg00463.txt.bz2 This is a multi-part message in MIME format. --------------050505060400080404070109 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-length: 2492 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Joel Here's a testcase. In order to see the issue, do the following: 1. Compile it with -g flag 2. Run gdb 3. b main 4. ptype struct my_page You'll see: type = struct my_page { union { struct {...}; }; } Using the proposed patch, you'll see: type = struct my_page { union { struct {int mapping; }; }; } If you want, you may use a more complex union, such as: struct my_page { union { struct { int mapping; long foo; char *pointer; }; struct { char blah; int test; }; struct { char blahblah; }; struct { }; }; }; Any questions, feel free to contact me. Thanks and regards, - -- Carlos Eduardo Seo Software Engineer IBM Linux Technology Center Joel Brobecker wrote: > Carlos, > >> The attached patched fixes an issue described on this post: >> >> http://sourceware.org/ml/gdb-patches/2002-04/msg01114.html > >> 2007-08-16 Carlos Eduardo Seo >> >> gdb/c-typeprint.c (c_type_print_base): check value of >> TYPE_NFIELDS (type) when displaying members of an >> unnamed struct inside an union. > > Could you add a testcase for this issue? Being new at reviewing > other people's patches, it's sometimes hard for me to understand > what you are trying to do. A testcase would help in two ways: not > only ensure that we do not regress in the future, but also help > me understand clearly what it is that we're trying to fix. > > Thank you! > >> Index: src-git/gdb/c-typeprint.c >> =================================================================== >> --- src-git.orig/gdb/c-typeprint.c 2007-08-16 15:28:04.000000000 -0700 >> +++ src-git/gdb/c-typeprint.c 2007-08-16 15:29:07.000000000 -0700 >> @@ -735,7 +735,7 @@ >> fputs_filtered (" ", stream); >> } >> wrap_here (" "); >> - if (show < 0) >> + if ((show < 0) && (TYPE_NFIELDS (type) == 0)) >> { >> /* If we just printed a tag name, no need to print anything else. */ >> if (TYPE_TAG_NAME (type) == NULL) > -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGzwDaqvq7Aov/qQARArN6AJ9i06xbZqjUGhRXRZg5LReVZtmi6gCghOZB PgEYEpPTi3YfX6rXvQoXlZY= =sCUb -----END PGP SIGNATURE----- --------------050505060400080404070109 Content-Type: text/plain; name="mypage.c" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="mypage.c" Content-length: 149 struct my_page { union { struct { int mapping; }; }; }; main() { struct my_page mypage; } --------------050505060400080404070109 Content-Type: application/octet-stream; name="mypage.c.sig" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="mypage.c.sig" Content-length: 90 iD8DBQBGzwDbqvq7Aov/qQARAtFIAJ9ri6LuZ54RbwuJNUqig8fLaNBpeACc D2mASuUV/QTBMS3AwSSoiYc8YFs= --------------050505060400080404070109--