Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andrew Burgess <aburgess@redhat.com>
To: gdb-patches@sourceware.org
Cc: Andrew Burgess <aburgess@redhat.com>
Subject: [PATCHv2 4/7] gdb/gdbserver: share I386_LINUX_XSAVE_XCR0_OFFSET definition
Date: Tue,  5 Mar 2024 17:00:19 +0000	[thread overview]
Message-ID: <add521c466cec9af7893c097f41ff81c3a3117cc.1709657954.git.aburgess@redhat.com> (raw)
In-Reply-To: <cover.1709657954.git.aburgess@redhat.com>

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.
---
 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 ec80bfe905c..7bade8b3cbf 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.  */
-- 
2.25.4


  parent reply	other threads:[~2024-03-05 17:01 UTC|newest]

Thread overview: 116+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-01 15:28 [PATCH 0/7] x86/Linux Target Description Changes Andrew Burgess
2024-02-01 15:28 ` [PATCH 1/7] gdbserver: convert have_ptrace_getregset to a tribool Andrew Burgess
2024-02-01 15:28 ` [PATCH 2/7] gdb/x86: move reading of cs and ds state into gdb/nat directory Andrew Burgess
2024-02-01 15:28 ` [PATCH 3/7] gdbserver/x86: move no-xml code earlier in x86_linux_read_description Andrew Burgess
2024-02-01 15:28 ` [PATCH 4/7] gdb/gdbserver: share I386_LINUX_XSAVE_XCR0_OFFSET definition Andrew Burgess
2024-02-01 15:28 ` [PATCH 5/7] gdb/gdbserver: share some code relating to target description creation Andrew Burgess
2024-02-01 15:28 ` [PATCH 6/7] gdbserver: update target description creation for x86/linux Andrew Burgess
2024-02-01 15:28 ` [PATCH 7/7] gdb/gdbserver: share x86/linux tdesc caching Andrew Burgess
2024-03-05 17:00 ` [PATCHv2 0/7] x86/Linux Target Description Changes Andrew Burgess
2024-03-05 17:00   ` [PATCHv2 1/7] gdbserver: convert have_ptrace_getregset to a tribool Andrew Burgess
2024-03-05 17:00   ` [PATCHv2 2/7] gdb/x86: move reading of cs and ds state into gdb/nat directory Andrew Burgess
2024-03-05 17:00   ` [PATCHv2 3/7] gdbserver/x86: move no-xml code earlier in x86_linux_read_description Andrew Burgess
2024-03-05 17:00   ` Andrew Burgess [this message]
2024-03-05 17:00   ` [PATCHv2 5/7] gdb/gdbserver: share some code relating to target description creation Andrew Burgess
2024-03-05 17:00   ` [PATCHv2 6/7] gdbserver: update target description creation for x86/linux Andrew Burgess
2024-03-19 16:01     ` John Baldwin
2024-03-19 18:34       ` Andrew Burgess
2024-03-21 17:28         ` John Baldwin
2024-03-26 10:01           ` Luis Machado
2024-03-26 15:31             ` Tom Tromey
2024-03-05 17:00   ` [PATCHv2 7/7] gdb/gdbserver: share x86/linux tdesc caching Andrew Burgess
2024-03-19 16:05   ` [PATCHv2 0/7] x86/Linux Target Description Changes John Baldwin
2024-03-23 16:35   ` [PATCHv3 0/8] " Andrew Burgess
2024-03-23 16:35     ` [PATCHv3 1/8] gdbserver: convert have_ptrace_getregset to a tribool Andrew Burgess
2024-03-23 16:35     ` [PATCHv3 2/8] gdb/x86: move reading of cs and ds state into gdb/nat directory Andrew Burgess
2024-03-23 16:35     ` [PATCHv3 3/8] gdbserver/x86: move no-xml code earlier in x86_linux_read_description Andrew Burgess
2024-03-23 16:35     ` [PATCHv3 4/8] gdb/gdbserver: share I386_LINUX_XSAVE_XCR0_OFFSET definition Andrew Burgess
2024-03-23 16:35     ` [PATCHv3 5/8] gdb/gdbserver: share some code relating to target description creation Andrew Burgess
2024-03-23 16:35     ` [PATCHv3 6/8] gdb/arch: assert that X86_XSTATE_MPX is not set for x32 Andrew Burgess
2024-03-23 16:35     ` [PATCHv3 7/8] gdbserver: update target description creation for x86/linux Andrew Burgess
2024-03-23 16:35     ` [PATCHv3 8/8] gdb/gdbserver: share x86/linux tdesc caching Andrew Burgess
2024-03-26 12:17       ` Andrew Burgess
2024-03-25 17:20     ` [PATCHv3 0/8] x86/Linux Target Description Changes Andrew Burgess
2024-03-25 18:26       ` Simon Marchi
2024-03-26 12:15         ` Andrew Burgess
2024-03-26 13:51           ` H.J. Lu
2024-03-26 14:16             ` H.J. Lu
2024-03-26 16:36       ` Andrew Burgess
2024-03-26 19:03         ` Andrew Burgess
2024-04-05 12:33     ` [PATCHv4 00/10] " Andrew Burgess
2024-04-05 12:33       ` [PATCHv4 01/10] gdbserver/ipa/x86: remove unneeded declarations Andrew Burgess
2024-04-05 12:33       ` [PATCHv4 02/10] gdbserver: convert have_ptrace_getregset to a tribool Andrew Burgess
2024-04-05 12:33       ` [PATCHv4 03/10] gdb/x86: move reading of cs and ds state into gdb/nat directory Andrew Burgess
2024-04-05 12:33       ` [PATCHv4 04/10] gdbserver/x86: move no-xml code earlier in x86_linux_read_description Andrew Burgess
2024-04-05 12:33       ` [PATCHv4 05/10] gdb/gdbserver: share I386_LINUX_XSAVE_XCR0_OFFSET definition Andrew Burgess
2024-04-05 12:33       ` [PATCHv4 06/10] gdb/gdbserver: share some code relating to target description creation Andrew Burgess
2024-04-05 12:33       ` [PATCHv4 07/10] gdb/arch: assert that X86_XSTATE_MPX is not set for x32 Andrew Burgess
2024-04-05 12:33       ` [PATCHv4 08/10] gdbserver: update target description creation for x86/linux Andrew Burgess
2024-04-05 12:33       ` [PATCHv4 09/10] gdb: move xcr0 == 0 check into i386_linux_core_read_description Andrew Burgess
2024-04-05 12:33       ` [PATCHv4 10/10] gdb/gdbserver: share x86/linux tdesc caching Andrew Burgess
2024-04-09 18:37       ` [PATCHv4 00/10] x86/Linux Target Description Changes John Baldwin
2024-04-25 13:35       ` Willgerodt, Felix
2024-04-25 16:06         ` Andrew Burgess
2024-04-26 15:01       ` [PATCHv5 00/11] " Andrew Burgess
2024-04-26 15:01         ` [PATCHv5 01/11] gdbserver/ipa/x86: remove unneeded declarations Andrew Burgess
2024-04-29 14:34           ` Willgerodt, Felix
2024-05-07 15:05             ` Andrew Burgess
2024-05-08  7:49               ` Willgerodt, Felix
2024-04-26 15:01         ` [PATCHv5 02/11] gdbserver: convert have_ptrace_getregset to a tribool Andrew Burgess
2024-04-29 14:34           ` Willgerodt, Felix
2024-05-07 15:28             ` Andrew Burgess
2024-04-26 15:01         ` [PATCHv5 03/11] gdb/x86: move reading of cs and ds state into gdb/nat directory Andrew Burgess
2024-04-29 14:34           ` Willgerodt, Felix
2024-04-26 15:01         ` [PATCHv5 04/11] gdb/x86: move have_ptrace_getfpxregs global " Andrew Burgess
2024-04-29 14:34           ` Willgerodt, Felix
2024-04-26 15:01         ` [PATCHv5 05/11] gdbserver/x86: move no-xml code earlier in x86_linux_read_description Andrew Burgess
2024-04-29 14:34           ` Willgerodt, Felix
2024-05-07 11:55             ` Luis Machado
2024-05-07 15:43               ` Andrew Burgess
2024-05-07 15:56                 ` Luis Machado
2024-05-08  7:49                 ` Willgerodt, Felix
2024-05-08 13:18                   ` Andrew Burgess
2024-04-26 15:01         ` [PATCHv5 06/11] gdb/gdbserver: share I386_LINUX_XSAVE_XCR0_OFFSET definition Andrew Burgess
2024-04-29 14:34           ` Willgerodt, Felix
2024-04-26 15:01         ` [PATCHv5 07/11] gdb/gdbserver: share some code relating to target description creation Andrew Burgess
2024-04-29 14:34           ` Willgerodt, Felix
2024-05-07 11:40             ` Andrew Burgess
2024-04-26 15:01         ` [PATCHv5 08/11] gdb/arch: assert that X86_XSTATE_MPX is not set for x32 Andrew Burgess
2024-04-29 14:34           ` Willgerodt, Felix
2024-05-07 16:08             ` Andrew Burgess
2024-04-26 15:01         ` [PATCHv5 09/11] gdbserver: update target description creation for x86/linux Andrew Burgess
2024-04-29 14:35           ` Willgerodt, Felix
2024-05-07 14:24             ` Andrew Burgess
2024-05-08  7:47               ` Willgerodt, Felix
2024-05-08 13:28                 ` Andrew Burgess
2024-04-26 15:01         ` [PATCHv5 10/11] gdb: move xcr0 == 0 check into i386_linux_core_read_description Andrew Burgess
2024-04-29 14:35           ` Willgerodt, Felix
2024-04-26 15:01         ` [PATCHv5 11/11] gdb/gdbserver: share x86/linux tdesc caching Andrew Burgess
2024-04-29 14:35           ` Willgerodt, Felix
2024-05-07 14:50             ` Andrew Burgess
2024-05-08  7:49               ` Willgerodt, Felix
2024-05-08 16:09                 ` Andrew Burgess
2024-05-08 16:46         ` [PATCHv6 0/9] x86/Linux Target Description Changes Andrew Burgess
2024-05-08 16:46           ` [PATCHv6 1/9] gdb/gdbserver: share I386_LINUX_XSAVE_XCR0_OFFSET definition Andrew Burgess
2024-05-08 16:46           ` [PATCHv6 2/9] gdbserver/x86: move no-xml code earlier in x86_linux_read_description Andrew Burgess
2024-05-08 16:46           ` [PATCHv6 3/9] gdb/x86: move have_ptrace_getfpxregs global into gdb/nat directory Andrew Burgess
2024-05-08 22:52             ` John Baldwin
2024-05-08 16:46           ` [PATCHv6 4/9] gdb/x86: move have_ptrace_getregset " Andrew Burgess
2024-05-08 22:53             ` John Baldwin
2024-05-08 16:46           ` [PATCHv6 5/9] gdb/x86: move reading of cs and ds state " Andrew Burgess
2024-05-08 16:46           ` [PATCHv6 6/9] gdb: move xcr0 == 0 check into i386_linux_core_read_description Andrew Burgess
2024-05-08 22:54             ` John Baldwin
2024-05-08 16:46           ` [PATCHv6 7/9] gdb/gdbserver: share some code relating to target description creation Andrew Burgess
2024-05-08 22:58             ` John Baldwin
2024-05-08 16:46           ` [PATCHv6 8/9] gdbserver: update target description creation for x86/linux Andrew Burgess
2024-05-08 16:46           ` [PATCHv6 9/9] gdb/gdbserver: share x86/linux tdesc caching Andrew Burgess
2024-05-11 10:08           ` [PATCHv7 0/9] x86/Linux Target Description Changes Andrew Burgess
2024-05-11 10:08             ` [PATCHv7 1/9] gdb/gdbserver: share I386_LINUX_XSAVE_XCR0_OFFSET definition Andrew Burgess
2024-05-11 10:08             ` [PATCHv7 2/9] gdbserver/x86: move no-xml code earlier in x86_linux_read_description Andrew Burgess
2024-05-11 10:08             ` [PATCHv7 3/9] gdb/x86: move have_ptrace_getfpxregs global into gdb/nat directory Andrew Burgess
2024-05-11 10:08             ` [PATCHv7 4/9] gdb: move have_ptrace_getregset declaration " Andrew Burgess
2024-05-11 10:08             ` [PATCHv7 5/9] gdb/x86: move reading of cs and ds state " Andrew Burgess
2024-05-11 10:08             ` [PATCHv7 6/9] gdb: move xcr0 == 0 check into i386_linux_core_read_description Andrew Burgess
2024-05-11 10:08             ` [PATCHv7 7/9] gdb/gdbserver: share some code relating to target description creation Andrew Burgess
2024-05-11 10:08             ` [PATCHv7 8/9] gdbserver: update target description creation for x86/linux Andrew Burgess
2024-05-11 10:08             ` [PATCHv7 9/9] gdb/gdbserver: share x86/linux tdesc caching Andrew Burgess

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=add521c466cec9af7893c097f41ff81c3a3117cc.1709657954.git.aburgess@redhat.com \
    --to=aburgess@redhat.com \
    --cc=gdb-patches@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