aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2024-11-22 13:43:03 +0100
committerTom de Vries <tdevries@suse.de>2024-11-22 13:43:03 +0100
commit00386b4c6826d92700710fc8144e3522fcec44d3 (patch)
treede88927aba1983cc95eb277535307ef1e4964271 /gdb
parent2e61ad32abe8b8f89ba899fe9eff7856bee74cce (diff)
downloadbinutils-00386b4c6826d92700710fc8144e3522fcec44d3.zip
binutils-00386b4c6826d92700710fc8144e3522fcec44d3.tar.gz
binutils-00386b4c6826d92700710fc8144e3522fcec44d3.tar.bz2
[gdb/tdep] Simplify amd64_windows_store_arg_in_reg
Simplify amd64_windows_store_arg_in_reg by: - replacing memset with value initialization, - making valbuf a gdb::array_view, allowing us to: - replace memcpy with std::copy, and - use valbuf.size () instead of arg->type->size (), and - dropping the std::min in std::min (type->length (), (ULONGEST) 8), since we're already asserting that type->length () <= 8. Suggested-By: Tom Tromey <tom@tromey.com> Tested by rebuilding on x86_64-linux.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/amd64-windows-tdep.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/gdb/amd64-windows-tdep.c b/gdb/amd64-windows-tdep.c
index df59a44..e3e815e 100644
--- a/gdb/amd64-windows-tdep.c
+++ b/gdb/amd64-windows-tdep.c
@@ -205,14 +205,12 @@ static void
amd64_windows_store_arg_in_reg (struct regcache *regcache,
struct value *arg, int regno)
{
- struct type *type = arg->type ();
- const gdb_byte *valbuf = arg->contents ().data ();
+ gdb::array_view<const gdb_byte> valbuf = arg->contents ();
/* We only set 8 bytes, buf if it's a XMM register, 16 bytes are read. */
- std::array<gdb_byte, 16> buf;
+ std::array<gdb_byte, 16> buf {};
- gdb_assert (type->length () <= 8);
- memset (buf.data (), 0, buf.size ());
- memcpy (buf.data (), valbuf, std::min (type->length (), (ULONGEST) 8));
+ gdb_assert (valbuf.size () <= 8);
+ std::copy (valbuf.begin (), valbuf.end (), buf.begin ());
size_t reg_size = regcache_register_size (regcache, regno);
gdb_assert (reg_size <= buf.size ());
gdb::array_view<gdb_byte> view (buf);