summaryrefslogtreecommitdiff
path: root/gdb/amd64-windows-tdep.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2022-09-07 09:52:44 -0600
committerTom Tromey <tromey@adacore.com>2023-01-03 08:45:01 -0700
commit911627e7b1bc682a18ac5a976eb33cd87d73578f (patch)
treeac38675ac49e0aede201b82f8f193cff20658915 /gdb/amd64-windows-tdep.c
parent5cb0f2d5b67ce2b4f60d5ad0b0a26ef918e8244f (diff)
downloadbinutils-gdb-911627e7b1bc682a18ac5a976eb33cd87d73578f.tar.gz
Fix inferior calls with variably-sized return type
This patch updates the gdbarch_return_value_as_value implementations to work correctly with variably-sized return types.
Diffstat (limited to 'gdb/amd64-windows-tdep.c')
-rw-r--r--gdb/amd64-windows-tdep.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/gdb/amd64-windows-tdep.c b/gdb/amd64-windows-tdep.c
index 6f7dbaa7002..411a6204a90 100644
--- a/gdb/amd64-windows-tdep.c
+++ b/gdb/amd64-windows-tdep.c
@@ -360,13 +360,6 @@ amd64_windows_return_value (struct gdbarch *gdbarch, struct value *function,
int len = type->length ();
int regnum = -1;
- gdb_byte *readbuf = nullptr;
- if (read_value != nullptr)
- {
- *read_value = allocate_value (type);
- readbuf = value_contents_raw (*read_value).data ();
- }
-
/* See if our value is returned through a register. If it is, then
store the associated register number in REGNUM. */
switch (type->code ())
@@ -401,20 +394,24 @@ amd64_windows_return_value (struct gdbarch *gdbarch, struct value *function,
if (regnum < 0)
{
/* RAX contains the address where the return value has been stored. */
- if (readbuf)
+ if (read_value != nullptr)
{
ULONGEST addr;
regcache_raw_read_unsigned (regcache, AMD64_RAX_REGNUM, &addr);
- read_memory (addr, readbuf, type->length ());
+ *read_value = value_at_non_lval (type, addr);
}
return RETURN_VALUE_ABI_RETURNS_ADDRESS;
}
else
{
/* Extract the return value from the register where it was stored. */
- if (readbuf)
- regcache->raw_read_part (regnum, 0, len, readbuf);
+ if (read_value != nullptr)
+ {
+ *read_value = allocate_value (type);
+ regcache->raw_read_part (regnum, 0, len,
+ value_contents_raw (*read_value).data ());
+ }
if (writebuf)
regcache->raw_write_part (regnum, 0, len, writebuf);
return RETURN_VALUE_REGISTER_CONVENTION;