From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21913 invoked by alias); 4 Oct 2011 18:05:24 -0000 Received: (qmail 21905 invoked by uid 22791); 4 Oct 2011 18:05:24 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from qmta05.westchester.pa.mail.comcast.net (HELO qmta05.westchester.pa.mail.comcast.net) (76.96.62.48) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 04 Oct 2011 18:05:08 +0000 Received: from omta23.westchester.pa.mail.comcast.net ([76.96.62.74]) by qmta05.westchester.pa.mail.comcast.net with comcast id gddk1h0071c6gX855i59XJ; Tue, 04 Oct 2011 18:05:09 +0000 Received: from [10.127.238.91] ([65.206.2.68]) by omta23.westchester.pa.mail.comcast.net with comcast id gi4w1h01F1U2a2h3ji4y3z; Tue, 04 Oct 2011 18:05:07 +0000 Subject: Re: [PATCH v2] gdb/python: add missing handling for anonymous members of struct and union Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: Paul Koning In-Reply-To: Date: Tue, 04 Oct 2011 18:05:00 -0000 Cc: Li Yu , gdb-patches@sourceware.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <4E8595F6.7080004@gmail.com> To: Tom Tromey 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/msg00108.txt.bz2 On Oct 4, 2011, at 12:36 PM, Tom Tromey wrote: > ... > I don't understand why the iterator iterates into sub-objects. Why not > just have a flat iterator? That is, return a field with no name whose > type is some structure, and then let the caller iterate over that type > if need be. >=20 > Tom That's the current behavior. Yu showed an example where he wanted to get a= ll the field names so he could then use those to retrieve the fields in a g= db.Value object. (Value objects don't currently have iterators; I'll propo= se a patch for that shortly.) You can certainly do this in Python, for example: import gdb def deepkeys (t): parent =3D t.iteritems () child =3D None while True: if not child: try: k, v =3D parent.next () except StopIteration: parent =3D None raise if k: yield k continue child =3D deepkeys (v.type) try: yield child.next () except StopIteration: child =3D None (This could be done more elegantly if gdb.Type could be subclassed.) It's an interesting inconsistency that values can be indexed by field names= of nested fields inside anonymous fields, but type cannot. And the keys()= method on a Type right now returns only the top level names.=20=20 paul