From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 91618 invoked by alias); 8 Jul 2019 16:34:55 -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 91285 invoked by uid 89); 8 Jul 2019 16:34:55 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,KAM_SHORT,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=reversed, HContent-Transfer-Encoding:8bit X-HELO: mail-wm1-f66.google.com Received: from mail-wm1-f66.google.com (HELO mail-wm1-f66.google.com) (209.85.128.66) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 08 Jul 2019 16:34:53 +0000 Received: by mail-wm1-f66.google.com with SMTP id g67so188048wme.1 for ; Mon, 08 Jul 2019 09:34:53 -0700 (PDT) Return-Path: Received: from ?IPv6:2001:8a0:f913:f700:56ee:75ff:fe8d:232b? ([2001:8a0:f913:f700:56ee:75ff:fe8d:232b]) by smtp.gmail.com with ESMTPSA id r12sm28533876wrt.95.2019.07.08.09.34.50 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Mon, 08 Jul 2019 09:34:50 -0700 (PDT) Subject: Re: [RFAv3 0/3] Convenience functions $_gdb_setting/$_gdb_int_setting To: Philippe Waroquiers , gdb-patches@sourceware.org References: <20190706104947.30301-1-philippe.waroquiers@skynet.be> From: Pedro Alves Message-ID: Date: Mon, 08 Jul 2019 16:34:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <20190706104947.30301-1-philippe.waroquiers@skynet.be> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-SW-Source: 2019-07/txt/msg00197.txt.bz2 Hi Philippe, Some overall design comments below. On 7/6/19 11:49 AM, Philippe Waroquiers wrote: > As part of the discussion of 'show | set may-call-functions [on|off]', > Eli suggested to have a way to access the GDB settings from > user defined commands. > As I had mentioned back then: https://sourceware.org/ml/gdb-patches/2019-04/msg00562.html we can already access the settings via Python. E.g. see it done here from a gdbinit script: https://gcc.gnu.org/ml/gcc-patches/2019-01/msg00135.html Copied here for convenience: python __gcc_prev_pagination=gdb.parameter("pagination") set pagination off ... python if __gcc_prev_pagination: gdb.execute("set pagination on") Given that, and the existence of the "with" command now for the common case, I'd like to at least see some mention/rationale/argument in the commit logs about why this is worth having/maintaining over just using gdb.parameter. BTW, did you look into how gdb.parameter is implemented, see if anything could be shared? BTW², kind of unfortunate that Python used a different naming here (settings vs parameters). > So, this patch series implements this. > > 2 functions are provided: > * $_gdb_setting that gives access to all settings, giving back a string value. > * $_gdb_int_setting, giving access to boolean, auto-boolean and integers. > This is easier to use for such types than the string version. The naming of the functions kind of seems a bit reversed to me. Off hand, I'd expect $_gdb_setting to give me the setting in its native type, and then something like $_gdb_setting_str to give me a string version/representation. Also, it seems like a design issue that settings that are unsigned internally get their values exposed as signed. I guess it could be even better if the setting's types were some new built-in types specific for the settings, and then if you wanted to get a string representation, you'd use '$_as_string($_gdb_setting(...))'. (*) (*) this made me wonder about a special $_python convenience function, which would take some python code as argument, and return a value, so you could write: if $_python(gdb.parameter ("pagination")) ... end etc. > This is v3. > Compared to v1, it rebases to a recent master, and handles the comments > of Eli about the documentation. > > (there was in fact no changes between v2 and v1, because I forgot to > commit the changes before sending the RFAv2 mail). Thanks, Pedro Alves