From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1726) id 2DA813858D1E; Tue, 7 May 2024 15:27:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2DA813858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1715095625; bh=hG3ThhQKho05UGIniSryy4f9V70cLyyE1ARUfBnH3E8=; h=From:To:Subject:Date:From; b=LoAn3/xi3huRWOiYLyxUQ+tEN/R3/TSlcqFiDwKsX+Mgr7cwH2r8RBp3Iyp8+Q7M5 32aVzotFWnB9O7DgA9pHVhfeLCxjc2E9olndXfuE1WOfYFl2n158lJbCGobyWDx7CP k5ak1MPXRpYThA+yZSSJToCM4wH4x7ycECT4rads= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Andrew Burgess To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdbserver: convert have_ptrace_getregset to a tribool X-Act-Checkin: binutils-gdb X-Git-Author: Andrew Burgess X-Git-Refname: refs/heads/master X-Git-Oldrev: 3f1438a5b2ef4a6b2bd3cc0600033362c43de7b3 X-Git-Newrev: 0c58b372e07fe81d23e4fcf6d6cfee8394e8bce5 Message-Id: <20240507152705.2DA813858D1E@sourceware.org> Date: Tue, 7 May 2024 15:27:05 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D0c58b372e07f= e81d23e4fcf6d6cfee8394e8bce5 commit 0c58b372e07fe81d23e4fcf6d6cfee8394e8bce5 Author: Andrew Burgess Date: Thu Jan 25 14:10:42 2024 +0000 gdbserver: convert have_ptrace_getregset to a tribool =20 Convert the have_ptrace_getregset global within gdbserver to a tribool. This brings the flag into alignment with the corresponding flag in GDB. =20 The gdbserver have_ptrace_getregset variable is already used as a tribool, it just doesn't have the tribool type. =20 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. =20 There should be no user visible changes after this commit. =20 Approved-By: John Baldwin Reviewed-By: Felix Willgerodt Diff: --- 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(-) 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 () =20 /* Check if PTRACE_GETREGSET works. */ if (ptrace (PTRACE_GETREGSET, tid, NT_PRSTATUS, &iov) =3D=3D 0) - have_ptrace_getregset =3D 1; + have_ptrace_getregset =3D TRIBOOL_TRUE; else - have_ptrace_getregset =3D 0; + have_ptrace_getregset =3D TRIBOOL_FALSE; } =20 bool @@ -1121,7 +1121,7 @@ arm_target::get_regs_info () { const struct target_desc *tdesc =3D current_process ()->tdesc; =20 - if (have_ptrace_getregset =3D=3D 1 + if (have_ptrace_getregset =3D=3D TRIBOOL_TRUE && (is_aarch32_linux_description (tdesc) || arm_linux_get_tdesc_fp_type (tdesc) =3D=3D ARM_FP_TYPE_VFPV3)) return ®s_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 =20 /* Does the current host support PTRACE_GETREGSET? */ -int have_ptrace_getregset =3D -1; +enum tribool have_ptrace_getregset =3D TRIBOOL_UNKNOWN; =20 /* Return TRUE if THREAD is the leader thread of the process. */ =20 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); =20 bool thread_db_thread_handle (ptid_t ptid, gdb_byte **handle, int *handle_= len); =20 -extern int have_ptrace_getregset; +extern enum tribool have_ptrace_getregset; =20 /* 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 =3D 0; - have_ptrace_getregset =3D 0; + have_ptrace_getregset =3D 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 (); } =20 - if (have_ptrace_getregset =3D=3D -1) + if (have_ptrace_getregset =3D=3D 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 =3D 0; + have_ptrace_getregset =3D TRIBOOL_FALSE; else { - have_ptrace_getregset =3D 1; + have_ptrace_getregset =3D TRIBOOL_TRUE; =20 /* Get XCR0 from XSAVE extended state. */ xcr0 =3D xstateregs[(I386_LINUX_XSAVE_XCR0_OFFSET @@ -954,7 +954,7 @@ x86_linux_read_description (void) } =20 /* Check the native XCR0 only if PTRACE_GETREGSET is available. */ - xcr0_features =3D (have_ptrace_getregset + xcr0_features =3D (have_ptrace_getregset =3D=3D TRIBOOL_TRUE && (xcr0 & X86_XSTATE_ALL_MASK)); =20 if (xcr0_features)