public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Andrew Burgess <aburgess@sourceware.org>
To: gdb-cvs@sourceware.org
Subject: [binutils-gdb] gdb/gdbserver: share I386_LINUX_XSAVE_XCR0_OFFSET definition
Date: Mon, 25 Mar 2024 17:18:50 +0000 (GMT)	[thread overview]
Message-ID: <20240325171851.1DCD63858C78@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=7816b81e9b36ea0f57662bfd7446b573bf0c9e54

commit 7816b81e9b36ea0f57662bfd7446b573bf0c9e54
Author: Andrew Burgess <aburgess@redhat.com>
Date:   Sat Jan 27 10:40:35 2024 +0000

    gdb/gdbserver: share I386_LINUX_XSAVE_XCR0_OFFSET definition
    
    Share the definition of I386_LINUX_XSAVE_XCR0_OFFSET between GDB and
    gdbserver.
    
    This commit is part of a series that aims to share more of the x86
    target description creation code between GDB and gdbserver.  The
    I386_LINUX_XSAVE_XCR0_OFFSET #define is used as part of the target
    description creation, and I noticed that this constant is defined
    separately for GDB and gdbserver.
    
    This commit moves the definition into gdb/nat/x86-linux.h, which
    allows the #define to be shared.
    
    There should be no user visible changes after this commit.
    
    Approved-By: John Baldwin <jhb@FreeBSD.org>

Diff:
---
 gdb/amd64-linux-tdep.c     |  1 +
 gdb/i386-linux-tdep.c      |  1 +
 gdb/i386-linux-tdep.h      | 20 --------------------
 gdb/nat/x86-linux.h        | 20 ++++++++++++++++++++
 gdbserver/linux-x86-low.cc | 22 +---------------------
 5 files changed, 23 insertions(+), 41 deletions(-)

diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c
index 1deb13b4e9a..a512ec5dd02 100644
--- a/gdb/amd64-linux-tdep.c
+++ b/gdb/amd64-linux-tdep.c
@@ -42,6 +42,7 @@
 #include "arch/amd64.h"
 #include "target-descriptions.h"
 #include "expop.h"
+#include "nat/x86-linux.h"
 
 /* The syscall's XML filename for i386.  */
 #define XML_SYSCALL_FILENAME_AMD64 "syscalls/amd64-linux.xml"
diff --git a/gdb/i386-linux-tdep.c b/gdb/i386-linux-tdep.c
index a2f937690c2..8dd7203b6c3 100644
--- a/gdb/i386-linux-tdep.c
+++ b/gdb/i386-linux-tdep.c
@@ -40,6 +40,7 @@
 
 #include "i387-tdep.h"
 #include "gdbsupport/x86-xstate.h"
+#include "nat/x86-linux.h"
 
 /* The syscall's XML filename for i386.  */
 #define XML_SYSCALL_FILENAME_I386 "syscalls/i386-linux.xml"
diff --git a/gdb/i386-linux-tdep.h b/gdb/i386-linux-tdep.h
index 5891747572b..07593c6a8ec 100644
--- a/gdb/i386-linux-tdep.h
+++ b/gdb/i386-linux-tdep.h
@@ -58,26 +58,6 @@ extern void i386_linux_report_signal_info (struct gdbarch *gdbarch,
 /* Return the target description according to XCR0.  */
 extern const struct target_desc *i386_linux_read_description (uint64_t xcr0);
 
-/* Format of XSAVE extended state is:
-	struct
-	{
-	  fxsave_bytes[0..463]
-	  sw_usable_bytes[464..511]
-	  xstate_hdr_bytes[512..575]
-	  extended state regions (AVX, MPX, AVX512, PKRU, etc.)
-	};
-
-  Same memory layout will be used for the coredump NT_X86_XSTATE
-  representing the XSAVE extended state registers.
-
-  The first 8 bytes of the sw_usable_bytes[464..467] is the OS enabled
-  extended state mask, which is the same as the extended control register
-  0 (the XFEATURE_ENABLED_MASK register), XCR0.  We can use this mask
-  together with the mask saved in the xstate_hdr_bytes to determine what
-  states the processor/OS supports and what state, used or initialized,
-  the process/thread is in.  */ 
-#define I386_LINUX_XSAVE_XCR0_OFFSET 464
-
 extern int i386_linux_gregset_reg_offset[];
 
 /* Return x86 siginfo type.  */
diff --git a/gdb/nat/x86-linux.h b/gdb/nat/x86-linux.h
index 15153ea277e..855a8d14f91 100644
--- a/gdb/nat/x86-linux.h
+++ b/gdb/nat/x86-linux.h
@@ -22,6 +22,26 @@
 
 #include "nat/linux-nat.h"
 
+/* Format of XSAVE extended state is:
+	struct
+	{
+	  fxsave_bytes[0..463]
+	  sw_usable_bytes[464..511]
+	  xstate_hdr_bytes[512..575]
+	  extended state regions (AVX, MPX, AVX512, PKRU, etc.)
+	};
+
+  Same memory layout will be used for the coredump NT_X86_XSTATE
+  representing the XSAVE extended state registers.
+
+  The first 8 bytes of the sw_usable_bytes[464..467] is the OS enabled
+  extended state mask, which is the same as the extended control register
+  0 (the XFEATURE_ENABLED_MASK register), XCR0.  We can use this mask
+  together with the mask saved in the xstate_hdr_bytes to determine what
+  states the processor/OS supports and what state, used or initialized,
+  the process/thread is in.  */
+#define I386_LINUX_XSAVE_XCR0_OFFSET 464
+
 /* Set whether our local mirror of LWP's debug registers has been
    changed since the values were last written to the thread.  Nonzero
    indicates that a change has been made, zero indicates no change.  */
diff --git a/gdbserver/linux-x86-low.cc b/gdbserver/linux-x86-low.cc
index 872c3fc69c7..30d876efc5d 100644
--- a/gdbserver/linux-x86-low.cc
+++ b/gdbserver/linux-x86-low.cc
@@ -27,6 +27,7 @@
 #include "gdbsupport/x86-xstate.h"
 #include "nat/x86-xstate.h"
 #include "nat/gdb_ptrace.h"
+#include "nat/x86-linux.h"
 
 #ifdef __x86_64__
 #include "nat/amd64-linux-siginfo.h"
@@ -832,27 +833,6 @@ x86_target::low_siginfo_fixup (siginfo_t *ptrace, gdb_byte *inf, int direction)
 \f
 static int use_xml;
 
-/* Format of XSAVE extended state is:
-	struct
-	{
-	  fxsave_bytes[0..463]
-	  sw_usable_bytes[464..511]
-	  xstate_hdr_bytes[512..575]
-	  avx_bytes[576..831]
-	  future_state etc
-	};
-
-  Same memory layout will be used for the coredump NT_X86_XSTATE
-  representing the XSAVE extended state registers.
-
-  The first 8 bytes of the sw_usable_bytes[464..467] is the OS enabled
-  extended state mask, which is the same as the extended control register
-  0 (the XFEATURE_ENABLED_MASK register), XCR0.  We can use this mask
-  together with the mask saved in the xstate_hdr_bytes to determine what
-  states the processor/OS supports and what state, used or initialized,
-  the process/thread is in.  */
-#define I386_LINUX_XSAVE_XCR0_OFFSET 464
-
 /* Does the current host support the GETFPXREGS request?  The header
    file may or may not define it, and even if it is defined, the
    kernel will return EIO if it's running on a pre-SSE processor.  */

                 reply	other threads:[~2024-03-25 17:18 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240325171851.1DCD63858C78@sourceware.org \
    --to=aburgess@sourceware.org \
    --cc=gdb-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).