From: Carl Love Date: Mon, 14 Nov 2022 21:22:11 +0000 (-0500) Subject: PowerPC, function ppc64_sysv_abi_return_value add missing return value convention X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=24b27e5e9b6bf5a37fb39dfca151722bb801cbaa;p=binutils-gdb.git PowerPC, function ppc64_sysv_abi_return_value add missing return value convention This patch address five testcase failures in gdb.cp/non-trivial-retval.exp. The following commit resulted in the five testcases failures on PowerPC. The value returned by the function is being reported incorrectly. commit b1718fcdd1d2a5c514f8ee504ba07fb3f42b8608 Author: Andrew Burgess Date: Mon Dec 13 16:56:16 2021 +0000 gdb: on x86-64 non-trivial C++ objects are returned in memory Fixes PR gdb/28681. It was observed that after using the `finish` command an incorrect value was displayed in some cases. Specifically, this behaviour was observed on an x86-64 target. The function: enum return_value_convention ppc64_sysv_abi_return_value (struct gdbarch *gdbarch, struct value *function, struct type *valtype, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf) should return RETURN_VALUE_STRUCT_CONVENTION if the valtype->code() is TYPE_CODE_STRUCT and if the language_pass_by_reference is not trivially_copyable. This patch adds the needed code to return the value RETURN_VALUE_STRUCT_CONVENTION in this case. With this patch, the five test cases still fail but with the message "Value returned has type: A. Cannot determine contents". The PowerPC ABI stores the address of the buffer containing the function return value in register r3 on entry to the function. However, the PowerPC ABI does not guarentee that r3 will not be modified in the function. So when the function returns, the return buffer address cannot be reliably obtained from register r3. Thus the message "Cannot determine contents" is appropriate in this case. --- diff --git a/gdb/ppc-sysv-tdep.c b/gdb/ppc-sysv-tdep.c index d7f05ddc6b4..450162dd46e 100644 --- a/gdb/ppc-sysv-tdep.c +++ b/gdb/ppc-sysv-tdep.c @@ -2099,6 +2099,10 @@ ppc64_sysv_abi_return_value (struct gdbarch *gdbarch, struct value *function, return RETURN_VALUE_REGISTER_CONVENTION; } + if (!language_pass_by_reference (valtype).trivially_copyable + && valtype->code () == TYPE_CODE_STRUCT) + return RETURN_VALUE_STRUCT_CONVENTION; + /* In the ELFv2 ABI, aggregate types of up to 16 bytes are returned in registers r3:r4. */ if (tdep->elf_abi == POWERPC_ELF_V2