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 3B8963858D28 for ; Wed, 12 Apr 2023 14:35:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3B8963858D28 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 [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 RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id A6F251E110; Wed, 12 Apr 2023 10:35:17 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1681310117; bh=pMjI2bnYcTlRR6XahMql4L61+Em/qVP3N6mneEfsmAg=; h=Date:Subject:To:References:From:In-Reply-To:From; b=O/XV+18kZh1j+s3z92p5wPbk1H1VDTkkvjoHIygQBFuqNaDkcRDFmoqOL28K2y9G5 BwSrBlJnwwiCwZKXSfcSUGR6sHxtRjYb+Zr48Ule/O4UE2/s5AzVwmyZSmxbSlMkad 8QWYDhBdoMmVSkJ6cLzXrg/e8wJpcLZlxUui8JHo= Message-ID: Date: Wed, 12 Apr 2023 10:35:17 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Subject: Re: [PATCH v4 06/13] gdb: Support XSAVE layouts for the current host in the FreeBSD x86 targets. Content-Language: fr To: John Baldwin , gdb-patches@sourceware.org References: <20230318010905.14294-1-jhb@FreeBSD.org> <20230318010905.14294-7-jhb@FreeBSD.org> <448537fa-fff2-4bf9-e01b-1c01e5cb48dd@simark.ca> <198191af-c026-9e6a-767c-3418e8174959@simark.ca> <02d796f2-de80-b3c4-8279-38c750286446@FreeBSD.org> <3e738f3b-a028-0e13-1c43-e50b06d255cb@FreeBSD.org> From: Simon Marchi In-Reply-To: <3e738f3b-a028-0e13-1c43-e50b06d255cb@FreeBSD.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.1 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/11/23 18:35, John Baldwin wrote: > On 4/11/23 2:37 PM, John Baldwin wrote: >> On 4/11/23 9:46 AM, Simon Marchi wrote: >>> On 4/11/23 12:19, John Baldwin wrote: >>>> Note that the read_description methods for both Linux and >>>> FreeBSD already use ptrace for other things. Both use ptrace to decide >>>> if the inferior is using a 64-bit vs 32-bit tdesc. For 32-bit both use >>>> ptrace to determine if there is support for a custom ptrace op to fetch >>>> SSE/XMM register state (PTRACE_GETFPXREGS on Linux, PT_GETXMMREGS on >>>> FreeBSD), so this case is already quite broken. >>> >>> Heh, you're right, I ran those commands on x86 Linux and didn't even >>> notice the error message! >>> >>> (gdb) target native >>> Done. Use the "run" command to start a process. >>> (gdb) unset tdesc filename >>> Couldn't get CS register: No such process. >>> >>> So yeah, perhaps make sure this corner case is relatively correctly >>> handled. That probably means skipping over the ptrace check if >>> inferior_ptid is null_ptid, and make sure you don't cache that value (so >>> we actually probe it next time around). >> >> I think the right answer for theses cases is that the read_description >> methods need to just return a specific base-line description if >> inferior_ptid == null_ptid before doing any of the ptrace, etc. checks. >> Probably for 64-bit it means a simple 64-bit tdesc with SSE for example. > > This pattern is actually fairly common (using ptrace in read_description > methods) across several architectures. I have added patches to my series > locally to fix this for all of the FreeBSD and Linux native architectures > though I can't test many of these. Cool, thanks! Simon