aboutsummaryrefslogtreecommitdiff
path: root/gdbserver/linux-x86-low.cc
diff options
context:
space:
mode:
authorAndrew Burgess <aburgess@redhat.com>2024-04-26 14:24:40 +0100
committerAndrew Burgess <aburgess@redhat.com>2024-06-14 09:08:45 +0100
commit18d4886c009aaa4fa26bf440ae57fbdd14acce11 (patch)
tree1d276143b7523576f299b3873d75953575b9013b /gdbserver/linux-x86-low.cc
parent3d5394c501de9a8b1fdc11e73feb04f61c3c2eec (diff)
downloadbinutils-18d4886c009aaa4fa26bf440ae57fbdd14acce11.zip
binutils-18d4886c009aaa4fa26bf440ae57fbdd14acce11.tar.gz
binutils-18d4886c009aaa4fa26bf440ae57fbdd14acce11.tar.bz2
gdb/x86: move have_ptrace_getfpxregs global into gdb/nat directory
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), I think 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>
Diffstat (limited to 'gdbserver/linux-x86-low.cc')
-rw-r--r--gdbserver/linux-x86-low.cc19
1 files changed, 5 insertions, 14 deletions
diff --git a/gdbserver/linux-x86-low.cc b/gdbserver/linux-x86-low.cc
index e8ef366..2d99a82 100644
--- a/gdbserver/linux-x86-low.cc
+++ b/gdbserver/linux-x86-low.cc
@@ -29,6 +29,8 @@
#ifdef __x86_64__
#include "nat/amd64-linux-siginfo.h"
+#else
+#include "nat/i386-linux.h"
#endif
#include "gdb_proc_service.h"
@@ -831,17 +833,6 @@ x86_target::low_siginfo_fixup (siginfo_t *ptrace, gdb_byte *inf, int direction)
static int use_xml;
-/* Does the current host support the GETFPXREGS request? The header
- file may or may not define it, and even if it is defined, the
- kernel will return EIO if it's running on a pre-SSE processor. */
-int have_ptrace_getfpxregs =
-#ifdef HAVE_PTRACE_GETFPXREGS
- -1
-#else
- 0
-#endif
-;
-
/* Get Linux/x86 target description from running target. */
static const struct target_desc *
@@ -886,18 +877,18 @@ x86_linux_read_description (void)
}
#if !defined __x86_64__ && defined HAVE_PTRACE_GETFPXREGS
- if (machine == EM_386 && have_ptrace_getfpxregs == -1)
+ if (machine == EM_386 && have_ptrace_getfpxregs == TRIBOOL_UNKNOWN)
{
elf_fpxregset_t fpxregs;
if (ptrace (PTRACE_GETFPXREGS, tid, 0, (long) &fpxregs) < 0)
{
- have_ptrace_getfpxregs = 0;
+ have_ptrace_getfpxregs = TRIBOOL_FALSE;
have_ptrace_getregset = TRIBOOL_FALSE;
return i386_linux_read_description (X86_XSTATE_X87);
}
else
- have_ptrace_getfpxregs = 1;
+ have_ptrace_getfpxregs = TRIBOOL_TRUE;
}
#endif