From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3534 invoked by alias); 19 Oct 2011 02:08:44 -0000 Received: (qmail 3474 invoked by uid 22791); 19 Oct 2011 02:08:42 -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; Wed, 19 Oct 2011 02:08:26 +0000 Received: by iagf6 with SMTP id f6so1729059iag.0 for ; Tue, 18 Oct 2011 19:08:25 -0700 (PDT) Received: by 10.231.61.76 with SMTP id s12mr2065109ibh.35.1318990104866; Tue, 18 Oct 2011 19:08:24 -0700 (PDT) Received: from [10.32.160.31] ([182.92.247.1]) by mx.google.com with ESMTPS id g16sm10327825ibs.8.2011.10.18.19.08.20 (version=SSLv3 cipher=OTHER); Tue, 18 Oct 2011 19:08:22 -0700 (PDT) Message-ID: <4E9E3112.7050307@gmail.com> Date: Wed, 19 Oct 2011 08:28: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: pmuldoon@redhat.com 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: 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/msg00522.txt.bz2 于 2011年10月18日 21:57, Phil Muldoon 写道: > 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. > The patch for test suite is here: http://www.cygwin.com/ml/gdb-patches/2011-10/msg00219.html You may find the reason of this patch at http://sourceware.org/ml/gdb-patches/2011-09/msg00568.html En, we may need a doc update, it seem that I indeed read tens of pages gnu coding standard carefully, it will spend some time. >> /* 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 >