aboutsummaryrefslogtreecommitdiff
path: root/gdb/i386-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/i386-tdep.c
parent5cb0f2d5b67ce2b4f60d5ad0b0a26ef918e8244f (diff)
downloadgdb-911627e7b1bc682a18ac5a976eb33cd87d73578f.zip
gdb-911627e7b1bc682a18ac5a976eb33cd87d73578f.tar.gz
gdb-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/i386-tdep.c')
-rw-r--r--gdb/i386-tdep.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index cc41dd8..dc3cbed 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -3006,7 +3006,8 @@ i386_reg_struct_return_p (struct gdbarch *gdbarch, struct type *type)
if (struct_convention == pcc_struct_convention
|| (struct_convention == default_struct_convention
- && tdep->struct_return == pcc_struct_return))
+ && tdep->struct_return == pcc_struct_return)
+ || TYPE_HAS_DYNAMIC_LENGTH (type))
return 0;
/* Structures consisting of a single `float', `double' or 'long
@@ -3034,13 +3035,6 @@ i386_return_value (struct gdbarch *gdbarch, struct value *function,
{
enum type_code code = type->code ();
- gdb_byte *readbuf = nullptr;
- if (read_value != nullptr)
- {
- *read_value = allocate_value (type);
- readbuf = value_contents_raw (*read_value).data ();
- }
-
if (((code == TYPE_CODE_STRUCT
|| code == TYPE_CODE_UNION
|| code == TYPE_CODE_ARRAY)
@@ -3068,12 +3062,12 @@ i386_return_value (struct gdbarch *gdbarch, struct value *function,
a record, so the convention applied to records also applies
to arrays. */
- if (readbuf)
+ if (read_value != nullptr)
{
ULONGEST addr;
regcache_raw_read_unsigned (regcache, I386_EAX_REGNUM, &addr);
- read_memory (addr, readbuf, type->length ());
+ *read_value = value_at_non_lval (type, addr);
}
return RETURN_VALUE_ABI_RETURNS_ADDRESS;
@@ -3097,8 +3091,12 @@ i386_return_value (struct gdbarch *gdbarch, struct value *function,
return result;
}
- if (readbuf)
- i386_extract_return_value (gdbarch, type, regcache, readbuf);
+ if (read_value != nullptr)
+ {
+ *read_value = allocate_value (type);
+ i386_extract_return_value (gdbarch, type, regcache,
+ value_contents_raw (*read_value).data ());
+ }
if (writebuf)
i386_store_return_value (gdbarch, type, regcache, writebuf);