aboutsummaryrefslogtreecommitdiff
path: root/gdb/infcmd.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2022-09-07 08:39:52 -0600
committerTom Tromey <tromey@adacore.com>2023-01-03 08:45:00 -0700
commit4e1d2f5814b29048d1dd1cea2cb50570e6c8f1f8 (patch)
treec5b684d3cad8e726247e58566b9d293ece12b756 /gdb/infcmd.c
parent862ebb27bbe30768356776a10827dd1c0824d405 (diff)
downloadgdb-4e1d2f5814b29048d1dd1cea2cb50570e6c8f1f8.zip
gdb-4e1d2f5814b29048d1dd1cea2cb50570e6c8f1f8.tar.gz
gdb-4e1d2f5814b29048d1dd1cea2cb50570e6c8f1f8.tar.bz2
Add new overload of gdbarch_return_value
The gdbarch "return_value" can't correctly handle variably-sized types. The problem here is that the TYPE_LENGTH of such a type is 0, until the type is resolved, which requires reading memory. However, gdbarch_return_value only accepts a buffer as an out parameter. Fixing this requires letting the implementation of the gdbarch method resolve the type and return a value -- that is, both the contents and the new type. After an attempt at this, I realized I wouldn't be able to correctly update all implementations (there are ~80) of this method. So, instead, this patch adds a new method that falls back to the current method, and it updates gdb to only call the new method. This way it's possible to incrementally convert the architectures that I am able to test.
Diffstat (limited to 'gdb/infcmd.c')
-rw-r--r--gdb/infcmd.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 0c1765d..0497ad0 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -1497,15 +1497,14 @@ get_return_value (struct symbol *func_symbol, struct value *function)
inferior function call code. In fact, when inferior function
calls are made async, this will likely be made the norm. */
- switch (gdbarch_return_value (gdbarch, function, value_type,
- nullptr, nullptr, nullptr))
+ switch (gdbarch_return_value_as_value (gdbarch, function, value_type,
+ nullptr, nullptr, nullptr))
{
case RETURN_VALUE_REGISTER_CONVENTION:
case RETURN_VALUE_ABI_RETURNS_ADDRESS:
case RETURN_VALUE_ABI_PRESERVES_ADDRESS:
- value = allocate_value (value_type);
- gdbarch_return_value (gdbarch, function, value_type, stop_regs,
- value_contents_raw (value).data (), nullptr);
+ gdbarch_return_value_as_value (gdbarch, function, value_type, stop_regs,
+ &value, nullptr);
break;
case RETURN_VALUE_STRUCT_CONVENTION:
value = nullptr;
@@ -1889,10 +1888,11 @@ finish_command (const char *arg, int from_tty)
struct type * val_type
= check_typedef (sm->function->type ()->target_type ());
- return_value = gdbarch_return_value (gdbarch,
- read_var_value (sm->function, nullptr,
- callee_frame),
- val_type, nullptr, nullptr, nullptr);
+ return_value
+ = gdbarch_return_value_as_value (gdbarch,
+ read_var_value (sm->function, nullptr,
+ callee_frame),
+ val_type, nullptr, nullptr, nullptr);
if (return_value == RETURN_VALUE_STRUCT_CONVENTION
&& val_type->code () != TYPE_CODE_VOID)