From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14875 invoked by alias); 18 Oct 2011 01:44:02 -0000 Received: (qmail 14863 invoked by uid 22791); 18 Oct 2011 01:44:01 -0000 X-SWARE-Spam-Status: No, hits=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail-iy0-f169.google.com (HELO mail-iy0-f169.google.com) (209.85.210.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 18 Oct 2011 01:43:46 +0000 Received: by iagf6 with SMTP id f6so127368iag.0 for ; Mon, 17 Oct 2011 18:43:45 -0700 (PDT) Received: by 10.42.72.194 with SMTP id p2mr677997icj.0.1318902224916; Mon, 17 Oct 2011 18:43:44 -0700 (PDT) Received: from [10.32.160.31] ([182.92.247.1]) by mx.google.com with ESMTPS id ge16sm1128586ibb.2.2011.10.17.18.43.39 (version=SSLv3 cipher=OTHER); Mon, 17 Oct 2011 18:43:41 -0700 (PDT) Message-ID: <4E9CD9C3.4080602@gmail.com> Date: Tue, 18 Oct 2011 01:48:00 -0000 From: Li Yu User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.23) Gecko/20110922 Thunderbird/3.1.15 MIME-Version: 1.0 To: gdb-patches@sourceware.org CC: Paul Koning , Tom Tromey Subject: Re: [PATCH v4] gdb/python: add missing handling for anonymous members of struct and union References: In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: 2011-10/txt/msg00490.txt.bz2 Is this ready for merge into upsteam ? thanks Yu 于 2011年10月08日 13:35, Li Yu 写道: > gdb.Type.fields() missed handling for anonymous members. > > This patch fix it, below are details: > > Assume that we have a c source as below: > > ///////////////////////////// > struct A > { > int a; > union { > int b0; > int b1; > union { > int bb0; > int bb1; > union { > int bbb0; > int bbb1; > }; > }; > }; > int c; > union { > union { > int dd0; > int dd1; > }; > int d2; > int d3; > }; > }; > > int main() > { > struct A a; > } > //////////////////////////// > > And have a python gdb script as below: > > ########################## > v = gdb.parse_and_eval("a") > t = v.type > fields = t.fields() > for f in fields: > print "[%s]" % f.name, v[f.name] > ########################## > > Without this patch, above script will print: > > [a] -7616 > [] {{dd0 = 0, dd1 = 0}, d2 = 0, d3 = 0} > [c] 0 > [] {{dd0 = 0, dd1 = 0}, d2 = 0, d3 = 0} > > With this patch, above script will print rightly: > > [a] -7616 > [b0] 32767 > [b1] 32767 > [bb0] 32767 > [bb1] 32767 > [bbb0] 32767 > [bbb1] 32767 > [c] 0 > [dd0] 0 > [dd1] 0 > [d2] 0 > [d3] 0 > > Thanks for Paul and Tom's feedback of this patch. > > This version uses recursion implementation, as we discussed, this > patch is passed by "make check" without regression :) > > Signed-off-by: Li Yu > > gdb/python/: > 2011-10-8 Li Yu > > * py-type.c: Add process for anonymous members of struct and union > > py-type.c | 41 ++++++++++++++++++++++++++++++++++------- > 1 file changed, 34 insertions(+), 7 deletions(-)