From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18276 invoked by alias); 21 Aug 2017 16:23:48 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 18243 invoked by uid 89); 21 Aug 2017 16:23:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.3 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS,SPF_SOFTFAIL autolearn=ham version=3.3.2 spammy=HX-Greylist:succeeded, H*F:D*freebsd.org, baldwin, HX-Greylist:SMTP X-HELO: mail.baldwin.cx Received: from bigwig.baldwin.cx (HELO mail.baldwin.cx) (96.47.65.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 21 Aug 2017 16:23:44 +0000 Received: from ralph.baldwin.cx (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by mail.baldwin.cx (Postfix) with ESMTPSA id AA76F10AF0F; Mon, 21 Aug 2017 12:23:41 -0400 (EDT) From: John Baldwin To: Yao Qi Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 03/22] Return X86_XSTATE_SSE_MASK instead of 0 in i386fbsd_core_read_xcr0 Date: Mon, 21 Aug 2017 16:23:00 -0000 Message-ID: <3145523.UstzfFeGMo@ralph.baldwin.cx> User-Agent: KMail/4.14.10 (FreeBSD/11.1-STABLE; KDE/4.14.30; amd64; ; ) In-Reply-To: <1503329347-26711-4-git-send-email-yao.qi@linaro.org> References: <1503329347-26711-1-git-send-email-yao.qi@linaro.org> <1503329347-26711-4-git-send-email-yao.qi@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-IsSubscribed: yes X-SW-Source: 2017-08/txt/msg00405.txt.bz2 On Monday, August 21, 2017 04:28:48 PM Yao Qi wrote: > i386fbsd_core_read_xcr0 reads the value of xcr0 from the corefile. If > it fails, returns 0. This makes its caller {i386,amd64}_target_description > has to handle this special value. IMO, i386fbsd_core_read_xcr0 should > return the default xcr0 in case of error. > > gdb: > > 2017-08-21 Yao Qi > > * i386-fbsd-tdep.c (i386fbsd_core_read_xcr0): Return > X86_XSTATE_SSE_MASK instead of 0. > --- > gdb/i386-fbsd-tdep.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/gdb/i386-fbsd-tdep.c b/gdb/i386-fbsd-tdep.c > index 594b8f6..baca978 100644 > --- a/gdb/i386-fbsd-tdep.c > +++ b/gdb/i386-fbsd-tdep.c > @@ -248,14 +248,14 @@ i386fbsd_core_read_xcr0 (bfd *abfd) > { > warning (_("Couldn't read `xcr0' bytes from " > "`.reg-xstate' section in core file.")); > - return 0; > + return X86_XSTATE_SSE_MASK; > } > > xcr0 = bfd_get_64 (abfd, contents); > } > } > else > - xcr0 = 0; > + xcr0 = X86_XSTATE_SSE_MASK; > > return xcr0; > } I think this should actually be X86_XSTATE_MMX_MASK. Core dumps on FreeBSD/i386 only include the original 387 FPU state in .reg2, they do not write out SSE state in a separate note as Linux does. For i386 native FreeBSD (and probably other *BSD) targets the logic needs to similarly be a bit more complicated, though I can help. In particular, the 'static int have_ptrace_xmmregs' in i386-bsd-nat.c probably needs to be made non-static with an extern in 'i386-bsd-nat.h', and i386fbsd_read_description should try to use PT_GETXMMREGS once to probe it if it isn't set (it can just fetch the gdb process' registers to test the flag) and then select X86_XSTATE_SSE_MASK if there is no XSAVE support for PT_GETXMMREGS works, else use X86_XSTATE_MMX_MASK. Other BSD's don't have a target read description target method, so only i386-fbsd-nat.c would need to have its method updated. I could always work on this as a followup. -- John Baldwin