From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id lqX0ClrsEWHjVQAAWB0awg (envelope-from ) for ; Mon, 09 Aug 2021 23:02:50 -0400 Received: by simark.ca (Postfix, from userid 112) id 1C6A21EDF7; Mon, 9 Aug 2021 23:02:50 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 39BA21EA7E for ; Mon, 9 Aug 2021 23:02:49 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D63C939450C2 for ; Tue, 10 Aug 2021 03:02:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D63C939450C2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1628564567; bh=QL0ATrMfnppiDYwEToZdgxjvPh7UE1C58NhQkTndq4U=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=tg6Ma+2vBRmkT8wsFjzL3xxbE0033r2z6K4zVdrB7Eb5r3pSfoXVMD08eaVZPX4pj qSDK9cb3KPc9/BDAh4N8XuY3VDMC6KW6GD/oMp1QS7OgwdB816K21DwM5aQ66Z4BuU u8YgqQXiu1fmYaHxflCU659k7DtJ5YA3XWdh2HDc= Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 2FC29384800A for ; Tue, 10 Aug 2021 03:02:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2FC29384800A Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 17A31Akg006359 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 9 Aug 2021 23:01:17 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 17A31Akg006359 Received: from [10.0.0.11] (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id A44801EA7E; Mon, 9 Aug 2021 23:01:10 -0400 (EDT) Subject: Re: [PATCH v2 3/4] gdb: Have setter and getter callbacks for settings To: Lancelot SIX , gdb-patches@sourceware.org References: <20210808192302.3768766-1-lsix@lancelotsix.com> <20210808192302.3768766-4-lsix@lancelotsix.com> Message-ID: <727ab80a-c72d-960a-6d6e-a731aaa147dd@polymtl.ca> Date: Mon, 9 Aug 2021 23:01:10 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <20210808192302.3768766-4-lsix@lancelotsix.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Tue, 10 Aug 2021 03:01:10 +0000 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Simon Marchi via Gdb-patches Reply-To: Simon Marchi Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" On 2021-08-08 3:23 p.m., Lancelot SIX via Gdb-patches wrote: > The main motivation behind this improvement is to help the > implementation of a patch Simon Marchi is preparing to fix a bug when > MI or Python try to access parameters that are inferior dependent (see > PR/28085). > > This commit extends the previous one, which introduces the setting > object to represent a static variable that can be set or shown with the > appropriate commands. This patch proposes that a setting can either > contain a pointer to a static variable holding a setting, or pointers to > a pair of setter and getter callback functions. > > The callbacks functions can be used to generate values on the fly when > the setting is accessed (or set the value in a context dependent way). > This is useful when the source of truth is not contained in the > variable pointed to by the setting instance. > > Given that the callback function call is hidden within the setting > abstraction introduced earlier, none of the sites accessing the setting > needs to be updated. The registered getter or setter is used whatever > the way to access it is (through MI, Python, Guild, the "with" command > and the $_gdb_setting / $_gdb_setting_str convenience functions). > > All the add_setshow_*_cmd are given a new overload that will accept the > pair of function pointers (set / get functions) instead of the pointer > to a global variable. LGTM, except a small issue I found while rebasing my patch on top of your series: > @@ -231,25 +427,50 @@ struct base_setting > gdb_assert (var_type_uses (this->m_var_type)); > gdb_assert (!this->empty ()); I think this needs to call operator bool, like so: gdb_assert (*this); Otherwise, the assert fails when using a getter/setter (empty only checks for m_var to be non-NULL, which is false when using getter/setter). I don't find this notation super clear, it might be clearer if we could call a named method instead of operator bool. Maybe "empty" could mean "does not have a buffer nor getter/setter"? Simon