diff options
author | Simon Marchi <simon.marchi@efficios.com> | 2024-07-31 14:06:12 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2024-08-02 16:54:25 -0400 |
commit | d724d71ad22b9d4b8e659d9c44cce8b724f4f7f5 (patch) | |
tree | 0f976ca65d4bb650f182b3c3e24aa0876b06a1c6 /gdb/amd64-linux-nat.c | |
parent | 6ce1ea97af20b9e618c524aa719e70c17dacda74 (diff) | |
download | gdb-d724d71ad22b9d4b8e659d9c44cce8b724f4f7f5.zip gdb-d724d71ad22b9d4b8e659d9c44cce8b724f4f7f5.tar.gz gdb-d724d71ad22b9d4b8e659d9c44cce8b724f4f7f5.tar.bz2 |
gdb: remove uses of VLA
Remove uses of VLAs, replace with gdb::byte_vector. There might be more
in files that I can't compile, but it's difficult to tell without
actually compiling on all platforms.
Many thanks to the Linaro pre-commit CI for helping find some problems
with an earlier iteration of this patch.
Change-Id: I3e5e34fcac51f3e6b732bb801c77944e010b162e
Reviewed-by: Keith Seitz <keiths@redhat.com>
Diffstat (limited to 'gdb/amd64-linux-nat.c')
-rw-r--r-- | gdb/amd64-linux-nat.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/gdb/amd64-linux-nat.c b/gdb/amd64-linux-nat.c index aa9295d..823c1f7 100644 --- a/gdb/amd64-linux-nat.c +++ b/gdb/amd64-linux-nat.c @@ -235,22 +235,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 +299,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) |