From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4709 invoked by alias); 13 Sep 2013 07:30:05 -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 4689 invoked by uid 89); 13 Sep 2013 07:30:04 -0000 Received: from mtaout23.012.net.il (HELO mtaout23.012.net.il) (80.179.55.175) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 13 Sep 2013 07:30:04 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,KHOP_THREADED autolearn=ham version=3.3.2 X-HELO: mtaout23.012.net.il Received: from conversion-daemon.a-mtaout23.012.net.il by a-mtaout23.012.net.il (HyperSendmail v2007.08) id <0MT100L00Z5LES00@a-mtaout23.012.net.il> for gdb-patches@sourceware.org; Fri, 13 Sep 2013 10:30:00 +0300 (IDT) Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout23.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0MT100L9NZHZC190@a-mtaout23.012.net.il>; Fri, 13 Sep 2013 10:30:00 +0300 (IDT) Date: Fri, 13 Sep 2013 07:30:00 -0000 From: Eli Zaretskii Subject: Re: [PATCH/RFA] Introduce new $_isvoid() convenience function In-reply-to: To: Sergio Durigan Junior Cc: dje@google.com, gdb-patches@sourceware.org Reply-to: Eli Zaretskii Message-id: <83a9jhi3h0.fsf@gnu.org> References: X-IsSubscribed: yes X-SW-Source: 2013-09/txt/msg00393.txt.bz2 > From: Sergio Durigan Junior > Cc: GDB Patches > Date: Fri, 13 Sep 2013 03:42:35 -0300 > > On Thursday, September 12 2013, Doug Evans wrote: > > > Hi. Thanks for persevering! > > Thank you for reviewing :-). > > > While I often follow "it's easier to relax restrictions than impose > > them after the fact", > > in this case I wonder if there's any reason to restrict $_isvoid() to > > convenience variables. > > > > Thoughts? > > > > For "void foo(){}", is there any real difference to: > > (gdb) set $foo = foo() > > (gdb) p $_isvoid($foo) > > (gdb) p $_isvoid(foo()) > > > > [Haven't tried it, but I'm guessing removing the internalva4 check in > > your patch would make that work.] > > Yes, I agree. I have changed the code to accept not only convenience > variables, but other kinds of expressions (it was just a matter of > removing the check for internalvar, really). BTW, I have reworded the > help message and the documentation and did s/convenience > variable/expression/g. > > > Also, you've put a fair bit of time into this, and I'm happy with > > what you've got. And thanks! > > The high order bit here for me is being able to script $_exitcode + $exitsignal. > > If we're going with checking for a void value, one could just leave it > > to be handled in Python. > > Yeah, I thought about it too, but then I thought that maybe we shouldn't > always depend on Python. This was easy to do in C, and has the > advantage that it will be available everywhere. But I guess you said > something along those lines below... > > > OTOH, this patch is really simple, and IMO it is *nice* to be able to > > do this from just a plain gdb script, > > so I'm advocating accepting this patch (modulo maybe handling any void > > value, not just conv vars). > > Nice. I hope you like the new version of the patch. > > > btw, I noticed that if I run a program to exit, and then rerun to > > main, $_exitcode has the last exit code - I would have expected it to > > get reset to void upon rerun. After all, if I stop at main the first > > time through, $_exitcode is void. > > [I'll file a bug, no need to address this in your patch series.] > > Yes, this is a bug indeed. Thanks for filing it. I may even have a fix > hanging around, will look. > > -- > Sergio > > gdb/ > 2013-09-13 Sergio Durigan Junior > > * NEWS: Mention new convenience function $_isvoid. > * value.c (isvoid_internal_fn): New function. > (_initialize_values): Add new convenience function $_isvoid. > > gdb/doc/ > 2013-09-13 Sergio Durigan Junior > > * gdb.texinfo (Convenience Functions): Mention new convenience > function $_isvoid. > > gdb/testsuite/ > 2013-09-13 Sergio Durigan Junior > > * gdb.base/gdbvars.c (foo_void): New function. > (foo_int): Likewise. > * gdb.base/gdbvars.exp (test_convenience_functions): New > function. Call it. > > diff --git a/gdb/NEWS b/gdb/NEWS > index ad97f6f..e58d6ce 100644 > --- a/gdb/NEWS > +++ b/gdb/NEWS > @@ -3,6 +3,9 @@ > > *** Changes since GDB 7.6 > > +* New convenience function "$_isvoid", to check whether an expression > + is void. This is OK, but please add a sentence explaining what is a "void expression". This is not something GDB users will automatically know or understand. > + > * The "maintenance print objfiles" command now takes an optional regexp. > > * The "catch syscall" command now works on arm*-linux* targets. > diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo > index b6ba239..70d580f 100644 > --- a/gdb/doc/gdb.texinfo > +++ b/gdb/doc/gdb.texinfo > @@ -9829,6 +9829,18 @@ Returns the length of string @var{str}. > > @end table > > +These functions do not require @value{GDBN} to be configured with > +@code{Python} support, which means that they are always available. I'd prefer to describe functions that don't need Python before those that do, not after. > +@table @code > + > +@item $_isvoid (@var{expr}) > +@findex $_isvoid@r{, convenience function} > +Return one if the expression @code{expr} is void. Otherwise it ^^^^^^^^^^^ @var{expr}. And please put here an explanation of what is a void expression, preferably more detailed than what you will have in NEWS. AFAICS, we never explain that anywhere in the manual. And now a question about this feature: what will use of this function do in versions of GDB before 7.7? Thanks.