aboutsummaryrefslogtreecommitdiff
path: root/gdb/sparc-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/sparc-tdep.c
parent5cb0f2d5b67ce2b4f60d5ad0b0a26ef918e8244f (diff)
downloadbinutils-911627e7b1bc682a18ac5a976eb33cd87d73578f.zip
binutils-911627e7b1bc682a18ac5a976eb33cd87d73578f.tar.gz
binutils-911627e7b1bc682a18ac5a976eb33cd87d73578f.tar.bz2
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/sparc-tdep.c')
-rw-r--r--gdb/sparc-tdep.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c
index 91cf391..55c8434 100644
--- a/gdb/sparc-tdep.c
+++ b/gdb/sparc-tdep.c
@@ -1500,13 +1500,6 @@ sparc32_return_value (struct gdbarch *gdbarch, struct value *function,
{
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
- gdb_byte *readbuf = nullptr;
- if (read_value != nullptr)
- {
- *read_value = allocate_value (type);
- readbuf = value_contents_raw (*read_value).data ();
- }
-
/* The psABI says that "...every stack frame reserves the word at
%fp+64. If a function returns a structure, union, or
quad-precision value, this word should hold the address of the
@@ -1519,11 +1512,11 @@ sparc32_return_value (struct gdbarch *gdbarch, struct value *function,
ULONGEST sp;
CORE_ADDR addr;
- if (readbuf)
+ if (read_value != nullptr)
{
regcache_cooked_read_unsigned (regcache, SPARC_SP_REGNUM, &sp);
addr = read_memory_unsigned_integer (sp + 64, 4, byte_order);
- read_memory (addr, readbuf, type->length ());
+ *read_value = value_at_non_lval (type, addr);
}
if (writebuf)
{
@@ -1535,8 +1528,12 @@ sparc32_return_value (struct gdbarch *gdbarch, struct value *function,
return RETURN_VALUE_ABI_PRESERVES_ADDRESS;
}
- if (readbuf)
- sparc32_extract_return_value (type, regcache, readbuf);
+ if (read_value != nullptr)
+ {
+ *read_value = allocate_value (type);
+ gdb_byte *readbuf = value_contents_raw (*read_value).data ();
+ sparc32_extract_return_value (type, regcache, readbuf);
+ }
if (writebuf)
sparc32_store_return_value (type, regcache, writebuf);