From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27444 invoked by alias); 9 Dec 2014 16:22:11 -0000 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 Received: (qmail 27408 invoked by uid 89); 9 Dec 2014 16:22:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.7 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_SOFTFAIL autolearn=no version=3.3.2 X-HELO: mtaout20.012.net.il Received: from mtaout20.012.net.il (HELO mtaout20.012.net.il) (80.179.55.166) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 09 Dec 2014 16:22:04 +0000 Received: from conversion-daemon.a-mtaout20.012.net.il by a-mtaout20.012.net.il (HyperSendmail v2007.08) id <0NGB00700P3LA600@a-mtaout20.012.net.il> for gdb-patches@sourceware.org; Tue, 09 Dec 2014 18:22:01 +0200 (IST) Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout20.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0NGB005VMPGMKZ50@a-mtaout20.012.net.il>; Tue, 09 Dec 2014 18:22:01 +0200 (IST) Date: Tue, 09 Dec 2014 16:22:00 -0000 From: Eli Zaretskii Subject: Re: [PATCH] New python function gdb.lookup_objfile. In-reply-to: To: Doug Evans Cc: gdb-patches@sourceware.org Reply-to: Eli Zaretskii Message-id: <83vblkx07z.fsf@gnu.org> References: X-IsSubscribed: yes X-SW-Source: 2014-12/txt/msg00199.txt.bz2 > From: Doug Evans > Date: Mon, 08 Dec 2014 18:39:36 -0800 > > This patch implements a new python function gdb.lookup_objfile. > It provides the ability to look up an objfile given a file name > or build id. > > While one could call gdb.objfiles() and then scan over that, > it requires construction of the list, and with *lots* of objfiles > it is a bit cumbersome. > > Regression tested on amd64-linux. > > 2014-12-08 Doug Evans > > * NEWS: Mention gdb.lookup_objfile. > * python/python.c (GdbMethods): Add lookup_objfile. > * python/python-internal.h (gdbpy_lookup_objfile): Declare. > * python/py-objfile.c: #include "symtab.h". > (objfpy_build_id_ok, objfpy_build_id_matches): New functions. > (objfpy_lookup_objfile_by_name): New function. > (objfpy_lookup_objfile_by_build_id): New function. > (gdbpy_lookup_objfile): New function. > > doc/ > * python.texi (Objfiles In Python): Document gdb.lookup_objfile. > > testsuite/ > * lib/gdb-python.exp (get_python_valueof): New function. > * gdb.python/py-objfile.exp: Add tests for gdb.lookup_objfile. > > diff --git a/gdb/NEWS b/gdb/NEWS > index 6a2cb9b..93e06d4 100644 > --- a/gdb/NEWS > +++ b/gdb/NEWS > @@ -28,6 +28,7 @@ > ** A new event "gdb.clear_objfiles" has been added, triggered when > selecting a new file to debug. > ** You can now add attributes to gdb.Objfile and gdb.Progspace objects. > + ** New function gdb.lookup_objfile. OK for NEWS. > +@findex gdb.lookup_objfile > +@defun gdb.lookup_objfile (name @r{[}, by_build_id{]}) > +Look up @var{name}, which is a file name, in the list of objfiles > +for the current program space (@pxref{Progspaces In Python}). "Look up @var{name}, a file name or a build ID, in the list of objfiles for the current program space." > +If the objfile is not found then a Python @code{ValueError} exception > +is thrown. "... throw the Python ValueError exception" is better, because it avoids the passive tense. > +If @var{by_build_id} is provided and is @code{True} then @var{name} > +is the build ID of the objfile. I would add "Otherwise, @var{name} is a file name." The documentation changes are OK with those fixed. Thanks.