aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbarch-gen.h
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/gdbarch-gen.h
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/gdbarch-gen.h')
-rw-r--r--gdb/gdbarch-gen.h21
1 files changed, 19 insertions, 2 deletions
diff --git a/gdb/gdbarch-gen.h b/gdb/gdbarch-gen.h
index c2299dc..128efa1 100644
--- a/gdb/gdbarch-gen.h
+++ b/gdb/gdbarch-gen.h
@@ -433,14 +433,31 @@ extern void set_gdbarch_integer_to_address (struct gdbarch *gdbarch, gdbarch_int
If WRITEBUF is not NULL, it contains a return value which will be
stored into the appropriate register. This can be used when we want
to force the value returned by a function (see the "return" command
- for instance). */
+ for instance).
-extern bool gdbarch_return_value_p (struct gdbarch *gdbarch);
+ NOTE: it is better to implement return_value_as_value instead, as that
+ method can properly handle variably-sized types. */
typedef enum return_value_convention (gdbarch_return_value_ftype) (struct gdbarch *gdbarch, struct value *function, struct type *valtype, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf);
extern 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);
extern void set_gdbarch_return_value (struct gdbarch *gdbarch, gdbarch_return_value_ftype *return_value);
+/* Return the return-value convention that will be used by FUNCTION
+ to return a value of type VALTYPE. FUNCTION may be NULL in which
+ case the return convention is computed based only on VALTYPE.
+
+ If READ_VALUE is not NULL, extract the return value and save it in
+ this pointer.
+
+ If WRITEBUF is not NULL, it contains a return value which will be
+ stored into the appropriate register. This can be used when we want
+ to force the value returned by a function (see the "return" command
+ for instance). */
+
+typedef enum return_value_convention (gdbarch_return_value_as_value_ftype) (struct gdbarch *gdbarch, struct value *function, struct type *valtype, struct regcache *regcache, struct value **read_value, const gdb_byte *writebuf);
+extern 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);
+extern void set_gdbarch_return_value_as_value (struct gdbarch *gdbarch, gdbarch_return_value_as_value_ftype *return_value_as_value);
+
/* Return the address at which the value being returned from
the current function will be stored. This routine is only
called if the current function uses the the "struct return