From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 3r/mHWQf+2AAeAAAWB0awg (envelope-from ) for ; Fri, 23 Jul 2021 15:58:28 -0400 Received: by simark.ca (Postfix, from userid 112) id 6A4731EDFB; Fri, 23 Jul 2021 15:58:28 -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,RCVD_IN_MSPIKE_H2,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 99C201E4A3 for ; Fri, 23 Jul 2021 15:58:27 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C39CA388E800 for ; Fri, 23 Jul 2021 19:58:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C39CA388E800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1627070306; bh=6593bmOLCqf62wnGqjler5LZYsKc6WUgi7pDXntJlEY=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=dUKkAi9DiGLBtA1z+JSYDXFSBYbZusStSjsl6S0FltGcs9mBBKN3IzPBHZ/g0CUoj LZ4IneyaykrdBG2NYoRXQlGpfMoTLpo5ylxtvteEns+HM0TzoW9LuoAH3BXL4RqE+P 621FIfCE9w7vI5LHM944/1wKY84niUg6zMS4qRk8= Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 4E721386480A for ; Fri, 23 Jul 2021 19:58:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4E721386480A 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 16NJuwmX003977 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 Jul 2021 15:57:04 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 16NJuwmX003977 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 F3BB41E4A3; Fri, 23 Jul 2021 15:56:57 -0400 (EDT) Subject: Re: [PATCH 15/16] gdb: make cmd_list_element var an optional union To: Lancelot SIX References: <20210714045520.1623120-1-simon.marchi@polymtl.ca> <20210714045520.1623120-16-simon.marchi@polymtl.ca> <20210714120851.3pfew5pgcdp6ezn6@ubuntu.lan> <20210714171238.vzccwpurh2izbkps@ubuntu.lan> <20210714232112.wsn7pits6uuz3nf5@ubuntu.lan> <20210720230335.dcpfxbol2uwjre3b@Plymouth> Message-ID: Date: Fri, 23 Jul 2021 15:56:57 -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: <20210720230335.dcpfxbol2uwjre3b@Plymouth> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Fri, 23 Jul 2021 19:56:58 +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 Cc: gdb-patches@sourceware.org Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" > Hi, > > I reworked a bit my previous implementation to see to what extent it can > support what you are looking for. Short answer: it can (and it is > completely transparent to the caller). > > In the previous draft version[1], I introduced a struct that groups > together the var_type and the pointer to the actual data in order to > abstract a setting (i.e. a value with a type that can be SET or SHOWn). > This struct provides getters and setters in order to enforce that we > cast the pointer to the adequate type. I have modified this data > structure so we can register user-provided callbacks. If those > functions are provided, the getter and setters will call them to > generate retrieve the value instead of trying to dereference the > pointer. > > For the moment, I just made sure that this compiles and I played with > dummy settings in my local tree. It is not yet finalized nor fully > operational because do_set_command will try to free the pointer returned > by the getter when dealing with char* data. With user provided > callbacks memory should probably not be managed at that level but by the > getter / setter. Nothing worrying, you have a commit that plans to > change the char* with std::string, this should solve the issue quite > nicely. > > As for the previous version, this adds a significant amount of templated > code that can make the implementation appear quite complex. > > I think I’ll wait for your series to land before I finalize this > proposal (this is just a POC for the moment) unless you want to build on > top of this approach to introduce user provided callbacks. Do you suggest I merge my patch that makes it a union first? Won't that be counter productive if you plan to make it a void* again? I'm a bit lost now, so I am not sure what's the best order for doing things. Simon