[PATCHv6 3/9] gdb/x86: move have_ptrace_getfpxregs global into gdb/nat directory
John Baldwin
jhb@FreeBSD.org
Wed May 8 22:52:23 GMT 2024
On 5/8/24 9:46 AM, Andrew Burgess wrote:
> The have_ptrace_getfpxregs global tracks whether GDB or gdbserver is
> running on a kernel that supports the GETFPXREGS ptrace request.
>
> Currently this global is declared twice (once in GDB and once in
> gdbserver), but it makes sense to move this global into the nat/
> directory, and have a single declaration and definition.
>
> While moving this variable I have converted it to a tribool, as that
> was what it really was, if even used the same numbering as the tribool
> enum (-1, 0, 1). Where have_ptrace_getfpxregs was used I have updated
> in the obvious way.
>
> However, while making this change I noticed what I think is a bug in
> x86_linux_nat_target::read_description and x86_linux_read_description,
> both of these functions can be called multiple times, but in both
> cases we only end up calling i386_linux_read_description the first
> time through in the event that PTRACE_GETFPXREGS is not supported.
> This is because initially have_ptrace_getfpxregs will be
> TRIBOOL_UNKNOWN, but after the ptrace call fails we set
> have_ptrace_getfpxregs to TRIBOOL_FALSE. The next time we attempt to
> read the target description we'll skip the ptrace call, and so skip
> the call to i386_linux_read_description.
>
> I've not tried to address this preexisting bug in this commit, this is
> purely a refactor, there should be no user visible changes after this
> commit. In later commits I'll merge the gdbserver and GDB code
> together into the nat/ directory, and after that I'll try to address
> this bug.
>
> Reviewed-By: Felix Willgerodt <felix.willgerodt@intel.com>
> ---
> gdb/Makefile.in | 1 -
> gdb/i386-linux-nat.c | 26 +++++---------------------
> gdb/i386-linux-nat.h | 26 --------------------------
> gdb/nat/x86-linux.c | 9 +++++++++
> gdb/nat/x86-linux.h | 14 ++++++++++++++
> gdb/x86-linux-nat.c | 7 ++-----
> gdbserver/linux-x86-low.cc | 17 +++--------------
> 7 files changed, 33 insertions(+), 67 deletions(-)
> delete mode 100644 gdb/i386-linux-nat.h
>
> diff --git a/gdb/nat/x86-linux.c b/gdb/nat/x86-linux.c
> index 7a21c8f2c26..f394dc5d5e1 100644
> --- a/gdb/nat/x86-linux.c
> +++ b/gdb/nat/x86-linux.c
> @@ -20,6 +20,15 @@
> #include "x86-linux.h"
> #include "x86-linux-dregs.h"
>
> +/* See nat/x86-linux.h. */
> +tribool have_ptrace_getfpxregs =
> +#ifdef HAVE_PTRACE_GETFPXREGS
> + TRIBOOL_UNKNOWN
> +#else
> + TRIBOOL_FALSE
> +#endif
> +;
> +
Should this be under #ifdef __i386__ or the like? My understanding is that
this request isn't supported for Linux x86-64, just for i386?
--
John Baldwin
More information about the Gdb-patches
mailing list