From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id 520D03858D3C for ; Mon, 7 Nov 2022 20:04:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 520D03858D3C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=us.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=us.ibm.com Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2A7I1jEu008288 for ; Mon, 7 Nov 2022 20:04:55 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : subject : from : to : cc : date : in-reply-to : references : content-type : mime-version : content-transfer-encoding; s=pp1; bh=Z1fji9TuPW6NyE1PM9LzhtR2mjFAM6PEa8imwtMmk8s=; b=TSXvO+Rzok9aiyeGuVlTbnwHFuNDF4M1g8Rlppgw/O48cPY8WhBJJOln0NXFW4JWf1hn URmMhh9To1dsxNrP7PNGQNDbrQrY15w13RZdfMVSb0gklJHxUMnMjl2NcvDJsqhjN+Rk d2BvcwSjFEuzP+fnRAd2EfP9KpVplgsbXwBY8N6Njws2s439b79dZrRWza7GZvcl3Wx/ WTqSqfr2IPeNWsrK37A/3kk476vJHPHEnt/BSWi8OKxlYHfuIdXRnU98/Iz2ys3J8qE3 3u2KZ+XcEkw7uVYTpwXDOE3nXR05nMbwW5Z31+S92JAWrCiThVBjNFTYVDVAcz2qqeYP 3w== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3kq6x7k44j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 07 Nov 2022 20:04:55 +0000 Received: from m0098404.ppops.net (m0098404.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 2A7JjLvH015970 for ; Mon, 7 Nov 2022 20:04:55 GMT Received: from ppma02wdc.us.ibm.com (aa.5b.37a9.ip4.static.sl-reverse.com [169.55.91.170]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3kq6x7k43e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 07 Nov 2022 20:04:55 +0000 Received: from pps.filterd (ppma02wdc.us.ibm.com [127.0.0.1]) by ppma02wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2A7Jo67X001684; Mon, 7 Nov 2022 20:04:53 GMT Received: from b03cxnp08026.gho.boulder.ibm.com (b03cxnp08026.gho.boulder.ibm.com [9.17.130.18]) by ppma02wdc.us.ibm.com with ESMTP id 3kngnehv2y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 07 Nov 2022 20:04:53 +0000 Received: from smtpav05.dal12v.mail.ibm.com ([9.208.128.132]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2A7K4ujU7930372 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 7 Nov 2022 20:04:56 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EA61D58067; Mon, 7 Nov 2022 20:04:51 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 708E25804C; Mon, 7 Nov 2022 20:04:51 +0000 (GMT) Received: from li-e362e14c-2378-11b2-a85c-87d605f3c641.ibm.com (unknown [9.163.10.231]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Mon, 7 Nov 2022 20:04:51 +0000 (GMT) Message-ID: Subject: Re: [PATCH 1/2 ver 3] PowerPC, function ppc64_sysv_abi_return_value add missing return value convention From: Carl Love To: Ulrich Weigand , "gdb-patches@sourceware.org" Cc: "will_schmidt@vnet.ibm.com" , blarsen@redhat.com, Kevin Buettner , cel@us.ibm.com Date: Mon, 07 Nov 2022 12:04:51 -0800 In-Reply-To: References: <28ce795ca489f69829207b2a7a535cf7f77f6dd8.camel@us.ibm.com> <87a6dslkip.fsf@tromey.com> <49c0eb4ef5a984b42f3a9e89faa8001a87ecb3ba.camel@de.ibm.com> <6ca2276426343756e103995e07ff951d6e26837b.camel@us.ibm.com> <939797b94ab71f3f7356747d84a1515939cb3dcc.camel@de.ibm.com> <1edb818bd2873a3fa5278f28131089d228a0a4f6.camel@de.ibm.com> <7c884a865d06890cb325225c65d7a52fdfbd20d2.camel@us.ibm.com> <846ca96309d2732d3db0e4c323a81105c098fa5f.camel@de.ibm.com> <5a858dd7b957ecf45cf5b00ffc140a839c8ef023.camel@us.ibm.com> <25f2380ced176f58a8e3ea9b70c7e7786988d650.camel@us.ibm.com> <2b0481466e9ecc33d52c74c3a3b4babb05435f47.camel@de.ibm.com> <71370ce02bd57827d3b7958772b1594d3591bd16.camel@de.ibm.com> <148d8d3efcc8d110119e566027bfd0c65dd02525.camel@de.ibm.com> <8decd662134d57e8caf43960a1cdc47723e2bfe3.camel@us.ibm.com> <79d82ed277308ed5ce312bff398e770ab234390a.camel@us.ibm.com> <63f21a897f452d81a73fb386cb99110a359ef0b7.camel@de.ibm.com> <97275f61ef101a12cde8e5a45008ed8e479424eb.camel@us.ibm.com> <5a34aaeab59f0099b915d1780c701284a6cf691e.camel@us.ibm.com> <8aa882863b2f4cef38c22386387c5705bf63c3d5.camel@de.ibm.com> <56392545859f7e949ee1b8fa2198f3928f714bad.camel@us.ibm.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5 (3.28.5-18.el8) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: S3-l-9BLQ_sJTdZhLZODkAYFhLPQpWlI X-Proofpoint-GUID: kefEwauVNa18T-zkHMrHC-NvCr8gCZ03 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-07_11,2022-11-07_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 clxscore=1015 impostorscore=0 mlxlogscore=999 priorityscore=1501 mlxscore=0 bulkscore=0 lowpriorityscore=0 phishscore=0 malwarescore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211070158 X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Ping on this patch. I have not received any additional comments on the patch. I have rebased and retested both patches in the series onto the latest gdb source tree. This patch applied cleanly on the latest tree. GDB maintainers: Version 3, rebased patch on the latest tree. No additional changes made to the patch. Patch has been retested with no regressions. Version 2, updated the commit log per feedback. The following PowerPC specific patch fixes an issue of GDB reporting a bogus return value for functions that return a non-trivial value. The bogus return values result in five testcase failures for test gdb.cp/non-trivial-retval.exp. The issue is the function ppc64_sysv_abi_return_value does not return the correct value when the valtype->code() is TYPE_CODE_STRUCT and the language_pass_by_reference is not trivially_copyable. This patch adds the needed code to return RETURN_VALUE_STRUCT_CONVENTION in these cases. The testcase gdb.cp/non-trivial-retval.exp still fails as gdb now correctly reports "Cannot determine contents" instead of the expected values, which is correct in this case. The PowerPC ABI uses passes the return buffer address in r3. The value of r3 is valid on entry to the function but the PowerPC ABI does not guarantee it will not be changed in the function. Hence the contents of r3 is not reliable on exit from the function. This issue will be addressed by the next patch in this patch series. The patch has been re-tested on PowerPC and on Intel X86-64 with no regression failures. Please let me know if this version of the patch is acceptable for the GDB mainline. Thanks. Carl Love ------------------------------- 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 need code to return the value RETURN_VALUE_STRUCT_CONVENTION in the case of 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. --- 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; } + 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 -- 2.37.2