From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9019 invoked by alias); 23 Apr 2018 16:53:58 -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 9006 invoked by uid 89); 23 Apr 2018 16:53:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.8 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.2 spammy=H*r:4.82, lastly, vars, awkward X-HELO: eggs.gnu.org Received: from eggs.gnu.org (HELO eggs.gnu.org) (208.118.235.92) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 23 Apr 2018 16:53:56 +0000 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fAeis-0000jQ-5m for gdb-patches@sourceware.org; Mon, 23 Apr 2018 12:53:54 -0400 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:45038) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fAeis-0000jM-2Y; Mon, 23 Apr 2018 12:53:50 -0400 Received: from [176.228.60.248] (port=4028 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1fAeir-0003MY-HY; Mon, 23 Apr 2018 12:53:49 -0400 Date: Mon, 23 Apr 2018 16:53:00 -0000 Message-Id: <83d0ypx3sa.fsf@gnu.org> From: Eli Zaretskii To: Tom Tromey CC: gdb-patches@sourceware.org In-reply-to: <20180422211309.31251-1-tom@tromey.com> (message from Tom Tromey on Sun, 22 Apr 2018 15:13:09 -0600) Subject: Re: [RFA] Add basic Python API for convenience variables Reply-to: Eli Zaretskii References: <20180422211309.31251-1-tom@tromey.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-IsSubscribed: yes X-SW-Source: 2018-04/txt/msg00451.txt.bz2 > From: Tom Tromey > Cc: Tom Tromey > Date: Sun, 22 Apr 2018 15:13:09 -0600 > > This adds a basic Python API for accessing convenience variables. > With this, convenience variables can be read and set from Python. > Although gdb supports convenience variables whose value changes at > each call, this is not exposed to Python; it could be, but I think > it's just as good to write a convenience function in this situation. > > This is PR python/23080. Thanks. > diff --git a/gdb/NEWS b/gdb/NEWS > index 63fe30d175..157756597a 100644 > --- a/gdb/NEWS > +++ b/gdb/NEWS > @@ -24,6 +24,12 @@ set|show record btrace cpu > Controls the processor to be used for enabling errata workarounds for > branch trace decode. > > +* Python API > + > + ** The new functions gdb.convenience_variable and > + gdb.set_convenience_variable can be used to get and set the value > + of convenience variables. > + > * New targets This part is OK. > --- a/gdb/doc/python.texi > +++ b/gdb/doc/python.texi > @@ -288,6 +288,26 @@ If no exception is raised, the return value is always an instance of > @code{gdb.Value} (@pxref{Values From Inferior}). > @end defun This is also OK, but I have a few nit-picking comments: > +@findex gdb.convenience_variable > +@defun gdb.convenience_variable (name) > +Return the value of the convenience variable (@pxref{Convenience > +Vars}) named @var{name}. @var{name} must be a string. The name > +should not include the @samp{$} that is used to mark a convenience > +variable in an expression. If the convenience variable does not > +exist, then @code{None} is returned. > +@end defun > + > +@findex gdb.set_convenience_variable > +@defun gdb.set_convenience_variable (name, value) > +Set the value of the convenience variable (@pxref{Convenience Vars}) > +named @var{name}. @var{name} must be a string. The name should not > +include the @samp{$} that is used to mark a convenience variable in an > +expression. If @var{value} is @code{None}, then the convenience > +variable is removed. Otherwise, if @var{value} is not a > +@code{gdb.Value} (@pxref{Values From Inferior}), it is is converted > +using the @code{gdb.Value} constructor. > +@end defun First, can we avoid repeating what NAME can and cannot be or include, and have that only once? Second, "named @var{name}" sounds awkward, I would perhaps suggest "specified by @var{name}" or somesuch. And lastly, I would generally suggest to avoid starting a sentence with @var{something} because in the printed manual this produces a sentence that begins with a lower-case word. Since these are minor issues, if you don't feel like fixing them, I won't object.