From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80071.outbound.protection.outlook.com [40.107.8.71]) by sourceware.org (Postfix) with ESMTPS id 5FD7C38515F5 for ; Thu, 19 May 2022 08:17:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5FD7C38515F5 ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=AcAh6TqGN/RqePS9sEKV2cPHCts+ww5MFzC3Sf78vDj/bBKSmB/5DqlcPdr/NCJECMw7xXu6ktz+rKY9oa2u3cjr+KWWONE7n2KB/UQgZyRb1A3pgE628qAvnU/NMpmuHS2otuVGZKHN1D7m6bxqwjgRQfFr6G2JRcJI1aFGi9KCIp6ykw4E0AA7hwV3rEOdsQ7KBKhw2xddpx1gauAh5ouNVP40VvQ5Wb4mfSiGKr+BH7/a5/9NzrHfiBwaaW9zmy13Ll5bO7F5QqYnC+jXw/kgedmWVYMCd24Bn3YmrNrJb2LkqiovD1Cwrce9vV/qQZlSzpdQChLy3aYCiM2WVw== ARC-Message-Signature: i=2; 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=UeCIvoTcCoyuCpHnZnHCgWaeBPhm2qlZuJAAiKVa2GE=; b=cKyIYOYG+1mBTUJ6Cd2RK6QjkFFyDRRQNI+FWBuyrDW1ALB7dsoWpwooSHUbqkRhR/aywycN4jjnSLNO/CuiROWc0Zncp1oJ4wapiLSmixnI/mpkqeKVNA+KVJej/3Iz/evb/aXVLrm/9GNhdhcJwt9ZnVvXjkB9VzPuKKbLsXcHUv27Dors1ys0IdIhWJjTQemraarU19/HF8uNB4RCYJjwGIYIZ9IsKKmA/PGa6QEZpsi0ylOPAJU4fSn9zt4DLWGAd5SgppkimY2sawfPlJ+T+5tP5QmFOGS+lgGm6woX7pyfCbI9aojwi7+/7ccOoYR72Iq1jbHOv1eE0oFv+g== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=sourceware.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) Received: from DU2PR04CA0202.eurprd04.prod.outlook.com (2603:10a6:10:28d::27) by DB9PR08MB7021.eurprd08.prod.outlook.com (2603:10a6:10:2c8::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5273.14; Thu, 19 May 2022 08:17:34 +0000 Received: from DBAEUR03FT012.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:28d:cafe::7c) by DU2PR04CA0202.outlook.office365.com (2603:10a6:10:28d::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5273.16 via Frontend Transport; Thu, 19 May 2022 08:17:34 +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; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DBAEUR03FT012.mail.protection.outlook.com (100.127.142.126) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5273.14 via Frontend Transport; Thu, 19 May 2022 08:17:34 +0000 Received: ("Tessian outbound 42cead292588:v119"); Thu, 19 May 2022 08:17:34 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: a13535465eaf4665 X-CR-MTA-TID: 64aa7808 Received: from 30a6d84f5c08.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 2260F0EA-0BD9-4CA9-9088-AF5B1A09F4B8.1; Thu, 19 May 2022 08:17:27 +0000 Received: from EUR01-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 30a6d84f5c08.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 19 May 2022 08:17:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J87QbkAoGMeXx3G/NT97JNgcon3b/1vmkdObIiDX0dk4U5rbpi1lM4EW/E8MFuuHw+C+ojCENFbIfE2pVNFyOG3e1eASSSYb5f460KDTbH+0OslyPIeNs5ABbIkV6FqyOzWY5mS2/DMWSyMLgNrCsjKPnep2QAwpwJmHfDiE7a4Coygz+K84Z3YiXHxWKG84uv+rYP34TUus+KH2F0racEFbNbeu+W3abTUiBCOsYk/5oIZDWXRqM2QzC7kWNTjtk2yNGudC0KTaCUmbC1TOM+Q74+I/CP8AyxxuGZ7e2QqI2nbQhJaSLzcYFC1SwfFxtvTrz4pcKwsOPKVjV5dtZw== 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=UeCIvoTcCoyuCpHnZnHCgWaeBPhm2qlZuJAAiKVa2GE=; b=n8k1HB5ALewp1oeLvd1GGSal3XUD9RNTjuTuL55jDZLFhr25t+/De6vd4VQngEGv85IOb+3T8ovCy4U2worG4idsFYKTaWodYbKfDtT65+uxouZFv66izjDqdD8SxfZSJMaNNYfiwou7h5rE9DH1X2uir8aeo/pYlMDLbGd8hbPnYhAqKlN1Go5CS7NbCBX4LDSqxx2cLcxmeduvMzAJ7vWZsdYo+98lmONFecIbhXGLXwq0EhHEVhV/ReCwjZ80OfPY3tYDCvtDd5+eXEV160eeVQ/Zevtv324eJW50e5S4ODhaIxfZXA70qJIbT8GHIVfEyVxxdjb0WCu+BIrN9w== 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 AM0PR08MB4931.eurprd08.prod.outlook.com (2603:10a6:208:15e::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5273.13; Thu, 19 May 2022 08:17:24 +0000 Received: from VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::7080:6233:cf8f:a8a6]) by VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::7080:6233:cf8f:a8a6%7]) with mapi id 15.20.5250.018; Thu, 19 May 2022 08:17:24 +0000 Message-ID: <10c5644f-ad8a-2d9f-5b9e-c383abfaa27a@arm.com> Date: Thu, 19 May 2022 09:17:16 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Subject: Re: [PATCH 1/3] gdb/arm: Set the correct address to the FPU register on Content-Language: en-US To: Torbjorn SVENSSON , Christophe Lyon , Yvan ROUX - foss , "gdb-patches@sourceware.org" References: <20220516135454.GA27993@gnbcxd0114.gnb.st.com> <20220516135803.GB27993@gnbcxd0114.gnb.st.com> <8596b573-ad8e-df22-592d-b342c89a315e@arm.com> <98ee6a2d-1af4-404f-bf47-9e730e84642a@arm.com> From: Luis Machado In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SN6PR05CA0022.namprd05.prod.outlook.com (2603:10b6:805:de::35) To VI1PR08MB3919.eurprd08.prod.outlook.com (2603:10a6:803:c4::31) MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 39f7f61a-1671-42e2-e9df-08da3970073d X-MS-TrafficTypeDiagnostic: AM0PR08MB4931:EE_|DBAEUR03FT012:EE_|DB9PR08MB7021: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: N4EekUDrQ1bzWwgU8K9DvqkanWWRe0Gwq1MlEDnlmuXM5NcRUHG+kT//qjnA9hWPS68JbgM/Et9x1IdfnV28OzZwB93ndBT/JGXB9AMaDnaPCV+C432iOfRp4asHHqeGw7O/r2z1POqqKnHUUk3rAdR4XeD/Z47oktE7cbFAxYV2MVdZgt7iTLsMthFZk2lqSdTHw40AwSelXFFcxd8hIHcHqBjzWv2DAzNRK0jrfpVOTAXju1HSSMl9Jr2P6nL/l/Ru0QBCapa3wRI2eekWwyBHK7b6jFJUnwWvlyC1gM8ueUSEIoCCt2OO58aTtTmy4dQYWLqYcPjgLWn6G4pDaRqgEhOZiN3aS10FBaMrFA/ZjMpC9mjkHpN8s6SPl6h/rDfq181tNmgq4rtFOa4NgqmvnfN14S3BjHFiANIRRo27oCoMEx+G7XyQuKyjqIEtY39iRaT2isyFPg9MLUHxg2vSDijkI5YMMg8JY+LE/jiD/ai/F1ozGfBVnBC/S6yljmUUNknHVpuQMZRNaNAvoVTBoRf9igH+4STw887ChfT0Vs6uWim4XQTMTteg1ObMuaV5Sa+KU1cJEQh9hXHfmnG1OtMDggUgWDtTbKMRhTmgP4BD9AbHeNvfi+GaSkWMlNdBWfJVFL1Vh6SYA267+OO25vFOPJkUuljXguqZJ+B4n3sfRj9P1Sm0TuxMwsR4sWYIp1cDSHGhOMgDQ2q9ctQWW53xA4VEOg1y4ds9yJaSHoMl4Wo1JeeoOEB+PDOqKz2YL9EHpZCDZF/4pGmuyS28llgrX9mrUEAO0EcD9GrmhIB/11SB75za4cFl7wsV 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)(36756003)(5660300002)(66946007)(66556008)(316002)(8676002)(44832011)(8936002)(66476007)(31696002)(86362001)(2906002)(83380400001)(966005)(110136005)(2616005)(38100700002)(6512007)(6506007)(186003)(26005)(6666004)(66574015)(6486002)(508600001)(31686004)(53546011)(43740500002)(45980500001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB4931 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: DBAEUR03FT012.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 53e71499-4080-4796-82db-08da397000b5 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kxLGL7IprwZQU0XXRSgfMt0s/e2bjm9bBxTCuHaz6eHQCX0yR/5KI/HPSiXgUD7l3n0nhO9ChPKsHvLKlCQgciyFydn4z+3XM5meUOlLH2SrxCBe6kB5CAMIAIvHUnTQn8TS34Q5hDD3/AWt38qx6McLb3fPWlC2u3H0yZRPFLnEylIY0RPTV/68pop7goI0ObBMeQbfKYjNRtaKuUfp1BHSUAs3rvDwFd9awtCPNoDZiPgSOByYZ5Dfoz0NQuHlJhiW56liDOQtnWIDvTGlG8ewXYRNYJM22TIXdZ1MpZjqp0muZqRhUX+OYe4EMoB5K5Hm+9XzP2Gc7QwM2QuyKeEKu6pLmGaFIjU2PZnImd1KX4fGfFxF6HqCTRCcDioWYll/22Ch0TSpFv+ov6mzBVicKOrVRTKN3bRiVJ97+ZHk+kHfGJP5622fI54EQ5Rv+s4CpgW5suoPu1P3SPJlstdJhuYoYqJl5/cQPPXE79A80JThxnrL4JzRpInNws2jC0U6S3G2wXfofD6Fb8qvwjbhmyaQZ7gtfTXCjSg9P5hZbE84iLd1/8LnI6uGfiOx+TsQCUlU5oXd4ScY1pVY2cP3/AGWHtPOm3Nog5MUBOWRad5JG/8WXYQBcZBXKaQMTtKyuPTl+rE5w17id4eLBIdH8JA9MhJ9XFyvWNl+8x9IVdMRlMNTGUqBOExFq1V/qoMbdyI1A4QqmsbAfHzlgzaa2P9RucKGFBupqRYgFlb2CnkxedngqAjHjEq1QxnH4mz6hyNGsQeIO9foFmUu8sLwrOId9kvyYsVFPlikmFo= 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)(46966006)(40470700004)(36840700001)(83380400001)(47076005)(66574015)(5660300002)(966005)(6666004)(86362001)(6506007)(8936002)(81166007)(336012)(53546011)(2906002)(31696002)(26005)(6512007)(356005)(186003)(44832011)(40460700003)(6486002)(508600001)(70586007)(70206006)(31686004)(2616005)(110136005)(36860700001)(82310400005)(8676002)(36756003)(316002)(43740500002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2022 08:17:34.6964 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 39f7f61a-1671-42e2-e9df-08da3970073d 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: DBAEUR03FT012.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB7021 X-Spam-Status: No, score=-13.4 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.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: Thu, 19 May 2022 08:17:40 -0000 On 5/18/22 20:24, Torbjorn SVENSSON wrote: > Hello, > >> -----Original Message----- >> From: Luis Machado >> Sent: den 17 maj 2022 17:45 >> To: Torbjorn SVENSSON ; Christophe Lyon >> ; Yvan ROUX - foss ; >> gdb-patches@sourceware.org >> Subject: Re: [PATCH 1/3] gdb/arm: Set the correct address to the FPU >> register on >> >> On 5/17/22 10:49, Torbjorn SVENSSON via Gdb-patches wrote: >>> Hello, >>> >>> >>> ST Restricted >>> >>>> -----Original Message----- >>>> From: Christophe Lyon >>>> Sent: den 16 maj 2022 16:47 >>>> To: Yvan ROUX - foss ; gdb- >>>> patches@sourceware.org >>>> Cc: Torbjorn SVENSSON >>>> Subject: Re: [PATCH 1/3] gdb/arm: Set the correct address to the FPU >>>> register on >>>> >>>> Hi! >>>> >>>> >>>> On 5/16/22 15:58, Yvan Roux via Gdb-patches wrote: >>>>> Registers offsets weren't computed from SP address. >>>>> >>>>> Signed-off-by: Torbj�rn SVENSSON >>>>> Signed-off-by: Yvan Roux >>>>> --- >>>>> gdb/arm-tdep.c | 2 +- >>>>> 1 file changed, 1 insertion(+), 1 deletion(-) >>>>> >>>>> diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c >>>>> index 49664093f00..c37254c2ce1 100644 >>>>> --- a/gdb/arm-tdep.c >>>>> +++ b/gdb/arm-tdep.c >>>>> @@ -3475,7 +3475,7 @@ arm_m_exception_cache (struct frame_info >>>> *this_frame) >>>>> if (tdep->have_sec_ext && !default_callee_register_stacking) >>>>> { >>>>> /* Handle floating-point callee saved registers. */ >>>>> - fpu_regs_stack_offset = 0x90; >>>>> + fpu_regs_stack_offset = unwound_sp + 0x90; >>>> >>>> Sorry, it looks like this was my mistake when I committed ef273377587d. >>>> >>>> I haven't checked the manual, and I may have forgotten, but shouldn't >>>> this be >>>> fpu_regs_stack_offset = unwound_sp + sp_r0_offset + 0x90? >>> >>> As I see it, it can be either >>> fpu_regs_stack_offset = unwound_sp + 0x90; >>> or >>> fpu_regs_stack_offset = unwound_sp + sp_r0_offset + 0x68; >>> The offset values (0x90 and 0x68) can be seen in the "Stack Frame" chapter >> at https://developer.arm.com/documentation/100701/0200/Exception- >> handlers >> >> It would be nice to #define these constants and put some comments >> pointing at this documentation. > > While it would be "nice" to have defines, the defines would just have a single use and I think it might cause more clobber than it helps. The problem here is that 0x90 doesn't translate to anything meaningful. A constant would provide an anchor that we can document properly. If you're looking at this for the first time, it is hard to understand where it is coming from. But it is clearly incorrect now, so we have a chance to fix this and document it properly. > Maybe a compromise would be to extend the function comment to point to the documentation and mention that the offset values are taken from it? What would be the practical difference? GDB is getting more and more C++ these days, and some of the code tends to be more verbose. We want the code to be easy to maintain and read. > >> >>> >>> Based on the rest of the code, maybe "unwound_sp + sp_r0_offset + >> 0x68" is the preferred expression here as it removes the "integer callee >> saved" part from the equation. >>> >>>> How did you test this? Does your patch actually work? >>> >>> I've not tested the code on target (I don't know how to reliably trigger the >> code), I've just looked at how the rest of the register values are handled in >> the same block of code in GDB and they are all using the unwound_sp >> variable to identify the appropriate address. >> >> Was this spotted on visual inspection only? Would it be possible to craft some >> code that runs into an exception and then forces GDB to go through the >> frame restoring the registers? > > It was spotted using visual inspection yes. > I've been trying to create something that would reliably trigger this, but I'm not certain of what kind of scenario that triggers the code. Ok. So this is not related to the bug you reported, it is a separate fix to which we don't have a reproducer. Could we have some sort of validation before pursuing it then? > > Kind regards, > Torbjörn