From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id tgNpIvWwVWFFVAAAWB0awg (envelope-from ) for ; Thu, 30 Sep 2021 08:43:33 -0400 Received: by simark.ca (Postfix, from userid 112) id 7A6F81EE27; Thu, 30 Sep 2021 08:43:33 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,NICE_REPLY_A,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 A6AA81EDF7 for ; Thu, 30 Sep 2021 08:43:32 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 22F313858415 for ; Thu, 30 Sep 2021 12:43:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 22F313858415 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1633005812; bh=1nJr9WN7+VZju3mz+F8/rukkolMyb47RY768hhIiS/U=; h=Date:Subject:To:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=pY7xAMInD83oClswSd4N7Q71sJMilsAR4F8A+eBUwwD1hYvNbDzX2PyayPIID1DnV oy+b1rbSg/K7x9AEX7wMshhibSiq4UWPrQN1BX9JHnQzYMZH9NZi1LLPVj1+kKO+q9 j3uX+t5EChVQx5up6wpvD+O0L+NSSMwtpgtdAf/Y= Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 72A3D3858C39 for ; Thu, 30 Sep 2021 12:43:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 72A3D3858C39 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 18UCg6rC027951 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 30 Sep 2021 08:42:11 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 18UCg6rC027951 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)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 309381EDF7; Thu, 30 Sep 2021 08:42:06 -0400 (EDT) Message-ID: Date: Thu, 30 Sep 2021 08:42:04 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.1 Subject: Re: [PATCH v4 3/4] gdb: Have setter and getter callbacks for settings Content-Language: en-US To: Lancelot SIX , gdb-patches@sourceware.org References: <20210929215011.1489639-1-lsix@lancelotsix.com> <20210929215011.1489639-4-lsix@lancelotsix.com> In-Reply-To: <20210929215011.1489639-4-lsix@lancelotsix.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Thu, 30 Sep 2021 12:42:06 +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" Just some nits: > @@ -475,6 +479,7 @@ add_set_or_show_cmd (const char *name, > > gdb_assert (type == set_cmd || type == show_cmd); > c->type = type; > + > c->var.emplace (var_type, arg); Spurious new line added. > @@ -219,18 +249,42 @@ struct setting > (see VAR_TYPE_USES). */ > setting (var_types var_type, const erased_args &args) > : m_var_type (var_type), > - m_var (args.var) > + m_var (args.var), > + m_getter (args.getter), > + m_setter (args.setter) > { > } > > - /* Access the type of the current setting. */ > - var_types type () const > + /* Create a setting backed by setter and getter functions. > + > + Type T must match the var type VAR_TYPE (see VAR_TYPE_USES). */ > + template > + setting (var_types var_type, > + setting_setter_ftype setter, > + setting_getter_ftype getter) > + : m_var_type (var_type) > { > - return m_var_type; > + gdb_assert (var_type_uses (var_type)); > + > + /* Getters and setters are cast to and from the arbitrary `void (*) ()` > + function pointer type. Make sure that the two types are really of the > + same size. */ > + gdb_static_assert (sizeof (m_getter) == sizeof (getter)); > + gdb_static_assert (sizeof (m_setter) == sizeof (setter)); > + > + m_getter = reinterpret_cast (getter); > + m_setter = reinterpret_cast (setter); > } > > + /* Access the type of the current setting. */ > + var_types type () const > + { return m_var_type; } > + > /* Return the current value. > > + Calling this method is only valid if the current setting is stored in a > + variable referenced by m_var (i.e. 'storage () == storage::variable'). That part of the comment seems false. Simon