From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15950 invoked by alias); 2 Jan 2012 09:35:56 -0000 Received: (qmail 15813 invoked by uid 22791); 2 Jan 2012 09:35:55 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-ww0-f43.google.com (HELO mail-ww0-f43.google.com) (74.125.82.43) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 02 Jan 2012 09:35:40 +0000 Received: by wgbds11 with SMTP id ds11so21621905wgb.12 for ; Mon, 02 Jan 2012 01:35:39 -0800 (PST) MIME-Version: 1.0 Received: by 10.227.204.9 with SMTP id fk9mr47321183wbb.5.1325496938147; Mon, 02 Jan 2012 01:35:38 -0800 (PST) Received: by 10.180.107.69 with HTTP; Mon, 2 Jan 2012 01:35:38 -0800 (PST) In-Reply-To: References: Date: Mon, 02 Jan 2012 09:35:00 -0000 Message-ID: Subject: Re: [RFC] A new command 'grep' From: Abhijit Halder To: Kevin Pouget Cc: Eli Zaretskii , Siva Chandra , gdb-patches@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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: 2012-01/txt/msg00023.txt.bz2 On Mon, Jan 2, 2012 at 2:58 PM, Kevin Pouget wrote: > On Mon, Jan 2, 2012 at 9:54 AM, Eli Zaretskii wrote: >> >> I think this is the first time we receive a proposal for a command >> implemented in Python. =A0Perhaps there's a place to discuss whether >> some policy is in order in this regard. =A0E.g., the command will be >> unavailable in non-Python builds, which at least needs to be >> documented. =A0There may be other aspects that are worth discussing. > > I'm also curious about that, and maybe first of all, is there a Python > specific coding convention likely to be enforced in GNU projects > and/or GDB? > >>> Date: Mon, 2 Jan 2012 10:30:55 +0530 >>> From: Siva Chandra >>> >>> Attached is a patch which implements a 'grep' command using the GDB >>> Python API. The idea behind the 'grep' command is as follows. We often >>> have deep data structures and are probably interested in some one >>> particular field or value embedded somewhere deep in that data >>> structure. For such cases, instead of typing the complete expression >>> for the field, we can use the 'grep' command to lookup the field or >>> value of interest. >> >> Thanks. >> >> I think this is the first time we receive a proposal for a command >> implemented in Python. =A0Perhaps there's a place to discuss whether >> some policy is in order in this regard. =A0E.g., the command will be >> unavailable in non-Python builds, which at least needs to be >> documented. =A0There may be other aspects that are worth discussing. >> >> If this is accepted, it will need user-level documentation. >> >> I cannot say I like the name "grep". =A0Users will associate that name >> with the Unix command that searches through files, which is radically >> different from what your command does. =A0How about "lookup-fields" >> instead? > > There was a discussion a few months ago about "Implementation of pipe > to pass GDB's command output to the shell" [1] which would allow to > use the 'real' grep to do a similar job, but I'm not sure about the > status of this patch, it seems not to be in the trunk yet, according > to the ChangeLog. Hi all, Sorry, I'm still struggling with copyright assignment. I almost got approval from my organization but waiting for the disclaimer to be in hand. I will send a final patch for review once this assignment is done. Thanks, Abhijit Halder > > I didn't really look in depth at the sources, but based on you email > description, I wonder how it differs from a generic code like that > (not tested): > >> (gdb) grep int ss >> ss.int_val =3D (int) 10 > > #assume set print pretty on > > command =3D "print %s" % ss > to_grep =3D "int" > > out =3D gdb.execute (command, to_string=3DTrue) > for line in out.split("\n") > =A0if to_grep in line: > =A0 =A0print line > > > good idea anyway, > thanks, > > Kevin > > [1]: http://sourceware.org/ml/gdb-patches/2011-08/msg00483.html