aboutsummaryrefslogtreecommitdiff
path: root/gdb/amd64-linux-nat.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/amd64-linux-nat.c')
-rw-r--r--gdb/amd64-linux-nat.c33
1 files changed, 16 insertions, 17 deletions
diff --git a/gdb/amd64-linux-nat.c b/gdb/amd64-linux-nat.c
index aa9295d..dbb9b32 100644
--- a/gdb/amd64-linux-nat.c
+++ b/gdb/amd64-linux-nat.c
@@ -1,6 +1,6 @@
/* Native-dependent code for GNU/Linux x86-64.
- Copyright (C) 2001-2024 Free Software Foundation, Inc.
+ Copyright (C) 2001-2025 Free Software Foundation, Inc.
Contributed by Jiri Smid, SuSE Labs.
This file is part of GDB.
@@ -79,6 +79,8 @@ static int amd64_linux_gregset32_reg_offset[] =
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
+ /* MPX is deprecated. Yet we keep this to not give the registers below
+ a new number. That could break older gdbservers. */
-1, -1, -1, -1, /* MPX registers BND0 ... BND3. */
-1, -1, /* MPX registers BNDCFGU, BNDSTATUS. */
-1, -1, -1, -1, -1, -1, -1, -1, /* k0 ... k7 (AVX512) */
@@ -88,7 +90,7 @@ static int amd64_linux_gregset32_reg_offset[] =
};
-/* Transfering the general-purpose registers between GDB, inferiors
+/* Transferring the general-purpose registers between GDB, inferiors
and core files. */
/* See amd64_collect_native_gregset. This linux specific version handles
@@ -176,7 +178,7 @@ fill_gregset (const struct regcache *regcache,
amd64_linux_collect_native_gregset (regcache, gregsetp, regnum);
}
-/* Transfering floating-point registers between GDB, inferiors and cores. */
+/* Transferring floating-point registers between GDB, inferiors and cores. */
/* Fill GDB's register cache with the floating-point and SSE register
values in *FPREGSETP. */
@@ -235,22 +237,21 @@ amd64_linux_nat_target::fetch_registers (struct regcache *regcache, int regnum)
if (have_ptrace_getregset == TRIBOOL_TRUE)
{
- char xstateregs[tdep->xsave_layout.sizeof_xsave];
- struct iovec iov;
-
/* Pre-4.14 kernels have a bug (fixed by commit 0852b374173b
"x86/fpu: Add FPU state copying quirk to handle XRSTOR failure on
Intel Skylake CPUs") that sometimes causes the mxcsr location in
xstateregs not to be copied by PTRACE_GETREGSET. Make sure that
the location is at least initialized with a defined value. */
- memset (xstateregs, 0, sizeof (xstateregs));
- iov.iov_base = xstateregs;
- iov.iov_len = sizeof (xstateregs);
+ gdb::byte_vector xstateregs (tdep->xsave_layout.sizeof_xsave, 0);
+ struct iovec iov;
+
+ iov.iov_base = xstateregs.data ();
+ iov.iov_len = xstateregs.size ();
if (ptrace (PTRACE_GETREGSET, tid,
(unsigned int) NT_X86_XSTATE, (long) &iov) < 0)
perror_with_name (_("Couldn't get extended state status"));
- amd64_supply_xsave (regcache, -1, xstateregs);
+ amd64_supply_xsave (regcache, -1, xstateregs.data ());
}
else
{
@@ -300,16 +301,16 @@ amd64_linux_nat_target::store_registers (struct regcache *regcache, int regnum)
if (have_ptrace_getregset == TRIBOOL_TRUE)
{
- char xstateregs[tdep->xsave_layout.sizeof_xsave];
+ gdb::byte_vector xstateregs (tdep->xsave_layout.sizeof_xsave);
struct iovec iov;
- iov.iov_base = xstateregs;
- iov.iov_len = sizeof (xstateregs);
+ iov.iov_base = xstateregs.data ();
+ iov.iov_len = xstateregs.size ();
if (ptrace (PTRACE_GETREGSET, tid,
(unsigned int) NT_X86_XSTATE, (long) &iov) < 0)
perror_with_name (_("Couldn't get extended state status"));
- amd64_collect_xsave (regcache, regnum, xstateregs, 0);
+ amd64_collect_xsave (regcache, regnum, xstateregs.data (), 0);
if (ptrace (PTRACE_SETREGSET, tid,
(unsigned int) NT_X86_XSTATE, (long) &iov) < 0)
@@ -423,9 +424,7 @@ amd64_linux_nat_target::low_siginfo_fixup (siginfo_t *ptrace,
return false;
}
-void _initialize_amd64_linux_nat ();
-void
-_initialize_amd64_linux_nat ()
+INIT_GDB_FILE (amd64_linux_nat)
{
amd64_native_gregset32_reg_offset = amd64_linux_gregset32_reg_offset;
amd64_native_gregset32_num_regs = I386_LINUX_NUM_REGS;