From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.freebsd.org (mx2.freebsd.org [IPv6:2610:1c1:1:606c::19:2]) by sourceware.org (Postfix) with ESMTPS id 55CC73858D28 for ; Tue, 11 Apr 2023 22:35:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 55CC73858D28 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=FreeBSD.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [96.47.72.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits)) (Client CN "mx1.freebsd.org", Issuer "R3" (verified OK)) by mx2.freebsd.org (Postfix) with ESMTPS id 4Px0zL4synz3kbQ; Tue, 11 Apr 2023 22:35:26 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Px0zL3DjNz3Dy2; Tue, 11 Apr 2023 22:35:26 +0000 (UTC) (envelope-from jhb@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1681252526; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iF+Fhjs3LHGm90rISq0WCS0K+7k7f/Pz2FuwLejBX5s=; b=u/IEzegTffZ4M+nXKm4hNSTyw1id2Ccuk0R0vtvQuJc9+zdDOUbOJrjnU1GIqEbs+/6B+J QNVdG1hTKD2t9/iI+rox+Iw58Esb5nC/dX2IruQ17UTAwCKwxtMSZ2zMoP8s1rWfYcuJew 0CsaLjU+9ZlJZ1FznHBhhdJt7KFGxThrqkC3ID+JrGhy+H8KZ17XRnkmbD1A8OzUSWzjWp 0jwqpwoBBPt1wzi2fRLsbv7JeFVhw+9+a2azy0ThertFxRzh5LlfmsYlehUikioTas/ZNP 5cR2jGc55OmWdvyzctRJyip0IR64Ghj/mJJ/Qshq1H9CZry1VIyIcmA+8mFZvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1681252526; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iF+Fhjs3LHGm90rISq0WCS0K+7k7f/Pz2FuwLejBX5s=; b=e3L5p68FTzWMLW0mP4plgDHwt1P/3UHuspYH0RuWcIcJEjfr/G8HAHfS5uIqAlfGU5dtX7 3mYecEWtTSGBkbAh0/Zrph1Hll2fLg/F/KbpXqu6Xno0gG3gMp0PaEJNueKmffLdEWMiXp mXj8ZN2TF3H4NrYX8qR4bOtzfBebDrk7tlw4TwIbr5nBYQf0VYKtKqsZtNxLciRMKlcwq/ CuW9n8sM/88ptaA7h9lFtOuFdHGlqr91WcKlxUOsrnqsRBNSJhOulg2S7bCKtTY07AUtyT GvQ4U8Pj08TChvbsgPhcU2PmagSzA6Igd87hlFG734oN5N/IsJbfj3VRg7xzvw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1681252526; a=rsa-sha256; cv=none; b=AFyO0wckKlrhOx8Bh/ysKjlYIv2ZK0QSUc3Tg+uGiDXrq0Yb93g2P4Gsb4x0ottKRrySKG eIsWjxcZjvQGLDuCm6JS+paH2pmPe/qYyMPjIwtRp3DW9/A/YG8RuryZv37viS4xnX57T6 PonkM04K2bM1ZBxMFfLG4mqwQGAW21nRFaBicrYYHE6t5dwzCwZ2lhN4RTrRbDRFtcgMkn WOaSyC22+1tBp5yys31t0pTRBdqUmCjo9sKfyh6fUXLGx0ZOQVz18gYJ5D+Fy5KHRDLF1Y 41yUbZMowncidTtnFfhzAy5TzEEP1rvjubyHEQT7nHzior7V8xMI2/4NdbYC9w== Received: from [IPV6:2601:648:8680:16b0:4564:3328:dee2:f08a] (unknown [IPv6:2601:648:8680:16b0:4564:3328:dee2:f08a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 4Px0zL0Knwz1B4F; Tue, 11 Apr 2023 22:35:25 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Message-ID: <3e738f3b-a028-0e13-1c43-e50b06d255cb@FreeBSD.org> Date: Tue, 11 Apr 2023 15:35:24 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; 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: en-US From: John Baldwin To: Simon Marchi , 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> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_NONE,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 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. -- John Baldwin