public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/3] Assume PT_GETXMMREGS is always present on *BSD/i386
@ 2022-02-28 22:35 John Baldwin
  2022-02-28 22:35 ` [PATCH 1/3] i386-fbsd-nat: Assume PT_GETXMMREGS is present John Baldwin
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: John Baldwin @ 2022-02-28 22:35 UTC (permalink / raw)
  To: gdb-patches

All of the BSD operating systems have included support for the XMM
register set for SSE since at least mid 2006.  This patch series
assumes it is present to reduce #ifdef's and remove a
no-longer-necessary configure check.

John Baldwin (3):
  i386-fbsd-nat: Assume PT_GETXMMREGS is present.
  i386-bsd-nat: Assume PT_GETXMMREGS is present.
  configure: Stop checking for PT_GETXMMREGS.

 gdb/configure       | 37 -------------------------------------
 gdb/configure.ac    | 20 --------------------
 gdb/i386-bsd-nat.c  | 10 ----------
 gdb/i386-fbsd-nat.c | 14 --------------
 4 files changed, 81 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/3] i386-fbsd-nat: Assume PT_GETXMMREGS is present.
  2022-02-28 22:35 [PATCH 0/3] Assume PT_GETXMMREGS is always present on *BSD/i386 John Baldwin
@ 2022-02-28 22:35 ` John Baldwin
  2022-03-01 14:22   ` Simon Marchi
  2022-02-28 22:35 ` [PATCH 2/3] i386-bsd-nat: " John Baldwin
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: John Baldwin @ 2022-02-28 22:35 UTC (permalink / raw)
  To: gdb-patches

PT_GETXMMREGS was first added in FreeBSD 6.0 released in November 2005.
The last FreeBSD release without support was 5.5 released in May 2006.
---
 gdb/i386-fbsd-nat.c | 14 --------------
 1 file changed, 14 deletions(-)

diff --git a/gdb/i386-fbsd-nat.c b/gdb/i386-fbsd-nat.c
index 6fb67434a2d..a6ced66250c 100644
--- a/gdb/i386-fbsd-nat.c
+++ b/gdb/i386-fbsd-nat.c
@@ -42,9 +42,7 @@ class i386_fbsd_nat_target final
   void fetch_registers (struct regcache *, int) override;
   void store_registers (struct regcache *, int) override;
 
-#if defined(PT_GETXMMREGS) || defined(PT_GETXSTATE_INFO)
   const struct target_desc *read_description () override;
-#endif
 
   void resume (ptid_t, int, enum gdb_signal) override;
 
@@ -59,9 +57,7 @@ static i386_fbsd_nat_target the_i386_fbsd_nat_target;
 static size_t xsave_len;
 #endif
 
-#ifdef HAVE_PT_GETXMMREGS
 static int have_ptrace_xmmregs;
-#endif
 
 /* Fetch register REGNUM from the inferior.  If REGNUM is -1, do this
    for all registers.  */
@@ -126,7 +122,6 @@ i386_fbsd_nat_target::fetch_registers (struct regcache *regcache, int regnum)
       return;
     }
 #endif
-#ifdef HAVE_PT_GETXMMREGS
   if (have_ptrace_xmmregs != 0)
     {
       char xmmregs[I387_SIZEOF_FXSAVE];
@@ -137,7 +132,6 @@ i386_fbsd_nat_target::fetch_registers (struct regcache *regcache, int regnum)
       i387_supply_fxsave (regcache, regnum, xmmregs);
       return;
     }
-#endif
 
   struct fpreg fpregs;
 
@@ -214,7 +208,6 @@ i386_fbsd_nat_target::store_registers (struct regcache *regcache, int regnum)
       return;
     }
 #endif
-#ifdef HAVE_PT_GETXMMREGS
   if (have_ptrace_xmmregs != 0)
     {
       char xmmregs[I387_SIZEOF_FXSAVE];
@@ -228,7 +221,6 @@ i386_fbsd_nat_target::store_registers (struct regcache *regcache, int regnum)
 	perror_with_name (_("Couldn't write XMM registers"));
       return;
     }
-#endif
 
   struct fpreg fpregs;
 
@@ -324,7 +316,6 @@ i386fbsd_supply_pcb (struct regcache *regcache, struct pcb *pcb)
 }
 \f
 
-#if defined(PT_GETXMMREGS) || defined(PT_GETXSTATE_INFO)
 /* Implement the read_description method.  */
 
 const struct target_desc *
@@ -334,9 +325,7 @@ i386_fbsd_nat_target::read_description ()
   static int xsave_probed;
   static uint64_t xcr0;
 #endif
-#ifdef PT_GETXMMREGS
   static int xmm_probed;
-#endif
 
 #ifdef PT_GETXSTATE_INFO
   if (!xsave_probed)
@@ -356,7 +345,6 @@ i386_fbsd_nat_target::read_description ()
     return i386_target_description (xcr0, true);
 #endif
 
-#ifdef PT_GETXMMREGS
   if (!xmm_probed)
     {
       char xmmregs[I387_SIZEOF_FXSAVE];
@@ -369,11 +357,9 @@ i386_fbsd_nat_target::read_description ()
 
   if (have_ptrace_xmmregs)
     return i386_target_description (X86_XSTATE_SSE_MASK, true);
-#endif
 
   return i386_target_description (X86_XSTATE_X87_MASK, true);
 }
-#endif
 
 #if defined(HAVE_PT_GETDBREGS) && defined(USE_SIGTRAP_SIGINFO)
 /* Implement the supports_stopped_by_hw_breakpoints method.  */
-- 
2.34.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 2/3] i386-bsd-nat: Assume PT_GETXMMREGS is present.
  2022-02-28 22:35 [PATCH 0/3] Assume PT_GETXMMREGS is always present on *BSD/i386 John Baldwin
  2022-02-28 22:35 ` [PATCH 1/3] i386-fbsd-nat: Assume PT_GETXMMREGS is present John Baldwin
@ 2022-02-28 22:35 ` John Baldwin
  2022-02-28 22:35 ` [PATCH 3/3] configure: Stop checking for PT_GETXMMREGS John Baldwin
  2022-03-01 20:48 ` [PATCH 0/3] Assume PT_GETXMMREGS is always present on *BSD/i386 Tom Tromey
  3 siblings, 0 replies; 7+ messages in thread
From: John Baldwin @ 2022-02-28 22:35 UTC (permalink / raw)
  To: gdb-patches

NetBSD has included PT_GETXMMREGS since 1.6 released in September
2002.  OpenBSD has included PT_GETXMMREGS since 3.8 released in
November 2005.
---
 gdb/i386-bsd-nat.c | 10 ----------
 1 file changed, 10 deletions(-)

diff --git a/gdb/i386-bsd-nat.c b/gdb/i386-bsd-nat.c
index bd9655c9ef9..97a9738c52b 100644
--- a/gdb/i386-bsd-nat.c
+++ b/gdb/i386-bsd-nat.c
@@ -92,11 +92,9 @@ static int i386bsd_r_reg_offset[] =
 #define GETREGS_SUPPLIES(regnum) \
   ((0 <= (regnum) && (regnum) <= 15))
 
-#ifdef HAVE_PT_GETXMMREGS
 /* Set to 1 if the kernel supports PT_GETXMMREGS.  Initialized to -1
    so that we try PT_GETXMMREGS the first time around.  */
 static int have_ptrace_xmmregs = -1;
-#endif
 \f
 
 /* Supply the general-purpose registers in GREGS, to REGCACHE.  */
@@ -162,7 +160,6 @@ i386bsd_fetch_inferior_registers (struct regcache *regcache, int regnum)
   if (regnum == -1 || regnum >= I386_ST0_REGNUM)
     {
       struct fpreg fpregs;
-#ifdef HAVE_PT_GETXMMREGS
       char xmmregs[512];
 
       if (have_ptrace_xmmregs != 0
@@ -175,15 +172,12 @@ i386bsd_fetch_inferior_registers (struct regcache *regcache, int regnum)
       else
 	{
 	  have_ptrace_xmmregs = 0;
-#endif
 	  if (gdb_ptrace (PT_GETFPREGS, ptid,
 			  (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
 	    perror_with_name (_("Couldn't get floating point status"));
 
 	  i387_supply_fsave (regcache, -1, &fpregs);
-#ifdef HAVE_PT_GETXMMREGS
 	}
-#endif
     }
 }
 
@@ -214,7 +208,6 @@ i386bsd_store_inferior_registers (struct regcache *regcache, int regnum)
   if (regnum == -1 || regnum >= I386_ST0_REGNUM)
     {
       struct fpreg fpregs;
-#ifdef HAVE_PT_GETXMMREGS
       char xmmregs[512];
 
       if (have_ptrace_xmmregs != 0
@@ -232,7 +225,6 @@ i386bsd_store_inferior_registers (struct regcache *regcache, int regnum)
       else
 	{
 	  have_ptrace_xmmregs = 0;
-#endif
 	  if (gdb_ptrace (PT_GETFPREGS, ptid,
 			  (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
 	    perror_with_name (_("Couldn't get floating point status"));
@@ -242,9 +234,7 @@ i386bsd_store_inferior_registers (struct regcache *regcache, int regnum)
 	  if (gdb_ptrace (PT_SETFPREGS, ptid,
 			  (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
 	    perror_with_name (_("Couldn't write floating point status"));
-#ifdef HAVE_PT_GETXMMREGS
 	}
-#endif
     }
 }
 
-- 
2.34.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 3/3] configure: Stop checking for PT_GETXMMREGS.
  2022-02-28 22:35 [PATCH 0/3] Assume PT_GETXMMREGS is always present on *BSD/i386 John Baldwin
  2022-02-28 22:35 ` [PATCH 1/3] i386-fbsd-nat: Assume PT_GETXMMREGS is present John Baldwin
  2022-02-28 22:35 ` [PATCH 2/3] i386-bsd-nat: " John Baldwin
@ 2022-02-28 22:35 ` John Baldwin
  2022-03-01 20:48 ` [PATCH 0/3] Assume PT_GETXMMREGS is always present on *BSD/i386 Tom Tromey
  3 siblings, 0 replies; 7+ messages in thread
From: John Baldwin @ 2022-02-28 22:35 UTC (permalink / raw)
  To: gdb-patches

This request is present on all modern *BSD/i386 systems (those
released since mid-2006), and the *BSD/i386 targets now assume it is
present unconditionally.
---
 gdb/configure    | 37 -------------------------------------
 gdb/configure.ac | 20 --------------------
 2 files changed, 57 deletions(-)

diff --git a/gdb/configure b/gdb/configure
index 425bdb08a73..b34baff13be 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -16245,43 +16245,6 @@ $as_echo "#define HAVE_PT_GETDBREGS 1" >>confdefs.h
 
 fi
 
-# See if <sys/ptrace.h> provides the PT_GETXMMREGS request.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for PT_GETXMMREGS" >&5
-$as_echo_n "checking for PT_GETXMMREGS... " >&6; }
-if ${gdb_cv_have_pt_getxmmregs+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <sys/types.h>
-	 #include <sys/ptrace.h>
-int
-main ()
-{
-PT_GETXMMREGS;
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  gdb_cv_have_pt_getxmmregs=yes
-else
-  gdb_cv_have_pt_getxmmregs=no
-
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-
-fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gdb_cv_have_pt_getxmmregs" >&5
-$as_echo "$gdb_cv_have_pt_getxmmregs" >&6; }
-if test "$gdb_cv_have_pt_getxmmregs" = yes; then
-
-$as_echo "#define HAVE_PT_GETXMMREGS 1" >>confdefs.h
-
-fi
-
 # See if <sys/ptrace.h> supports LWP names on FreeBSD
 # Older FreeBSD versions don't have the pl_tdname member of
 # `struct ptrace_lwpinfo'.
diff --git a/gdb/configure.ac b/gdb/configure.ac
index c6fa19b20bc..bc8925ddd69 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -1486,26 +1486,6 @@ if test "$gdb_cv_have_pt_getdbregs" = yes; then
   [Define if sys/ptrace.h defines the PT_GETDBREGS request.])
 fi
 
-# See if <sys/ptrace.h> provides the PT_GETXMMREGS request.
-AC_MSG_CHECKING(for PT_GETXMMREGS)
-AC_CACHE_VAL(
-  [gdb_cv_have_pt_getxmmregs],
-  [AC_COMPILE_IFELSE(
-     [AC_LANG_PROGRAM(
-	[#include <sys/types.h>
-	 #include <sys/ptrace.h>],
-	[PT_GETXMMREGS;]
-      )],
-     [gdb_cv_have_pt_getxmmregs=yes],
-     [gdb_cv_have_pt_getxmmregs=no]
-   )]
-)
-AC_MSG_RESULT($gdb_cv_have_pt_getxmmregs)
-if test "$gdb_cv_have_pt_getxmmregs" = yes; then
-  AC_DEFINE(HAVE_PT_GETXMMREGS, 1,
-  [Define if sys/ptrace.h defines the PT_GETXMMREGS request.])
-fi
-
 # See if <sys/ptrace.h> supports LWP names on FreeBSD
 # Older FreeBSD versions don't have the pl_tdname member of
 # `struct ptrace_lwpinfo'.
-- 
2.34.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/3] i386-fbsd-nat: Assume PT_GETXMMREGS is present.
  2022-02-28 22:35 ` [PATCH 1/3] i386-fbsd-nat: Assume PT_GETXMMREGS is present John Baldwin
@ 2022-03-01 14:22   ` Simon Marchi
  2022-03-01 18:25     ` John Baldwin
  0 siblings, 1 reply; 7+ messages in thread
From: Simon Marchi @ 2022-03-01 14:22 UTC (permalink / raw)
  To: John Baldwin, gdb-patches



On 2022-02-28 17:35, John Baldwin wrote:
> PT_GETXMMREGS was first added in FreeBSD 6.0 released in November 2005.
> The last FreeBSD release without support was 5.5 released in May 2006.
> ---
>  gdb/i386-fbsd-nat.c | 14 --------------
>  1 file changed, 14 deletions(-)
> 
> diff --git a/gdb/i386-fbsd-nat.c b/gdb/i386-fbsd-nat.c
> index 6fb67434a2d..a6ced66250c 100644
> --- a/gdb/i386-fbsd-nat.c
> +++ b/gdb/i386-fbsd-nat.c
> @@ -42,9 +42,7 @@ class i386_fbsd_nat_target final
>    void fetch_registers (struct regcache *, int) override;
>    void store_registers (struct regcache *, int) override;
>  
> -#if defined(PT_GETXMMREGS) || defined(PT_GETXSTATE_INFO)
>    const struct target_desc *read_description () override;
> -#endif
>  
>    void resume (ptid_t, int, enum gdb_signal) override;
>  
> @@ -59,9 +57,7 @@ static i386_fbsd_nat_target the_i386_fbsd_nat_target;
>  static size_t xsave_len;
>  #endif
>  
> -#ifdef HAVE_PT_GETXMMREGS
>  static int have_ptrace_xmmregs;

Is this variable (have_ptrace_xmmregs) still relevant?  In other words,
can the PT_GETXMMREGS request legitimately fail?

Simon

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/3] i386-fbsd-nat: Assume PT_GETXMMREGS is present.
  2022-03-01 14:22   ` Simon Marchi
@ 2022-03-01 18:25     ` John Baldwin
  0 siblings, 0 replies; 7+ messages in thread
From: John Baldwin @ 2022-03-01 18:25 UTC (permalink / raw)
  To: Simon Marchi, gdb-patches

On 3/1/22 6:22 AM, Simon Marchi wrote:
> 
> 
> On 2022-02-28 17:35, John Baldwin wrote:
>> PT_GETXMMREGS was first added in FreeBSD 6.0 released in November 2005.
>> The last FreeBSD release without support was 5.5 released in May 2006.
>> ---
>>   gdb/i386-fbsd-nat.c | 14 --------------
>>   1 file changed, 14 deletions(-)
>>
>> diff --git a/gdb/i386-fbsd-nat.c b/gdb/i386-fbsd-nat.c
>> index 6fb67434a2d..a6ced66250c 100644
>> --- a/gdb/i386-fbsd-nat.c
>> +++ b/gdb/i386-fbsd-nat.c
>> @@ -42,9 +42,7 @@ class i386_fbsd_nat_target final
>>     void fetch_registers (struct regcache *, int) override;
>>     void store_registers (struct regcache *, int) override;
>>   
>> -#if defined(PT_GETXMMREGS) || defined(PT_GETXSTATE_INFO)
>>     const struct target_desc *read_description () override;
>> -#endif
>>   
>>     void resume (ptid_t, int, enum gdb_signal) override;
>>   
>> @@ -59,9 +57,7 @@ static i386_fbsd_nat_target the_i386_fbsd_nat_target;
>>   static size_t xsave_len;
>>   #endif
>>   
>> -#ifdef HAVE_PT_GETXMMREGS
>>   static int have_ptrace_xmmregs;
> 
> Is this variable (have_ptrace_xmmregs) still relevant?  In other words,
> can the PT_GETXMMREGS request legitimately fail?

Yes, while the ptrace op always exists, it only works if the running CPU supports
SSE (and this is true in i386-bsd-nat.c as well).  Granted, the number of systems
running modern BSD operating systems on a CPU that doesn't include SSE support
(think Pentium or Pentium Pro class CPUs) may be vanishingly small to the point
of zero.

-- 
John Baldwin

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/3] Assume PT_GETXMMREGS is always present on *BSD/i386
  2022-02-28 22:35 [PATCH 0/3] Assume PT_GETXMMREGS is always present on *BSD/i386 John Baldwin
                   ` (2 preceding siblings ...)
  2022-02-28 22:35 ` [PATCH 3/3] configure: Stop checking for PT_GETXMMREGS John Baldwin
@ 2022-03-01 20:48 ` Tom Tromey
  3 siblings, 0 replies; 7+ messages in thread
From: Tom Tromey @ 2022-03-01 20:48 UTC (permalink / raw)
  To: John Baldwin; +Cc: gdb-patches

>>>>> "John" == John Baldwin <jhb@FreeBSD.org> writes:

John> All of the BSD operating systems have included support for the XMM
John> register set for SSE since at least mid 2006.  This patch series
John> assumes it is present to reduce #ifdef's and remove a
John> no-longer-necessary configure check.

FWIW, I skimmed these and they all seem fine to me.

Tom

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-03-01 20:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-28 22:35 [PATCH 0/3] Assume PT_GETXMMREGS is always present on *BSD/i386 John Baldwin
2022-02-28 22:35 ` [PATCH 1/3] i386-fbsd-nat: Assume PT_GETXMMREGS is present John Baldwin
2022-03-01 14:22   ` Simon Marchi
2022-03-01 18:25     ` John Baldwin
2022-02-28 22:35 ` [PATCH 2/3] i386-bsd-nat: " John Baldwin
2022-02-28 22:35 ` [PATCH 3/3] configure: Stop checking for PT_GETXMMREGS John Baldwin
2022-03-01 20:48 ` [PATCH 0/3] Assume PT_GETXMMREGS is always present on *BSD/i386 Tom Tromey

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).