From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2315 invoked by alias); 18 Oct 2011 13:58:09 -0000 Received: (qmail 2059 invoked by uid 22791); 18 Oct 2011 13:58:07 -0000 X-SWARE-Spam-Status: No, hits=-6.7 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 18 Oct 2011 13:57:50 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p9IDvlCq020606 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 18 Oct 2011 09:57:47 -0400 Received: from localhost.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p9IDvk5O012934; Tue, 18 Oct 2011 09:57:46 -0400 From: Phil Muldoon To: Li Yu Cc: gdb-patches@sourceware.org, Paul Koning , Tom Tromey Subject: Re: [PATCH v4] gdb/python: add missing handling for anonymous members of struct and union References: Reply-to: pmuldoon@redhat.com X-URL: http://www.redhat.com Date: Tue, 18 Oct 2011 14:03:00 -0000 In-Reply-To: (Li Yu's message of "Sat, 8 Oct 2011 13:35:38 +0800") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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/msg00500.txt.bz2 Li Yu writes: > gdb.Type.fields() missed handling for anonymous members. > > This patch fix it, below are details: Sorry I missed this patch. I have some questions. Given this functionality, do you have any use-cases in mind for it? Do we really want to include anonymous members in field () output? I ask because I cannot decide if the additional anonymous field information constitutes an API break. If so we may have to reconstitute this functionality from fields() so that it takes a keyword to turn this behavior on and off. Also, this patch requires a GDB testcase, and probably a documentation update. Also, a ChangeLog. > /* A type iterator object. */ > -typedef struct { > +typedef struct iterator_object > +{ > PyObject_HEAD > + /* The iterators for support fields of anonymous field */ > + struct iterator_object *child; Comments have to be complete sentences, including punctuation. So add a period at the end of that comment. > + if (iter_obj->child) > + { > + result = typy_iterator_iternext((PyObject*)iter_obj->child); Spacing around the ( and ) is incorrect. > + if (result) > + return result; > + Py_CLEAR(iter_obj->child); > + } > + > + type = iter_obj->source->type; > + > +restart: > + if (iter_obj->field >= TYPE_NFIELDS (type)) > + return NULL; > + > + name = TYPE_FIELD_NAME (type, iter_obj->field); > + if (!name || name[0]) /* array element or regular named member */ > { Comments need to be complete and punctuated. > result = make_fielditem (type, iter_obj->field, iter_obj->kind); > if (result != NULL) > @@ -1269,7 +1289,14 @@ typy_iterator_iternext (PyObject *self) > return result; > } > > - return NULL; > + type = TYPE_FIELD_TYPE(type, iter_obj->field++); > + child_pytype = type_to_type_object(type); Bracket spacing. > + if (!child_pytype) > + return NULL; > + child_iter_obj = > (typy_iterator_object*)typy_make_iter(child_pytype, iter_obj->kind); Bracket spacing. > + iter_obj->child = child_iter_obj; > + iter_obj = child_iter_obj; > + goto restart; > } > > static void Cheers, Phil