]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb/gdbserver: share I386_LINUX_XSAVE_XCR0_OFFSET definition
authorAndrew Burgess <aburgess@redhat.com>
Sat, 27 Jan 2024 10:40:35 +0000 (10:40 +0000)
committerAndrew Burgess <aburgess@redhat.com>
Mon, 25 Mar 2024 17:14:19 +0000 (17:14 +0000)
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>
gdb/amd64-linux-tdep.c
gdb/i386-linux-tdep.c
gdb/i386-linux-tdep.h
gdb/nat/x86-linux.h
gdbserver/linux-x86-low.cc

index 1deb13b4e9addec469b1aed2c3107439505362c7..a512ec5dd026c0808f7df8ae9ed768fa838abdd4 100644 (file)
@@ -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"
index a2f937690c2e0d8dfa9e1ae30d6dd97216a5b26a..8dd7203b6c332409001f1a39aed039351d67c697 100644 (file)
@@ -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"
index 5891747572b1756456abe38dc5ec460a9530378f..07593c6a8ecc7212a35185d96793d1c2c8e71e3a 100644 (file)
@@ -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.  */
index 15153ea277eb329fd35891afbf2b7f41ada3f01d..855a8d14f91f9a138dd2eae6d89cec95ae56e61b 100644 (file)
 
 #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.  */
index 872c3fc69c77e1ebebc2fe4a12c879c59e517b29..30d876efc5dea570e09abb5bda4a08f30ca617e4 100644 (file)
@@ -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.  */