From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60058.outbound.protection.outlook.com [40.107.6.58]) by sourceware.org (Postfix) with ESMTPS id A51DD3858D32 for ; Mon, 3 Oct 2022 11:27:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A51DD3858D32 ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=a60Mr03CDXArHW4Iu0FG1dep5LKqRXAIEt4LYs9IbCUHG+Hf45HK1t4f+eF/bxOP1duKqwVg8ZwhOer9fHDo3LIaxh0m7LiVdHKejyoB6ymaQu/wTkz+HYlXhLqlgOp7I/iPjhjs1zKUcm0Zd6E23hjdmhCR93+Q1JVkE2ldc9rQetQByD8T5VO1YkPPoSfmgNO0KWMHz9mNcV3eO4l2l4Rqmrj5IlkqRgPkaQ8ORy7MGiFPv37IYE3QgsFhWNrx+EfG/Bu1H23XLgGR4KQnYCyptk66MZJ40TqiT0DWz+yHPEF+QEAp4Vd4hdVx1gUbs0xAr3vU0A+8EBFMSOgRMw== 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=prs54ZikPoSPjXn2lckU8fs8EdKDo3jLU3s4rw6ZkZ0=; b=RGZL/kdAGIvjukpR02xGQvP3i1UiIX+RwvvTEJHoqNw1f2UwvwLAtmi0Mr5FUZt6ZqvJeOg3pi0/iT9cTVNjHdw8k5zeoiCMcTemooCc4FnJKcsGgBxVhRdipkE6nBj21drt5jImGEJGfRlLNxr+ORTabKR1DwapG7/nyCBkmyFYTKLNlIvxX5dfvjm0EVvW2G8G9twKb6aslcilidHXvfnjMi8fTUwTE7qSd86wqM5RSCeH1tBOVMREwnGzfdL0HKZ07phXox38KmfhLZlhYr/7/3Vm52EZPGToLmJa6iIsFyMsL56BAcc72VxDbU/vhj6ORRODYc48/tst/pPCDQ== 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 DBBPR09CA0036.eurprd09.prod.outlook.com (2603:10a6:10:d4::24) by DB9PR08MB6378.eurprd08.prod.outlook.com (2603:10a6:10:257::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.24; Mon, 3 Oct 2022 11:27:31 +0000 Received: from DBAEUR03FT007.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:d4:cafe::c2) by DBBPR09CA0036.outlook.office365.com (2603:10a6:10:d4::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.30 via Frontend Transport; Mon, 3 Oct 2022 11:27:31 +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 DBAEUR03FT007.mail.protection.outlook.com (100.127.142.161) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.17 via Frontend Transport; Mon, 3 Oct 2022 11:27:31 +0000 Received: ("Tessian outbound ce981123c49d:v128"); Mon, 03 Oct 2022 11:27:30 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 456f7e5ae96d0801 X-CR-MTA-TID: 64aa7808 Received: from 16a6f8034049.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 18A2FA1D-35B5-40E3-829C-D851CD5BD5CA.1; Mon, 03 Oct 2022 11:27:23 +0000 Received: from EUR02-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 16a6f8034049.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 03 Oct 2022 11:27:23 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jBw/JWA6FEzf3/SXz0lWqrEyodXsFvrJlgeAbqGLDWimQVJGDJamcnK73QqzFGvMk9cKYIBxSPF4LEaUd6/zdGDyS265oYj/vr1lOG7cBVwR5wkCDv4QjW7HGevBqzMwd6ZX1+EknFKW+mLjRz9w26bET5vefoNJAD7WRJlK3wIINDlu6o/EtamTCPWHIrh220QRBtI3HiSEXU22Yd6k9AUgicnL9xrUmsT0uUvbRmcFc6/fw6Kj6texvThEarNtAEveRANXA0muWNzCuE3BB5a0bNgH3Ga9as6l2jpujm1OY9/oSrILtRzcDG6dAsIDiLwczQ7YZx2UtMYrcLc8aQ== 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=prs54ZikPoSPjXn2lckU8fs8EdKDo3jLU3s4rw6ZkZ0=; b=jrXRjuzjjoWfDMvtNZ0Z4RHuUhWNclmqPaa7jHkM7ylirOcZCmM1RaueKWdsGmLyvgTbI4W+0F62+JJc1A7930n0x118WiPfCQG//i2fi0bOHG+2M1dfjyaOKaGMnxGmLxfKzARls225rIMs0Ch9R1i/mU6zovoDTP9bf56OhOQ7JIgDgv8kBvl4tTbmTuhvxGJjzwwsjhGno1WvRQ736sxXug45yUABar9BfZl7S6IZxT58Gi7jorEIKuJat5zK0iE3TNH6+booryEtR5fNlKp7kt/y5FK3ZcB0mu4PH2g7F0eX+5kfQPPb8RU21tk4gd89F8LM2Q6BgDFh2+TetQ== 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 PAWPR08MB9686.eurprd08.prod.outlook.com (2603:10a6:102:2e2::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.23; Mon, 3 Oct 2022 11:27:17 +0000 Received: from VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::c5f9:a25b:a5f2:6094]) by VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::c5f9:a25b:a5f2:6094%5]) with mapi id 15.20.5676.028; Mon, 3 Oct 2022 11:27:16 +0000 Message-ID: Date: Mon, 3 Oct 2022 12:27:14 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH v4] gdb/arm: Handle lazy FPU state preservation Content-Language: en-US To: =?UTF-8?Q?Torbj=c3=b6rn_SVENSSON?= , gdb-patches@sourceware.org Cc: brobecker@adacore.com, tom@tromey.com, pedro@palves.net, Yvan ROUX References: <20221002145138.2360215-1-torbjorn.svensson@foss.st.com> From: Luis Machado In-Reply-To: <20221002145138.2360215-1-torbjorn.svensson@foss.st.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: LO2P265CA0374.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a3::26) To VI1PR08MB3919.eurprd08.prod.outlook.com (2603:10a6:803:c4::31) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: VI1PR08MB3919:EE_|PAWPR08MB9686:EE_|DBAEUR03FT007:EE_|DB9PR08MB6378:EE_ X-MS-Office365-Filtering-Correlation-Id: d4275ee2-3ef4-4b45-b2ed-08daa5324298 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: 1Q2EUWTAA+le0B/AYGFkmrh9ZxkkSfSFtl9gYi58HEUFbWijIbsuDLSM0TtBKGSLGnKSJmFkHd6ckx03nhRjxF7CqaCuzPAkYCAfs1etGYjcq9kBUKiOmRRb3UTJ3Fs/jXgm4dAwYkJ1MjJANHogIjy+kvH+TShIq+VFL2/EdCP2G8eU0hmb30qaIR6N8PVcs09wJuJ8bolV7KgfUuSG08f9yiKm4pgBh3L0Dk+kJTZLAPfQja/eKM1iwju4bbWSaXi+nXhYu5V1ZuJIUtVPlp/FDhDcwt8TsQwWsRMMzwt088yz2ijJp63/wKHlkeJJhQox3FjX68WakNzFTEoWThd2pD4/+JJ3sp2pr/PrIHw7Tx1lVaYINa+oKY8H6oY7JoOOUXVISgQ3Rc/Jl+9ao+MmQKlY5s4loGiAJIfgPPDA1S87AYaf7ygjXBoiyC9PRI+Lk15BCDsLc9PJaOev0/NtoS6JjHKyKqPcQwbv0RfiLT2n82llRMT33luLNsgMZKDO0+FkTwhDo61YJtfLkqVqwmJvRijeFWhirRvPQYjjF47Auxgoy2+jtmTtzIo9IF7zJnGTq1fDXO1lto1zWfXPnTJDgwWhiFhfehHse61S6WmYifujfEY8MJUaPijLc8y9TAzDr6C+DFFskDufwKu6TMUHYe47KveML05ZiyuKdUFdWRhVinYtT90H8FDw/vliahGuXWfZYgUmuIK45I11UYE7hAE+ODNtAaGoDOMWa0GG0TTyu+E0JDnHQ/3AzMpz3G8RPTWVn/oLXHUUlGty7vaITa3LLdIQ30PgWlfH7felHsD2rbOTSZNIIRzbc2DH7remO4dDvemgb2PxbZjMJ7TNYVOlMd2rsIgn30MoQRqQ7/7fI2kkTjA/ELVrZ4VEVKWTXCNY//lRbToFzA== 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:(13230022)(4636009)(346002)(39860400002)(376002)(396003)(366004)(136003)(451199015)(66574015)(53546011)(86362001)(186003)(41300700001)(2616005)(5660300002)(66556008)(44832011)(66476007)(26005)(4326008)(31696002)(8676002)(30864003)(2906002)(8936002)(66946007)(478600001)(36756003)(6506007)(6512007)(6486002)(316002)(38100700002)(83380400001)(31686004)(2004002)(45980500001)(43740500002)(460985005); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR08MB9686 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: DBAEUR03FT007.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 24ed2852-8fc0-480a-fa70-08daa53239b8 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JXdURUAejtADjlgkM9Q6qYrNX+SseGKjgzPNb0EuKfpOaIvXXpG4ykTG/AgtWCeTH9FUlaufem8p4GZ8WYGkWZDcjq864wefahO2I5JaNsWnZK81+ZUl5dADrYR38vDLLl3leXZPubu97OeU4l4Fp8mL07kSkmzdSbph80cy+LgCuemk0DO9/E5IYDLQzLO6i7O78k2IhG13oj/V2geEHHoTJzNjT8d9HyNr5gTXPifsoBc57I1z8f3xyKw2xnLioWbUfrIUQKYuCEejG3/wLqp7sDFrVuj4XgZpt3NOVjbsWF4RtjTSiY/dyohfRecxzDqGsxLb2cgGyV90ZWYFJJlo7B/XvMx0NLYohryFt53KPxiS5A4a6OujvlhCi65eqkGJ8DncrhKfgwmi69HWBJsxlm+KPMStAzJRsU2aahMtd6rhO1VmuMZbfHct3NH3MBK4Ph1SSqQRNh25SUW7C1X7/0qCslzwfFmcP154V3pSEMGqRCbqEy72hH0zUGDI4nXe1VjMGM+DBVYxzcYl+xlDaKN8fweb4fRb6J4tOWU5lBWqCzo5/qBW9DWbRykH9LzfHTHOk9WhL/Hf6xVZfFXYEtm+Finu8vU7ni02uPWqRbxQP8bHze+75azicly5jaT6yc1197j96M7j7mq43+fG+BgpgR2zMPA1VBWcRcGMMuZwLM+y5+oLCfDyG/xN5gY6zVig25ddG0RahJvjoEhbjTI6I+E1hqjGDQHGFf0sGeRr6RD0SalpaYNOezhxPHKeYB0U8y2rkvw3ro0rZmkKlESfXPIOj9Zq+Cf06kDqT2ODX3Bht8A6mVv5pvMKju6qO8gk1QU5Ft8/SAeoIkCFXTXH4sTAJO7QwV05fvmJpeDORTC7KrF+2PSvJwNe9xXqGt0VEla0eK95BkdKE0qnO+4Bxvr+HKq9cFs6ALg= 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:(13230022)(4636009)(136003)(39860400002)(376002)(396003)(346002)(451199015)(36840700001)(40470700004)(46966006)(31686004)(5660300002)(30864003)(31696002)(26005)(86362001)(40460700003)(8936002)(36756003)(336012)(2906002)(478600001)(6486002)(6506007)(53546011)(6512007)(81166007)(2616005)(8676002)(4326008)(356005)(82740400003)(41300700001)(44832011)(40480700001)(36860700001)(82310400005)(186003)(83380400001)(316002)(70206006)(66574015)(70586007)(47076005)(2004002)(43740500002)(460985005); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2022 11:27:31.0597 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d4275ee2-3ef4-4b45-b2ed-08daa5324298 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: DBAEUR03FT007.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB6378 X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_NONE, KAM_SHORT, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, 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: Mon, 03 Oct 2022 11:27:37 -0000 Hi, I think the current mechanism is better than the observer scheme. On 10/2/22 15:51, Torbjörn SVENSSON wrote: > Read LSPEN, ASPEN and LSPACT bits from FPCCR and use them together > with FPCAR to identify if lazy FPU state preservation is active for > the current frame. See "Lazy context save of FP state", in B1.5.7, > also ARM AN298, supported by Cortex-M4F architecture for details on > lazy FPU register stacking. The same conditions are valid for other > Cortex-M cores with FPU. > > This patch has been verified on a STM32F4-Discovery board by: > a) writing a non-zero value (lets use 0x1122334455667788 as an > example) to all the D-registers in the main function > b) configured the SysTick to fire > c) in the SysTick_Handler, write some other value (lets use > 0x0022446688aaccee as an example) to one of the D-registers (D0 as > an example) and then do "SVC #0" > d) in the SVC_Handler, write some other value (lets use > 0x0099aabbccddeeff) to one of the D-registers (D0 as an example) > > In GDB, suspend the execution in the SVC_Handler function and compare > the value of the D-registers for the SVC_handler frame and the > SysTick_Handler frame. With the patch, the value of the modified > D-register (D0) should be the new value (0x009..eff) on the > SVC_Handler frame, and the intermediate value (0x002..cee) for the > SysTick_Handler frame. Now compare the D-register value for the > SysTick_Handler frame and the main frame. The main frame should > have the initial value (0x112..788). > > > Example GDB session: > > C:\>c:\dev\gdb\arm-none-eabi-gdb.exe C:\Users\foo\STM32Cube\Repository\STM32Cube_FW_F4_V1.27.0\Projects\STM32F4-Discovery\Examples\GPIO\GPIO_EXTI\SW4STM32\STM32F4-Discovery\Debug\STM32F4-Discovery.elf > GNU gdb (GDB) 13.0.50.20221001-git > Copyright (C) 2022 Free Software Foundation, Inc. > License GPLv3+: GNU GPL version 3 or later > This is free software: you are free to change and redistribute it. > There is NO WARRANTY, to the extent permitted by law. > Type "show copying" and "show warranty" for details. > This GDB was configured as "--host=x86_64-w64-mingw32 --target=arm-none-eabi". > Type "show configuration" for configuration details. > For bug reporting instructions, please see: > . > Find the GDB manual and other documentation resources online at: > . > > For help, type "help". > Type "apropos word" to search for commands related to "word"... > Reading symbols from C:\Users\foo\STM32Cube\Repository\STM32Cube_FW_F4_V1.27.0\Projects\STM32F4-Discovery\Examples\GPIO\GPIO_EXTI\SW4STM32\STM32F4-Discovery\Debug\STM32F4-Discovery.elf... > (gdb) set pagination off > (gdb) set confirm off > (gdb) define lazy_dump > Type commands for definition of "lazy_dump". > End with a line saying just "end". >> shell echo >> shell echo "Content at $arg0" >> set $i = 0 >> while $i <= $arg1 > > f $i > > p/x $d0 > > p/x $d1 > > shell echo > > set $i = $i + 1 > > end >> shell echo >> end > (gdb) > (gdb) target remote :61234 > Remote debugging using :61234 > Reset_Handler () at C:/Users/foo/STM32Cube/Repository/STM32Cube_FW_F4_V1.27.0/Projects/STM32F4-Discovery/Examples/GPIO/GPIO_EXTI/SW4STM32\startup_stm32f407xx.s:63 > 63 ldr sp, =_estack /* set stack pointer */ > (gdb) b main > Breakpoint 1 at 0x80015cc: file C:/Users/foo/STM32Cube/Repository/STM32Cube_FW_F4_V1.27.0/Projects/STM32F4-Discovery/Examples/GPIO/GPIO_EXTI/Src/main.c, line 63. > Note: automatically using hardware breakpoints for read-only addresses. > (gdb) b SysTick_Handler > Breakpoint 2 at 0x8001854: file C:/Users/foo/STM32Cube/Repository/STM32Cube_FW_F4_V1.27.0/Projects/STM32F4-Discovery/Examples/GPIO/GPIO_EXTI/Src/stm32f4xx_it.c, line 150. > (gdb) b SVC_Handler > Breakpoint 3 at 0x8001808: file C:/Users/foo/STM32Cube/Repository/STM32Cube_FW_F4_V1.27.0/Projects/STM32F4-Discovery/Examples/GPIO/GPIO_EXTI/Src/stm32f4xx_it.c, line 112. > (gdb) c > Continuing. > > Breakpoint 1, main () at C:/Users/foo/STM32Cube/Repository/STM32Cube_FW_F4_V1.27.0/Projects/STM32F4-Discovery/Examples/GPIO/GPIO_EXTI/Src/main.c:63 > 63 HAL_Init(); > (gdb) lazy_dump main 0 > > Content at main > #0 main () at C:/Users/foo/STM32Cube/Repository/STM32Cube_FW_F4_V1.27.0/Projects/STM32F4-Discovery/Examples/GPIO/GPIO_EXTI/Src/main.c:63 > 63 HAL_Init(); > $1 = 0x0 > $2 = 0x0 > > > (gdb) c > Continuing. > > Breakpoint 2, SysTick_Handler () at C:/Users/foo/STM32Cube/Repository/STM32Cube_FW_F4_V1.27.0/Projects/STM32F4-Discovery/Examples/GPIO/GPIO_EXTI/Src/stm32f4xx_it.c:150 > 150 HAL_IncTick(); > (gdb) lazy_dump "SysTick_Handler before vmov" 2 > > Content at "SysTick_Handler before vmov" > #0 SysTick_Handler () at C:/Users/foo/STM32Cube/Repository/STM32Cube_FW_F4_V1.27.0/Projects/STM32F4-Discovery/Examples/GPIO/GPIO_EXTI/Src/stm32f4xx_it.c:150 > 150 HAL_IncTick(); > $3 = 0x1122334455667788 > $4 = 0x1122334455667788 > > #1 > $5 = 0x1122334455667788 > $6 = 0x1122334455667788 > > #2 main () at C:/Users/foo/STM32Cube/Repository/STM32Cube_FW_F4_V1.27.0/Projects/STM32F4-Discovery/Examples/GPIO/GPIO_EXTI/Src/main.c:120 > 120 while (1) > $7 = 0x1122334455667788 > $8 = 0x1122334455667788 > > > (gdb) c > Continuing. > > Breakpoint 3, SVC_Handler () at C:/Users/foo/STM32Cube/Repository/STM32Cube_FW_F4_V1.27.0/Projects/STM32F4-Discovery/Examples/GPIO/GPIO_EXTI/Src/stm32f4xx_it.c:112 > 112 asm("push {r0, r1}"); > (gdb) lazy_dump "SVC_Handler before vmov" 4 > > Content at "SVC_Handler before vmov" > #0 SVC_Handler () at C:/Users/foo/STM32Cube/Repository/STM32Cube_FW_F4_V1.27.0/Projects/STM32F4-Discovery/Examples/GPIO/GPIO_EXTI/Src/stm32f4xx_it.c:112 > 112 asm("push {r0, r1}"); > $9 = 0x22446688aaccee > $10 = 0x22446688aaccee > > #1 > $11 = 0x22446688aaccee > $12 = 0x22446688aaccee > > #2 SysTick_Handler () at C:/Users/foo/STM32Cube/Repository/STM32Cube_FW_F4_V1.27.0/Projects/STM32F4-Discovery/Examples/GPIO/GPIO_EXTI/Src/stm32f4xx_it.c:162 > 162 } > $13 = 0x22446688aaccee > $14 = 0x22446688aaccee > > #3 > $15 = 0x22446688aaccee > $16 = 0x22446688aaccee > > #4 main () at C:/Users/foo/STM32Cube/Repository/STM32Cube_FW_F4_V1.27.0/Projects/STM32F4-Discovery/Examples/GPIO/GPIO_EXTI/Src/main.c:120 > 120 while (1) > $17 = 0x1122334455667788 > $18 = 0x1122334455667788 > > > (gdb) s 8 > 122 HAL_GPIO_EXTI_Callback(KEY_BUTTON_PIN); > (gdb) lazy_dump "SVC_Handler after vmov" 4 > > Content at "SVC_Handler after vmov" > #0 SVC_Handler () at C:/Users/foo/STM32Cube/Repository/STM32Cube_FW_F4_V1.27.0/Projects/STM32F4-Discovery/Examples/GPIO/GPIO_EXTI/Src/stm32f4xx_it.c:122 > 122 HAL_GPIO_EXTI_Callback(KEY_BUTTON_PIN); > $19 = 0x99aabbccddeeff > $20 = 0x99aabbccddeeff > > #1 > $21 = 0x99aabbccddeeff > $22 = 0x99aabbccddeeff > > #2 SysTick_Handler () at C:/Users/foo/STM32Cube/Repository/STM32Cube_FW_F4_V1.27.0/Projects/STM32F4-Discovery/Examples/GPIO/GPIO_EXTI/Src/stm32f4xx_it.c:162 > 162 } > $23 = 0x22446688aaccee > $24 = 0x22446688aaccee > > #3 > $25 = 0x22446688aaccee > $26 = 0x22446688aaccee > > #4 main () at C:/Users/foo/STM32Cube/Repository/STM32Cube_FW_F4_V1.27.0/Projects/STM32F4-Discovery/Examples/GPIO/GPIO_EXTI/Src/main.c:120 > 120 while (1) > $27 = 0x1122334455667788 > $28 = 0x1122334455667788 > > > > > > Signed-off-by: Torbjörn SVENSSON > Signed-off-by: Yvan ROUX > --- > gdb/arch/arm.h | 7 ++++++- > gdb/arm-tdep.c | 51 ++++++++++++++++++++++++++++++++++---------------- > 2 files changed, 41 insertions(+), 17 deletions(-) > > diff --git a/gdb/arch/arm.h b/gdb/arch/arm.h > index 36757493406..d384b952144 100644 > --- a/gdb/arch/arm.h > +++ b/gdb/arch/arm.h > @@ -115,7 +115,12 @@ enum system_register_address : CORE_ADDR > /* M-profile Floating-Point Context Control Register address, defined in > ARMv7-M (Section B3.2.2) and ARMv8-M (Section D1.2.99) reference > manuals. */ > - FPCCR = 0xe000ef34 > + FPCCR = 0xe000ef34, > + > + /* M-profile Floating-Point Context Address Register address, defined in > + ARMv7-M (Section B3.2.2) and ARMv8-M (Section D1.2.98) reference > + manuals. */ > + FPCAR = 0xe000ef38 > }; > > /* Instruction condition field values. */ > diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c > index 2810232fcb8..b08ee096f97 100644 > --- a/gdb/arm-tdep.c > +++ b/gdb/arm-tdep.c > @@ -3588,27 +3588,43 @@ arm_m_exception_cache (struct frame_info *this_frame) > if (extended_frame_used) > { > ULONGEST fpccr; > + ULONGEST fpcar; > > /* Read FPCCR register. */ > gdb_assert (safe_read_memory_unsigned_integer (FPCCR, > ARM_INT_REGISTER_SIZE, > byte_order, &fpccr)); > - bool fpccr_ts = bit (fpccr, 26); > > - /* This code does not take into account the lazy stacking, see "Lazy > - context save of FP state", in B1.5.7, also ARM AN298, supported > - by Cortex-M4F architecture. > - To fully handle this the FPCCR register (Floating-point Context > - Control Register) needs to be read out and the bits ASPEN and > - LSPEN could be checked to setup correct lazy stacked FP registers. > - This register is located at address 0xE000EF34. */ > + /* Read FPCAR register. */ > + gdb_assert (safe_read_memory_unsigned_integer (FPCAR, > + ARM_INT_REGISTER_SIZE, > + byte_order, &fpcar)); I'm not sure about this assertion. Can we handle this gracefully without crashing GDB? > + bool fpccr_aspen = bit (fpccr, 31); > + bool fpccr_lspen = bit (fpccr, 30); > + bool fpccr_ts = bit (fpccr, 26); > + bool fpccr_lspact = bit (fpccr, 0); > + > + /* The LSPEN and ASPEN bits indicate if the lazy state preservation > + for FP registers is enabled or disabled. The LSPACT bit indicate, > + together with FPCAR, if the lazy state preservation feature is > + active for the current frame or for another frame. > + See "Lazy context save of FP state", in B1.5.7, also ARM AN298, > + supported by Cortex-M4F architecture for details. */ > + bool fpcar_points_to_this_frame = ((unwound_sp + sp_r0_offset + 0x20) I'd define "addr = unwound_sp + sp_r0_offset + 0x20" and use it here... > + == (fpcar & ~0x7)); > + bool read_fp_regs_from_stack = (!(fpccr_aspen && fpccr_lspen > + && fpccr_lspact > + && fpcar_points_to_this_frame)); > > /* Extended stack frame type used. */ > - CORE_ADDR addr = unwound_sp + sp_r0_offset + 0x20; > - for (int i = 0; i < 8; i++) > + if (read_fp_regs_from_stack) > { > - cache->saved_regs[ARM_D0_REGNUM + i].set_addr (addr); > - addr += 8; > + CORE_ADDR addr = unwound_sp + sp_r0_offset + 0x20; ... and here. > + for (int i = 0; i < 8; i++) > + { > + cache->saved_regs[ARM_D0_REGNUM + i].set_addr (addr); > + addr += 8; > + } > } > cache->saved_regs[ARM_FPSCR_REGNUM].set_addr (unwound_sp > + sp_r0_offset + 0x60); > @@ -3617,11 +3633,14 @@ arm_m_exception_cache (struct frame_info *this_frame) > && fpccr_ts) > { > /* Handle floating-point callee saved registers. */ > - addr = unwound_sp + sp_r0_offset + 0x68; > - for (int i = 8; i < 16; i++) > + if (read_fp_regs_from_stack) > { > - cache->saved_regs[ARM_D0_REGNUM + i].set_addr (addr); > - addr += 8; > + CORE_ADDR addr = unwound_sp + sp_r0_offset + 0x68; Then adjust addr here if we are using a different address. > + for (int i = 8; i < 16; i++) > + { > + cache->saved_regs[ARM_D0_REGNUM + i].set_addr (addr); > + addr += 8; > + } > } > > arm_cache_set_active_sp_value (cache, tdep, Otherwise LGTM. Thanks for putting this together.