From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4658 invoked by alias); 27 Oct 2011 21:27:02 -0000 Received: (qmail 4643 invoked by uid 22791); 27 Oct 2011 21:27:01 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from qmta11.westchester.pa.mail.comcast.net (HELO QMTA11.westchester.pa.mail.comcast.net) (76.96.59.211) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 27 Oct 2011 21:26:44 +0000 Received: from omta12.westchester.pa.mail.comcast.net ([76.96.62.44]) by QMTA11.westchester.pa.mail.comcast.net with comcast id pxGL1h0030xGWP85BxSlb0; Thu, 27 Oct 2011 21:26:45 +0000 Received: from [10.127.238.91] ([65.206.2.68]) by omta12.westchester.pa.mail.comcast.net with comcast id pxSX1h00v1U2a2h3YxSamY; Thu, 27 Oct 2011 21:26:42 +0000 Subject: [RFA] Python: iterator for deep traversal of gdb.Type struct/union fields Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: Paul Koning In-Reply-To: <09787EF419216C41A903FD14EE5506DD030CF168FB@AUSX7MCPC103.AMER.DELL.COM> Date: Thu, 27 Oct 2011 21:56:00 -0000 Cc: Doug Evans Content-Transfer-Encoding: quoted-printable Message-Id: <66CAE6F8-F396-468B-A5CF-8D542A8A2E3D@comcast.net> References: <4E8595F6.7080004@gmail.com> <2460DAAE-C437-469A-BA1A-47343C5DBB45@comcast.net> <4E8F0244-3A3F-4AE2-A13C-DA9503282A97@comcast.net> <4C0389F5-A2DF-4864-8E33-BB893C885C98@comcast.net> <83bot4de4v.fsf@gnu.org> <92BF63C1-0118-4ED9-BB22-ACB406D2D22D@comcast.net> <09787EF419216C41A903FD14EE5506DD030CF1627A@AUSX7MCPC103.AMER.DELL.COM> <09787EF419216C41A903FD14EE5506DD030CF168FB@AUSX7MCPC103.AMER.DELL.COM> To: gdb-patches@sourceware.org, 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/msg00751.txt.bz2 > -----Original Message----- > From: Tom Tromey [mailto:tromey@redhat.com]=20 > Sent: Thursday, October 27, 2011 3:57 PM > To: Koning, Paul > Cc: dje@google.com; gdb-patches@sourceware.org > Subject: Re: [RFA] Python: iterator for deep traversal of gdb.Type struct= /union fields >=20 >>>>>> "Paul" =3D=3D writes: >=20 >>> Hi. Is it too late to change the name to deep_items? >>>=20 >>> I like consistency in the user-facing API and we've been using=20 >>> foo_bar (as does PEP008). >>>=20 >>> [Or is there a special reason for eliding the underscore?] >=20 > Paul> No problem that I know of. It's a trivial change to make if=20 > Paul> that's desired. >=20 > Yeah, I think so. >=20 > I was unaware that this is in PEP 8. >=20 > Also, could you write a NEWS item? I'd like to try to put all Python add= itions into NEWS. Like this? paul ChangeLog: 2011-10-27 Paul Koning * python/lib/gdb/types.py (deep_items): Rename from deepitems. * NEWS: Mention deep_items. doc/ChangeLog: 2011-10-27 Paul Koning * gdb.texinfo (gdb.types): Rename deepitems to deep_items. testsuite/ChangeLog: 2011-10-27 Paul Koning * gdb.python/lib-types.exp (deep_items): Rename from deepitems. Index: NEWS =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/NEWS,v retrieving revision 1.461 diff -u -r1.461 NEWS --- NEWS 24 Oct 2011 11:49:26 -0000 1.461 +++ NEWS 27 Oct 2011 21:21:31 -0000 @@ -56,6 +56,12 @@ ** A new event "gdb.new_objfile" has been added, triggered by loading a new object file. =20 + ** A new function, "deep_items" has been added to the gdb.types + module in the GDB Python modules library. This function returns + an iterator over the fields of a struct or union type. Unlike + the standard Python "iteritems" method, it will recursively traverse + any anonymous fields. + * libthread-db-search-path now supports two special values: $sdir and $pdi= r. $sdir specifies the default system locations of shared libraries. $pdir specifies the directory where the libpthread used by the applicati= on Index: python/lib/gdb/types.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/python/lib/gdb/types.py,v retrieving revision 1.3 diff -u -r1.3 types.py --- python/lib/gdb/types.py 26 Oct 2011 15:09:40 -0000 1.3 +++ python/lib/gdb/types.py 27 Oct 2011 21:21:35 -0000 @@ -91,7 +91,7 @@ return enum_dict =20 =20 -def deepitems (type_): +def deep_items (type_): """Return an iterator that recursively traverses anonymous fields. =20 Arguments: @@ -107,5 +107,5 @@ if k: yield k, v else: - for i in deepitems (v.type): + for i in deep_items (v.type): yield i Index: doc/gdb.texinfo =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v retrieving revision 1.883 diff -u -r1.883 gdb.texinfo --- doc/gdb.texinfo 27 Oct 2011 11:04:26 -0000 1.883 +++ doc/gdb.texinfo 27 Oct 2011 21:21:35 -0000 @@ -24438,10 +24438,10 @@ @item make_enum_dict (@var{enum_type}) Return a Python @code{dictionary} type produced from @var{enum_type}. =20 -@item deepitems (@var{type}) +@item deep_items (@var{type}) Returns a Python iterator similar to the standard @code{gdb.Type.iteritems} method, except that the iterator returned -by @code{deepitems} will recursively traverse anonymous struct or +by @code{deep_items} will recursively traverse anonymous struct or union fields. For example: =20 @smallexample @@ -24462,7 +24462,7 @@ (@value{GDBP}) python struct_a =3D gdb.lookup_type("struct A") (@value{GDBP}) python print struct_a.keys () @{['a', '']@} -(@value{GDBP}) python print [k for k,v in gdb.types.deepitems(struct_a)] +(@value{GDBP}) python print [k for k,v in gdb.types.deep_items(struct_a)] @{['a', 'b0', 'b1']@} @end smallexample =20 Index: testsuite/gdb.python/lib-types.exp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/testsuite/gdb.python/lib-types.exp,v retrieving revision 1.4 diff -u -r1.4 lib-types.exp --- testsuite/gdb.python/lib-types.exp 26 Oct 2011 15:10:11 -0000 1.4 +++ testsuite/gdb.python/lib-types.exp 27 Oct 2011 21:21:36 -0000 @@ -139,7 +139,7 @@ gdb_test_no_output "python enum1_list.sort ()" gdb_test "python print enum1_list" {\[\('A', 0L\), \('B', 1L\), \('C', 2L\= )\]} =20 -# test deepitems +# test deep_items gdb_test_no_output "python struct_a =3D gdb.lookup_type ('struct A')" gdb_test "python print struct_a.keys ()" {\['a', '', 'c', ''\]} -gdb_test "python print \[k for k,v in gdb.types.deepitems(struct_a)\]" {\[= 'a', 'b0', 'b1', 'bb0', 'bb1', 'bbb0', 'bbb1', 'c', 'dd0', 'dd1', 'd2', 'd3= '\]} +gdb_test "python print \[k for k,v in gdb.types.deep_items(struct_a)\]" {\= ['a', 'b0', 'b1', 'bb0', 'bb1', 'bbb0', 'bbb1', 'c', 'dd0', 'dd1', 'd2', 'd= 3'\]}