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.
This commit is contained in:
Tom Tromey
2022-09-07 08:39:52 -06:00
parent 862ebb27bb
commit 4e1d2f5814
10 changed files with 121 additions and 35 deletions

View File

@ -2838,9 +2838,10 @@ return_command (const char *retval_exp, int from_tty)
gdb_assert (rv_conv != RETURN_VALUE_STRUCT_CONVENTION
&& rv_conv != RETURN_VALUE_ABI_RETURNS_ADDRESS);
gdbarch_return_value (cache_arch, function, return_type,
get_current_regcache (), NULL /*read*/,
value_contents (return_value).data () /*write*/);
gdbarch_return_value_as_value
(cache_arch, function, return_type,
get_current_regcache (), NULL /*read*/,
value_contents (return_value).data () /*write*/);
}
/* If we are at the end of a call dummy now, pop the dummy frame