From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2084.outbound.protection.outlook.com [40.107.21.84]) by sourceware.org (Postfix) with ESMTPS id 6587B3857829 for ; Mon, 14 Mar 2022 10:43:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6587B3857829 Received: from AM5PR04CA0026.eurprd04.prod.outlook.com (2603:10a6:206:1::39) by AM0PR08MB3476.eurprd08.prod.outlook.com (2603:10a6:208:dd::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5061.25; Mon, 14 Mar 2022 10:43:46 +0000 Received: from VE1EUR03FT033.eop-EUR03.prod.protection.outlook.com (2603:10a6:206:1:cafe::bf) by AM5PR04CA0026.outlook.office365.com (2603:10a6:206:1::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5061.26 via Frontend Transport; Mon, 14 Mar 2022 10:43:46 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT033.mail.protection.outlook.com (10.152.18.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5061.22 via Frontend Transport; Mon, 14 Mar 2022 10:43:45 +0000 Received: ("Tessian outbound 31aeb3346a45:v113"); Mon, 14 Mar 2022 10:43:45 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 5f27226996908568 X-CR-MTA-TID: 64aa7808 Received: from 160c8e0de707.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 44FAD6E5-7476-4BC9-A9C1-CF466D0CBE44.1; Mon, 14 Mar 2022 10:43:39 +0000 Received: from EUR01-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 160c8e0de707.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 14 Mar 2022 10:43:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NObnm7nJzV2T6qzm6A7WGS+3IARzr5HW4DWgVh2QOT9tJ8ZPyPAKh4fFBvLHB8ASdbMEWxuWYQ7Dmn2QMnL38D9Hc/k5BAWSXEkKnf6hOKMouGZsqTBcDEvUQxRzHMpCm2Y1zvjMo9tiqazi5zx2P3VnjG2ASMhEfs2OJE/QPtte8JHojB70cOm+ohuVDGRBO407MsjLfC+Bxl7RP38nfFnxA06Uw0mu3J6cdzYSlk2PFMWX4/LF5lo2ZdfAG54uFWApZQ6dHZ44elkTX6MoFEbodKPlMkYq3trVttrtq4Ez3IVV7dA4BXvC/I2+7Vrad+ozeo7ceEDazti57OvhcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=rMgrTBquXPvGl3kRwPoRZ0sE/GZWFaOZHFirZvf3QdM=; b=DAYbX4Ef4uv+TS6sqiG/YRrhpLbbhUXfUvs/EHEYp0YdZHjWFGEOo8KhC/A8vCwl7hUdcvNPm7D1nCwXpt712KBksbPZZsZf66xUqnwmXHUtsQIjsImkNEVMEPdadQA3g23sC1a8QEfyKIv1HkircqsfH1wqhXnGhLrDZtyNt3FN6r1CLZAsJSwW9qKxmRydSpeTDKG3RvEWT8u/Ey+TFNqIFeUJ1Gzb5BUjNcj5Cdwp6J3PbJD6G1mwi1oGUcYiAfJJWdY2/V+afUW7MHiaZUAI7Rsgxe/bHGcVEnwJ/tf3VZTZUPGv65wE59dpRGesqgL2s2YX5jZx4qe9y/gnlA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from VI1PR08MB3919.eurprd08.prod.outlook.com (2603:10a6:803:c4::31) by AM9PR08MB5874.eurprd08.prod.outlook.com (2603:10a6:20b:281::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5061.22; Mon, 14 Mar 2022 10:43:37 +0000 Received: from VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::4d3d:c632:297e:1dcc]) by VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::4d3d:c632:297e:1dcc%5]) with mapi id 15.20.5061.028; Mon, 14 Mar 2022 10:43:36 +0000 Message-ID: Date: Mon, 14 Mar 2022 10:43:35 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH] PowerPC, add support for printing non-trivial C++ object for the finish command. Content-Language: en-US To: Carl Love , gdb-patches@sourceware.org, Ulrich Weigand Cc: Rogerio Alves References: <28ce795ca489f69829207b2a7a535cf7f77f6dd8.camel@us.ibm.com> From: Luis Machado In-Reply-To: <28ce795ca489f69829207b2a7a535cf7f77f6dd8.camel@us.ibm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LO2P265CA0194.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:9e::14) To VI1PR08MB3919.eurprd08.prod.outlook.com (2603:10a6:803:c4::31) MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: f52a1971-50c6-4a3a-aa8d-08da05a78405 X-MS-TrafficTypeDiagnostic: AM9PR08MB5874:EE_|VE1EUR03FT033:EE_|AM0PR08MB3476:EE_ X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 5IOxpSQdhNPJeyaAvYEJ30tSGyK9Z1YMjBow6qaqKnuC+IzhiwGJvjJ5tfKQq8pTuTBcpuVQbNxg9Wm8KT40IAP3WSr018CjqHB+CQD0p7OXzZgWbR8twSrS8lxdaNHV9jTjGNTOJNkIKiTDHwdH6tX5aq+2VV+3srZxxrn0UYuXcQg8PbOOdr0TqDDsbcU/vi4sb3Ev33tAQ9cimM1iI8sjTfKTDG8oiSqIxH4hf6cPM+yxYJZXj5ExiGgKjY5E1wiWb+38jDRiJYRZKq30LSU/gJiO6C4FgTPJXqOUwet3XgzfUN8HNVRiWUdtOgX1uUNdFd3X0f2cHXJpYIVX4L5b/3v+PUSUtgq+ubNIx9HCjZ9tq3p50UNNrZHz8NO122G5yeWvem4oRgC8KmPPvo57Q5EodrVP+FaUQeMv2jbD4FX1Z01KeGWem4//ymad1CGdwHnvgVoKD9CpCdOxhiyR0HztmLaYqSJ5mnIXkDaUF7AoOz8BRtMDaYt1/GK/82w6b58+LUHrm6T2zT+4knV36FwrV8bYQ1Xhlwkt8drOSim2CWbvabgY5cGkj5Qg6zt0P6hvqdbbe47qngB0LACo8nL7JnEqQIrlNsLeG8K8UgKwyfGg3JV8mU8JpZCK67cjJ7DEEU8hWH5yySPC8JIUk+rs6MczRLKWmGVuiI4aF3zQPHcwRxfaDscDPH+kgo9bsKTraWzWyGoodl1V9EAUwsodIz+wYoQc0zFx3lGkMydRCXLcVxdnErDCU7HM X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR08MB3919.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(316002)(83380400001)(2906002)(31696002)(86362001)(4326008)(8676002)(38100700002)(66476007)(66946007)(66556008)(6506007)(508600001)(53546011)(8936002)(2616005)(6512007)(44832011)(110136005)(6486002)(36756003)(26005)(5660300002)(31686004)(186003)(43740500002)(45980500001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR08MB5874 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT033.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 464c677c-953d-4331-e93c-08da05a77e87 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QKU9RcLIJsZZjhQK5kD4vN58EEKKptKca5TeVcdY1Cz4ZuazgoiJyoPfyi9fEwveNbADTBvyk0XdsDjpCjyw8I1dtXfXaQdXHSAKXrR3QPgGiCeFVXHbHi+tMVnJvDGqtoYqZs3O8YHCyNebdziClARLNhctYFnwpk1RHL94YqpQ3498s3N9vtnfkAvC2Ms+oV7aJp6RjajmZIB9zKfzqcK4soHAWx5dyl+uEEH4C+am+jgvb2Xgm63JCoGFhRHyR82jpKT1Mi/GR6YrCF2C+GN6WBwwAZWrDsG4OS+Vn3LCwaHG5+uox925VjWrMW0Ys+AtMPHeLqEkqSC3ocw51tGfQrZRLcCh2zd4xuUK+oYT2pqrW20MDDsM5HN9+uoMRBJn/69Xt7PiG7A4GA77IlX6MpuESsYnXGJCOZSd7qebfIcPN7D9rP48ay+cEEvlX9g+5M9nOSvjX/CeLFm/axVlLl5SSe1AxnCyojiizHRuZqu2awkB732NMNRsJLFd7o/TjBff10QOyqnExYfrtMQ+HL+yTUSDX6RYTJdeZyYUUB41/1gXUlIMzWPUWIbH01Vx5vHqJokmw5b6kYKquNLap0fGnPZcHhEVbSu/jbeFDgGO0JWlCfeZ7jquu7Xx2xj5mB2jGTBnTt5pjWiiIaLUEAaE/5JwCFYZDCCO0Nn25bR2hc4BcMYv7xKW3jgHh5Fotjh//5YCPEthqIqSzg== X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230001)(4636009)(40470700004)(46966006)(36840700001)(36860700001)(44832011)(356005)(83380400001)(336012)(6512007)(81166007)(31686004)(5660300002)(36756003)(2906002)(26005)(186003)(47076005)(2616005)(8936002)(4326008)(316002)(508600001)(40460700003)(31696002)(70586007)(70206006)(86362001)(8676002)(110136005)(53546011)(6506007)(82310400004)(6486002)(43740500002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Mar 2022 10:43:45.7899 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f52a1971-50c6-4a3a-aa8d-08da05a78405 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: VE1EUR03FT033.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3476 X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Mar 2022 10:43:57 -0000 On 3/11/22 22:26, Carl Love via Gdb-patches wrote: > > GDB maintainers: > > The following patch fixes an issue on Powerpc where the function return > value for a C++ program prints garbage when the function return type is > a class object. The fix is based on an x86-64 patch for the same > issue. > > The patch has been tested on Power 10 with no regressions. Please let > me know if this patch is acceptable for mainline. Thanks. > > Carl Love > --------------------------------------------------- > PowerPC, add support for printing non-trivial C++ object for the finish command. > > This patch fixes five testcase failures in gdb/cpp/non-trival-retval.exp. > The testcases that fail were added by commit: > > 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 commit adds new tests for printing the return value of a C++ function. > The return value of the function is a C++ Class. The current PowerPC code > is looking for the return value in register r3. The return value is actually > in memory as described in the commit message for x86-64 above. > > The fix for Powerpc is based on the fix in the above commit plus examining > how x86-64 handles the value in function amd64_return_value in file > gdb/amd64-tdep.c. > --- > gdb/ppc-sysv-tdep.c | 14 ++++++++++++++ > 1 file changed, 14 insertions(+) > > diff --git a/gdb/ppc-sysv-tdep.c b/gdb/ppc-sysv-tdep.c > index 9a3b02f028d..50277e7bdd1 100644 > --- a/gdb/ppc-sysv-tdep.c > +++ b/gdb/ppc-sysv-tdep.c > @@ -2035,6 +2035,20 @@ ppc64_sysv_abi_return_value (struct gdbarch *gdbarch, struct value *function, > return RETURN_VALUE_REGISTER_CONVENTION; > } > > + /* If the object is a non-trivial C++ object the object is in memory. */ > + if (!language_pass_by_reference (valtype).trivially_copyable) > + { > + if (readbuf) > + { > + ULONGEST addr; > + int regnum = tdep->ppc_gp0_regnum + 3; > + > + regcache_raw_read_unsigned (regcache, regnum, &addr); > + read_memory (addr, readbuf, TYPE_LENGTH (valtype)); > + } > + return RETURN_VALUE_ABI_RETURNS_ADDRESS; > + } > + > /* In the ELFv2 ABI, aggregate types of up to 16 bytes are > returned in registers r3:r4. */ > if (tdep->elf_abi == POWERPC_ELF_V2 Carl, Just a heads-up that I pushed a new test (gdb.base/retval-large-struct.exp) that exercises returning a large struct (> 16 bytes) from a function. You might want to validate that test on ppc as well, given this particular scenario wasn't being validated properly in the testsuite.