[PATCHv5,02/11] gdbserver: convert have_ptrace_getregset to a tribool

Message ID 461c1ea75f7149b8d4ef431085cb7dbc0f9bd6b2.1714143669.git.aburgess@redhat.com
State New
Headers
Series x86/Linux Target Description Changes |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Testing passed

Commit Message

Andrew Burgess April 26, 2024, 3:01 p.m. UTC
  Convert the have_ptrace_getregset global within gdbserver to a
tribool.  This brings the flag into alignment with the corresponding
flag in GDB.

The gdbserver have_ptrace_getregset variable is already used as a
tribool, it just doesn't have the tribool type.

In a future commit I plan to share more code between GDB and
gdbserver, and having this variable be the same type in both code
bases will make the sharing much easier.

There should be no user visible changes after this commit.

Approved-By: John Baldwin <jhb@FreeBSD.org>
---
 gdbserver/linux-arm-low.cc |  6 +++---
 gdbserver/linux-low.cc     |  2 +-
 gdbserver/linux-low.h      |  2 +-
 gdbserver/linux-x86-low.cc | 10 +++++-----
 4 files changed, 10 insertions(+), 10 deletions(-)
  

Comments

Willgerodt, Felix April 29, 2024, 2:34 p.m. UTC | #1
> -----Original Message-----
> From: Andrew Burgess <aburgess@redhat.com>
> Sent: Freitag, 26. April 2024 17:02
> To: gdb-patches@sourceware.org
> Cc: Andrew Burgess <aburgess@redhat.com>; Willgerodt, Felix
> <felix.willgerodt@intel.com>; John Baldwin <jhb@FreeBSD.org>
> Subject: [PATCHv5 02/11] gdbserver: convert have_ptrace_getregset to a tribool
> 
> Convert the have_ptrace_getregset global within gdbserver to a
> tribool.  This brings the flag into alignment with the corresponding
> flag in GDB.
> 
> The gdbserver have_ptrace_getregset variable is already used as a
> tribool, it just doesn't have the tribool type.
> 
> In a future commit I plan to share more code between GDB and
> gdbserver, and having this variable be the same type in both code
> bases will make the sharing much easier.
> 
> There should be no user visible changes after this commit.
> 
> Approved-By: John Baldwin <jhb@FreeBSD.org>
> ---
>  gdbserver/linux-arm-low.cc |  6 +++---
>  gdbserver/linux-low.cc     |  2 +-
>  gdbserver/linux-low.h      |  2 +-
>  gdbserver/linux-x86-low.cc | 10 +++++-----
>  4 files changed, 10 insertions(+), 10 deletions(-)


Reviewed-By: Felix Willgerodt <felix.willgerodt@intel.com>

Looks fine to me, x86 parts are approved.

Thanks,
Felix
Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva  
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
  
Andrew Burgess May 7, 2024, 3:28 p.m. UTC | #2
"Willgerodt, Felix" <felix.willgerodt@intel.com> writes:

>> -----Original Message-----
>> From: Andrew Burgess <aburgess@redhat.com>
>> Sent: Freitag, 26. April 2024 17:02
>> To: gdb-patches@sourceware.org
>> Cc: Andrew Burgess <aburgess@redhat.com>; Willgerodt, Felix
>> <felix.willgerodt@intel.com>; John Baldwin <jhb@FreeBSD.org>
>> Subject: [PATCHv5 02/11] gdbserver: convert have_ptrace_getregset to a tribool
>> 
>> Convert the have_ptrace_getregset global within gdbserver to a
>> tribool.  This brings the flag into alignment with the corresponding
>> flag in GDB.
>> 
>> The gdbserver have_ptrace_getregset variable is already used as a
>> tribool, it just doesn't have the tribool type.
>> 
>> In a future commit I plan to share more code between GDB and
>> gdbserver, and having this variable be the same type in both code
>> bases will make the sharing much easier.
>> 
>> There should be no user visible changes after this commit.
>> 
>> Approved-By: John Baldwin <jhb@FreeBSD.org>
>> ---
>>  gdbserver/linux-arm-low.cc |  6 +++---
>>  gdbserver/linux-low.cc     |  2 +-
>>  gdbserver/linux-low.h      |  2 +-
>>  gdbserver/linux-x86-low.cc | 10 +++++-----
>>  4 files changed, 10 insertions(+), 10 deletions(-)
>
>
> Reviewed-By: Felix Willgerodt <felix.willgerodt@intel.com>
>
> Looks fine to me, x86 parts are approved.

I've also pushed this patch from this series as it's only loosely
related to the rest of the series.

Thanks,
Andrew
  

Patch

diff --git a/gdbserver/linux-arm-low.cc b/gdbserver/linux-arm-low.cc
index 17b64c09aff..eec4649b235 100644
--- a/gdbserver/linux-arm-low.cc
+++ b/gdbserver/linux-arm-low.cc
@@ -1006,9 +1006,9 @@  arm_target::low_arch_setup ()
 
   /* Check if PTRACE_GETREGSET works.  */
   if (ptrace (PTRACE_GETREGSET, tid, NT_PRSTATUS, &iov) == 0)
-    have_ptrace_getregset = 1;
+    have_ptrace_getregset = TRIBOOL_TRUE;
   else
-    have_ptrace_getregset = 0;
+    have_ptrace_getregset = TRIBOOL_FALSE;
 }
 
 bool
@@ -1121,7 +1121,7 @@  arm_target::get_regs_info ()
 {
   const struct target_desc *tdesc = current_process ()->tdesc;
 
-  if (have_ptrace_getregset == 1
+  if (have_ptrace_getregset == TRIBOOL_TRUE
       && (is_aarch32_linux_description (tdesc)
 	  || arm_linux_get_tdesc_fp_type (tdesc) == ARM_FP_TYPE_VFPV3))
     return &regs_info_aarch32;
diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 9614cd7150c..ac7f9807ecc 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -134,7 +134,7 @@  typedef struct
 #endif
 
 /* Does the current host support PTRACE_GETREGSET?  */
-int have_ptrace_getregset = -1;
+enum tribool have_ptrace_getregset = TRIBOOL_UNKNOWN;
 
 /* Return TRUE if THREAD is the leader thread of the process.  */
 
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index d34d2738238..eaf87527338 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -951,7 +951,7 @@  void thread_db_notice_clone (struct thread_info *parent_thr, ptid_t child_ptid);
 
 bool thread_db_thread_handle (ptid_t ptid, gdb_byte **handle, int *handle_len);
 
-extern int have_ptrace_getregset;
+extern enum tribool have_ptrace_getregset;
 
 /* Search for the value with type MATCH in the auxv vector, with entries of
    length WORDSIZE bytes, of process with pid PID.  If found, store the
diff --git a/gdbserver/linux-x86-low.cc b/gdbserver/linux-x86-low.cc
index 2532603451a..2603fb2ac5d 100644
--- a/gdbserver/linux-x86-low.cc
+++ b/gdbserver/linux-x86-low.cc
@@ -898,7 +898,7 @@  x86_linux_read_description (void)
       if (ptrace (PTRACE_GETFPXREGS, tid, 0, (long) &fpxregs) < 0)
 	{
 	  have_ptrace_getfpxregs = 0;
-	  have_ptrace_getregset = 0;
+	  have_ptrace_getregset = TRIBOOL_FALSE;
 	  return i386_linux_read_description (X86_XSTATE_X87);
 	}
       else
@@ -917,7 +917,7 @@  x86_linux_read_description (void)
 	return tdesc_i386_linux_no_xml.get ();
     }
 
-  if (have_ptrace_getregset == -1)
+  if (have_ptrace_getregset == TRIBOOL_UNKNOWN)
     {
       uint64_t xstateregs[(X86_XSTATE_SSE_SIZE / sizeof (uint64_t))];
       struct iovec iov;
@@ -928,10 +928,10 @@  x86_linux_read_description (void)
       /* Check if PTRACE_GETREGSET works.  */
       if (ptrace (PTRACE_GETREGSET, tid,
 		  (unsigned int) NT_X86_XSTATE, (long) &iov) < 0)
-	have_ptrace_getregset = 0;
+	have_ptrace_getregset = TRIBOOL_FALSE;
       else
 	{
-	  have_ptrace_getregset = 1;
+	  have_ptrace_getregset = TRIBOOL_TRUE;
 
 	  /* Get XCR0 from XSAVE extended state.  */
 	  xcr0 = xstateregs[(I386_LINUX_XSAVE_XCR0_OFFSET
@@ -954,7 +954,7 @@  x86_linux_read_description (void)
     }
 
   /* Check the native XCR0 only if PTRACE_GETREGSET is available.  */
-  xcr0_features = (have_ptrace_getregset
+  xcr0_features = (have_ptrace_getregset == TRIBOOL_TRUE
 		   && (xcr0 & X86_XSTATE_ALL_MASK));
 
   if (xcr0_features)