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 CD0313858401 for ; Thu, 13 Apr 2023 15:07:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CD0313858401 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca Received: from [10.0.0.170] (unknown [167.248.160.41]) (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 E80DF1E110; Thu, 13 Apr 2023 11:07:52 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1681398473; bh=i5cbWxmWFoOGT6aCXTNS3jteCUGtIOucM7e1eN2IDJQ=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=MXsWaF3ZNAHmSOYJi58bfxj67UypdF87kdjk/CGUjEmMjhAbmNzOJRmM4nAdEcuHd 3Qi9Ly+j2SuadWLLxQwUhF2Rt0g5OzkQ/KTY1vYyGerGxwBJpMvvJ4HBWUkbMYqVTP Q4QELeEOPOE2a7s/jmZGrY/RRXgCZCDLaQr5jj6k= Message-ID: <8a501f77-1759-b214-e1e1-4bc55cc2a9ff@simark.ca> Date: Thu, 13 Apr 2023 11:07:52 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH v4 12/13] gdbserver: Read offsets of the XSAVE extended region via CPUID Content-Language: fr To: John Baldwin , gdb-patches@sourceware.org Cc: Aleksandar Paunovic References: <20230318010905.14294-1-jhb@FreeBSD.org> <20230318010905.14294-13-jhb@FreeBSD.org> <80ddaec3-f871-d318-57e6-22669a4f3887@FreeBSD.org> From: Simon Marchi In-Reply-To: <80ddaec3-f871-d318-57e6-22669a4f3887@FreeBSD.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_PASS,SPF_PASS,TXREP 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 4/12/23 17:07, John Baldwin wrote: > On 4/12/23 12:11 PM, Simon Marchi wrote: >> On 3/17/23 21:09, John Baldwin wrote: >>> From: Aleksandar Paunovic >> Finally, do you think this class could eventually be shared with GDB, >> and could help simplify the implementation there? The i387_xsave could >> take a reference to an existing x86_xsave_layout object to take the >> offsets from, rather than referring to the global instance as it does >> currently. > > What I would really like to do (and planned to try as a followup after > this series) is try to use regcache_map_entry arrays to describe the > various XSAVE regions. Those arrays could be shared between GDB and > gdbserver (might need to make some of the regcache_map_entry stuff > be shared instead of GDB-only). I want to do this for eventual FreeBSD > support in gdbserver as well where I want to share the regcache maps > used in the foo-fbsd-tdep.c files with the equivalent low.cc file over > in gdbserver to describe the register sets available via ptrace. > > But using regcache_map_entry would mean you would do something like this > for the AVX region: > > /* The AVX region includes the YMMH registers. */ > const struct regcache_map_entry xsave_avx_regmap[] = > { > { 16, 0, 16 }, /* ymmh0 ... ymmh15 */ > }; > > const struct regset xsave_avx_regset = > { > xsave_avx_regmap, > regcache_collect_regset, regcache_supply_regset > }; > > Similar to how aarch64_fbsd_tls_regset is handled in aarch64-fbsd-tdep.c, > but using I387_YMMH0_REGNUM (tdep) instead of tdep->tls_base_regnum as > the base register number. > > Just as in the case of aarch64-fbsd I share the same regset for TLS between > both the tdep.c and nat.c, the regsets for XSAVE regions could be shared > between GDB and gdbserver. > > The gdbserver patches here I have only modified lightly from Aleksandar's > original work. I can work on them further, but I think if I want to unify > them (probably using regcache maps) I'd like to do that as a followup series. I always forget how the regcache maps work, because I have never really used them myself directly. But it sounds like a good idea. Simon