From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 288AE3858C2A for ; Thu, 21 Dec 2023 20:12:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 288AE3858C2A Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 288AE3858C2A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703189551; cv=none; b=KobQ+gIiFkGRZC3Rcntc2InYgn+qzEAt4ra8H2IcxHfRp4W0+VLXx/31lJwsbUUHVn9mrshviVpbP6Tjxxfz7CEcnAoZ/AkSSU30yN8VEcXD/SeFN3BeapkT9q+gggMT29guY03sSMzSo5whJaHAyf74hXpgy56AaxE3s6D2Gps= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703189551; c=relaxed/simple; bh=AzAOTnR+K0xMoJ+w3YySLnbqVYVY23Q/OkqBDP8/IyM=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=FY8TkN9g0w+fv1j8bsElXBbQQgRS17o62Co5GnwZKRq3q7Dgk1RK5iLIomEBLD/qxDExocGVadxfjXR3j0G1JAATV63a6iqMS+hsxUAGY6bda95AW7mYj5FZ5kIIH/Pj7BxaTBElq8vsRb27ViqqayaW0ozFXm8Uq9x79rIQCXU= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1703189549; bh=AzAOTnR+K0xMoJ+w3YySLnbqVYVY23Q/OkqBDP8/IyM=; h=Date:Subject:To:References:From:In-Reply-To:From; b=mWyF/o/oqthi6KPSx3wTyoyawXyaD385uNhx3Vt9s0IMTMn0Ux1gzNjOSk372nKmN DQfWDJikvwjqCMO5H1f9g7EF8n35J5QaD+f0glivMKG75xaJ1m1lal3C36q3rmiRy3 FVGVi468+dJnXW5O2Q7cwz/ot7+e9stWMIsdGAOk= Received: from [172.16.0.192] (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id C9D8F1E0AC; Thu, 21 Dec 2023 15:12:29 -0500 (EST) Message-ID: <7d3747db-3dc8-4002-8bda-e4c6ae3e3dc8@simark.ca> Date: Thu, 21 Dec 2023 15:12:29 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 01/26] gdbserver: convert init_register_cache into regcache::initialize Content-Language: fr To: Tankut Baris Aktemur , gdb-patches@sourceware.org References: <696f1910a4f60993f28541e1a6e41be9f65f6a20.1677582744.git.tankut.baris.aktemur@intel.com> From: Simon Marchi In-Reply-To: <696f1910a4f60993f28541e1a6e41be9f65f6a20.1677582744.git.tankut.baris.aktemur@intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 2/28/23 06:27, Tankut Baris Aktemur via Gdb-patches wrote: > This is a refactoring that converts the `init_register_cache` function > to a method of the regcache struct. During this conversion, we also > change the return type to void. I think this is fine. However, with a bit more effort, I think this could actually become a constructor, which would be nicer than having to call an initialize function. The only more "tricky" spot would be the use of regcache in fast_tracepoint_ctx. I think you could replace the regcache_initted and regcache fields with an std::optional. When instantiating the regcache, you would emplace the optional, which would call the constructor at that point. fast_tracepoint_ctx is only ever allocated as a local variable in gdb_collect, so using a gdb::optional there should be fine. Another improvement to try (for a subsequent patch) would be to pass an array_view to the initialize method (or constructor), and assert that the register size described by the tdesc matches the size of the buffer array_view passed. Simon