mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-26 17:18:55 +00:00
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:
@@ -116,6 +116,7 @@ struct gdbarch
|
||||
gdbarch_address_to_pointer_ftype *address_to_pointer = unsigned_address_to_pointer;
|
||||
gdbarch_integer_to_address_ftype *integer_to_address = nullptr;
|
||||
gdbarch_return_value_ftype *return_value = nullptr;
|
||||
gdbarch_return_value_as_value_ftype *return_value_as_value = default_gdbarch_return_value;
|
||||
gdbarch_get_return_buf_addr_ftype *get_return_buf_addr = default_get_return_buf_addr;
|
||||
gdbarch_return_in_first_hidden_param_p_ftype *return_in_first_hidden_param_p = default_return_in_first_hidden_param_p;
|
||||
gdbarch_skip_prologue_ftype *skip_prologue = 0;
|
||||
@@ -369,7 +370,9 @@ verify_gdbarch (struct gdbarch *gdbarch)
|
||||
/* Skip verify of pointer_to_address, invalid_p == 0 */
|
||||
/* Skip verify of address_to_pointer, invalid_p == 0 */
|
||||
/* Skip verify of integer_to_address, has predicate. */
|
||||
/* Skip verify of return_value, has predicate. */
|
||||
/* Skip verify of return_value, invalid_p == 0 */
|
||||
if ((gdbarch->return_value_as_value == default_gdbarch_return_value) == (gdbarch->return_value == nullptr))
|
||||
log.puts ("\n\treturn_value_as_value");
|
||||
/* Skip verify of get_return_buf_addr, invalid_p == 0 */
|
||||
/* Skip verify of return_in_first_hidden_param_p, invalid_p == 0 */
|
||||
if (gdbarch->skip_prologue == 0)
|
||||
@@ -776,12 +779,12 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
|
||||
gdb_printf (file,
|
||||
"gdbarch_dump: integer_to_address = <%s>\n",
|
||||
host_address_to_string (gdbarch->integer_to_address));
|
||||
gdb_printf (file,
|
||||
"gdbarch_dump: gdbarch_return_value_p() = %d\n",
|
||||
gdbarch_return_value_p (gdbarch));
|
||||
gdb_printf (file,
|
||||
"gdbarch_dump: return_value = <%s>\n",
|
||||
host_address_to_string (gdbarch->return_value));
|
||||
gdb_printf (file,
|
||||
"gdbarch_dump: return_value_as_value = <%s>\n",
|
||||
host_address_to_string (gdbarch->return_value_as_value));
|
||||
gdb_printf (file,
|
||||
"gdbarch_dump: get_return_buf_addr = <%s>\n",
|
||||
host_address_to_string (gdbarch->get_return_buf_addr));
|
||||
@@ -2568,13 +2571,6 @@ set_gdbarch_integer_to_address (struct gdbarch *gdbarch,
|
||||
gdbarch->integer_to_address = integer_to_address;
|
||||
}
|
||||
|
||||
bool
|
||||
gdbarch_return_value_p (struct gdbarch *gdbarch)
|
||||
{
|
||||
gdb_assert (gdbarch != NULL);
|
||||
return gdbarch->return_value != NULL;
|
||||
}
|
||||
|
||||
enum return_value_convention
|
||||
gdbarch_return_value (struct gdbarch *gdbarch, struct value *function, struct type *valtype, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf)
|
||||
{
|
||||
@@ -2592,6 +2588,23 @@ set_gdbarch_return_value (struct gdbarch *gdbarch,
|
||||
gdbarch->return_value = return_value;
|
||||
}
|
||||
|
||||
enum return_value_convention
|
||||
gdbarch_return_value_as_value (struct gdbarch *gdbarch, struct value *function, struct type *valtype, struct regcache *regcache, struct value **read_value, const gdb_byte *writebuf)
|
||||
{
|
||||
gdb_assert (gdbarch != NULL);
|
||||
gdb_assert (gdbarch->return_value_as_value != NULL);
|
||||
if (gdbarch_debug >= 2)
|
||||
gdb_printf (gdb_stdlog, "gdbarch_return_value_as_value called\n");
|
||||
return gdbarch->return_value_as_value (gdbarch, function, valtype, regcache, read_value, writebuf);
|
||||
}
|
||||
|
||||
void
|
||||
set_gdbarch_return_value_as_value (struct gdbarch *gdbarch,
|
||||
gdbarch_return_value_as_value_ftype return_value_as_value)
|
||||
{
|
||||
gdbarch->return_value_as_value = return_value_as_value;
|
||||
}
|
||||
|
||||
CORE_ADDR
|
||||
gdbarch_get_return_buf_addr (struct gdbarch *gdbarch, struct type *val_type, frame_info_ptr cur_frame)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user