[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.
This commit is contained in:
Tom de Vries
2024-11-22 13:43:03 +01:00
parent 2e61ad32ab
commit 00386b4c68

View File

@@ -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);