From fbdecfbf285234cd4eba0e7daf480c63b2d65eb3 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Tue, 21 Feb 2023 13:49:17 -0700 Subject: [PATCH] Use entry values for 32-bit PPC struct return AdaCore has a local patch for PPC "finish", but last year, Ulrich Weigand pointed out that this patch was incorrect. It may work for simple functions like the one in the internal test, but nothing guarantees that r3 will be preserved by the callee, so checking r3 on exit is not always correct. This patch fixes the problem using the same approach as PPC64: use the entry value of r3, if available. Ulrich confirmed this matches the PPC32 ABI. --- gdb/ppc-sysv-tdep.c | 3 +-- gdb/ppc-tdep.h | 4 +++- gdb/rs6000-tdep.c | 3 +-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gdb/ppc-sysv-tdep.c b/gdb/ppc-sysv-tdep.c index ab859fbe143..66630793e86 100644 --- a/gdb/ppc-sysv-tdep.c +++ b/gdb/ppc-sysv-tdep.c @@ -2159,8 +2159,7 @@ ppc64_sysv_abi_return_value (struct gdbarch *gdbarch, struct value *function, } CORE_ADDR -ppc64_sysv_get_return_buf_addr (struct type *val_type, - frame_info_ptr cur_frame) +ppc_sysv_get_return_buf_addr (struct type *val_type, frame_info_ptr cur_frame) { /* The PowerPC ABI specifies aggregates that are not returned by value are returned in a storage buffer provided by the caller. The diff --git a/gdb/ppc-tdep.h b/gdb/ppc-tdep.h index db4e53205a6..ddeb810f35b 100644 --- a/gdb/ppc-tdep.h +++ b/gdb/ppc-tdep.h @@ -175,7 +175,9 @@ extern void ppc_collect_vsxregset (const struct regset *regset, const struct regcache *regcache, int regnum, void *vsxregs, size_t len); -extern CORE_ADDR ppc64_sysv_get_return_buf_addr (type*, frame_info_ptr); +/* Implementation of the gdbarch get_return_buf_addr hook. */ + +extern CORE_ADDR ppc_sysv_get_return_buf_addr (type*, frame_info_ptr); /* Private data that this module attaches to struct gdbarch. */ diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c index ee18b495d4c..966b75b8baa 100644 --- a/gdb/rs6000-tdep.c +++ b/gdb/rs6000-tdep.c @@ -8273,12 +8273,11 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) if (wordsize == 8) { set_gdbarch_return_value (gdbarch, ppc64_sysv_abi_return_value); - set_gdbarch_get_return_buf_addr (gdbarch, - ppc64_sysv_get_return_buf_addr); set_gdbarch_update_call_site_pc (gdbarch, ppc64_update_call_site_pc); } else set_gdbarch_return_value (gdbarch, ppc_sysv_abi_return_value); + set_gdbarch_get_return_buf_addr (gdbarch, ppc_sysv_get_return_buf_addr); /* Set lr_frame_offset. */ if (wordsize == 8) -- 2.30.2