]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdbserver: convert have_ptrace_getregset to a tribool
authorAndrew Burgess <aburgess@redhat.com>
Thu, 25 Jan 2024 14:10:42 +0000 (14:10 +0000)
committerAndrew Burgess <aburgess@redhat.com>
Mon, 25 Mar 2024 17:14:18 +0000 (17:14 +0000)
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
gdbserver/linux-low.cc
gdbserver/linux-low.h
gdbserver/linux-x86-low.cc

index 396ec88081b902db7559df0e6df05a3af74deced..b4f0e071c922b709819f8bd2ad7629500795c756 100644 (file)
@@ -1007,9 +1007,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
@@ -1122,7 +1122,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;
index 9d5a624280346537074d212268280f0663ff7ebe..dfa26d451b07f720d61deec09beb9164724b621d 100644 (file)
@@ -135,7 +135,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.  */
 
index d34d27382389bcf3e12824061bac9054a580e744..eaf875273386e83c8dbb48a5d745f3b1d626a019 100644 (file)
@@ -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
index 933d1fb012a1637e00c685f570f9f8634b18519e..04202e355bb44db37d2cd71f1086538f18d881b2 100644 (file)
@@ -899,7 +899,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
@@ -918,7 +918,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;
@@ -929,10 +929,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
@@ -955,7 +955,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)