From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1983) id 591303858D32; Mon, 14 Nov 2022 21:23:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 591303858D32 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1668461023; bh=+NaJJ2mA9s06oIT+psEmsz+ZD9A8VugRVaexuaG1E9o=; h=From:To:Subject:Date:From; b=Tq2iS5SRS4ZqvUzhf2tu0a7SMHI9AkRRU7GxC8gs3tuZeUAqBTeuhPr7TXxsowWmt sI+itrMNMsFebT8gEf+g/FkSJ4Lg7lM70MUXvD96FCgH5IAVZy/XHWlG4v0MYoabSr m0htTlAca9zeCaymLgOO5ERYU8Ff+f1nEfoXAUX4= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Carl Love To: gdb-cvs@sourceware.org Subject: [binutils-gdb] PowerPC, function ppc64_sysv_abi_return_value add missing return value convention X-Act-Checkin: binutils-gdb X-Git-Author: Carl Love X-Git-Refname: refs/heads/master X-Git-Oldrev: 197073104337f2d2ce8353334b4125e61b8217c5 X-Git-Newrev: 24b27e5e9b6bf5a37fb39dfca151722bb801cbaa Message-Id: <20221114212343.591303858D32@sourceware.org> Date: Mon, 14 Nov 2022 21:23:43 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D24b27e5e9b6b= f5a37fb39dfca151722bb801cbaa commit 24b27e5e9b6bf5a37fb39dfca151722bb801cbaa Author: Carl Love Date: Mon Nov 14 16:22:11 2022 -0500 PowerPC, function ppc64_sysv_abi_return_value add missing return value = convention =20 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. =20 commit b1718fcdd1d2a5c514f8ee504ba07fb3f42b8608 Author: Andrew Burgess Date: Mon Dec 13 16:56:16 2021 +0000 =20 gdb: on x86-64 non-trivial C++ objects are returned in memory =20 Fixes PR gdb/28681. It was observed that after using the `finish` command an incorrect value was displayed in some cases. Specific= ally, this behaviour was observed on an x86-64 target. =20 The function: =20 enum return_value_convention ppc64_sysv_abi_return_value (struct gdbarch *gdbarch, struct value *f= unction, struct type *valtype, struct regcache *r= egcache, gdb_byte *readbuf, const gdb_byte *write= buf) =20 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. =20 This patch adds the needed code to return the value RETURN_VALUE_STRUCT_CONVENTION in this case. =20 With this patch, the five test cases still fail but with the message "V= alue returned has type: A. Cannot determine contents". The PowerPC ABI stor= es the address of the buffer containing the function return value in regis= ter r3 on entry to the function. However, the PowerPC ABI does not guarent= ee that r3 will not be modified in the function. So when the function ret= urns, the return buffer address cannot be reliably obtained from register r3. Thus the message "Cannot determine contents" is appropriate in this cas= e. Diff: --- gdb/ppc-sysv-tdep.c | 4 ++++ 1 file changed, 4 insertions(+) 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; } =20 + if (!language_pass_by_reference (valtype).trivially_copyable + && valtype->code () =3D=3D 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 =3D=3D POWERPC_ELF_V2