From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2067.outbound.protection.outlook.com [40.107.21.67]) by sourceware.org (Postfix) with ESMTPS id 900AA3858D38 for ; Mon, 23 Jan 2023 12:09:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 900AA3858D38 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IABTFSrOrCnyqkz6DQFwPMWA6bDJtt5Zl2rQtAxLQnY=; b=QDkZoelMB0NC6t1Q7r3eZjxpn4p6/1bX0IRij9KZj6RangOBAj16e9yrTLoY7WLI0ILyYT76KHk+8c139soz5qstyNMMZ0MEgRxmDcM+LPZdTdBOqkfpT2kFfLG2RQbZ1uKyoVSocuofUzBFfs0FdKJZPk6rRP5JOPK25+Bebrs= Received: from AM6P194CA0021.EURP194.PROD.OUTLOOK.COM (2603:10a6:209:90::34) by AS8PR08MB6565.eurprd08.prod.outlook.com (2603:10a6:20b:33c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33; Mon, 23 Jan 2023 12:09:23 +0000 Received: from AM7EUR03FT020.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:90:cafe::d6) by AM6P194CA0021.outlook.office365.com (2603:10a6:209:90::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33 via Frontend Transport; Mon, 23 Jan 2023 12:09:23 +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 AM7EUR03FT020.mail.protection.outlook.com (100.127.140.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6023.16 via Frontend Transport; Mon, 23 Jan 2023 12:09:22 +0000 Received: ("Tessian outbound 8038f0863a52:v132"); Mon, 23 Jan 2023 12:09:22 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 3b88d13aa90c548a X-CR-MTA-TID: 64aa7808 Received: from 87943889e822.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 66099936-9F45-4FFF-8536-465413FED6B1.1; Mon, 23 Jan 2023 12:09:16 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 87943889e822.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 23 Jan 2023 12:09:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jLHpkDH0IhS1VQGav2URyEP0UbfrC3sl+Um6lNRmjJ/szpQq6sticilhA1gfUlqNagEQq1KZMkbkYjyV//lsgn1V00m/moqiwiMrhOO6+ePfi4AGS6p7Y1as18ezcWzmhNVG+gusP9WFZZB6hpZSVASMKOQvh/3sPQtFPN0zQh6iXzULfKyu3EO9khQ8eEGZ5CTOAx//Ps7keN8T7xxc1274cVHSPYscJkE/DgoGFiWDk3oY2J16XkGb4t2/sbBmjqadU2TeZvHBbJnlpsjpP9flHOKSCCtP3vZNge4EFqmNoNFhH4nqOpiq4NwaJlz1PZVjJ5YOlR+MHXdmo0MMsw== 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=IABTFSrOrCnyqkz6DQFwPMWA6bDJtt5Zl2rQtAxLQnY=; b=g9QlUIf9939g+IY0y1PGtF1/+9kGW9ItiDoyudrS3zrbTCZrcFAeJ1MQRs5FkEwlUuUCDrB1ATgvaSJJus+YUeKlkpcCnVq+W8ohlGYyuehOd9Tf4WQ87VUy/gJxa8ibCuXpWDgNDZp7sK1YzWPgTkQhYbZ6XhgBpaE7MKfIIFH+slDKfsoVEU3cCPbSSticFeVwLPfdY8DQqJ8VV6zAuXcEBL/2uaJnX3FCsR3Xud/Ot8rCDiRSemMtltF+inDasV6Llblad+xMtMeUo7WN7945MhhGek1LMwReEKsXSceeAUpIRPHiw41vLfszj8CtpWV/9/CTChOPTmx0QVvOWw== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IABTFSrOrCnyqkz6DQFwPMWA6bDJtt5Zl2rQtAxLQnY=; b=QDkZoelMB0NC6t1Q7r3eZjxpn4p6/1bX0IRij9KZj6RangOBAj16e9yrTLoY7WLI0ILyYT76KHk+8c139soz5qstyNMMZ0MEgRxmDcM+LPZdTdBOqkfpT2kFfLG2RQbZ1uKyoVSocuofUzBFfs0FdKJZPk6rRP5JOPK25+Bebrs= 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 AM9PR08MB5873.eurprd08.prod.outlook.com (2603:10a6:20b:2dd::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33; Mon, 23 Jan 2023 12:09:14 +0000 Received: from VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::bced:32a3:b77e:90a6]) by VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::bced:32a3:b77e:90a6%6]) with mapi id 15.20.6002.033; Mon, 23 Jan 2023 12:09:14 +0000 Message-ID: Date: Mon, 23 Jan 2023 12:09:12 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: [PATCH 3/4] [gdb/tdep, aarch64] Fix frame address of last insn in leaf function Content-Language: en-US To: Tom de Vries , gdb-patches@sourceware.org Cc: Bruno Larsen , Andrew Burgess References: <20230119104618.15503-1-tdevries@suse.de> <20230119104618.15503-4-tdevries@suse.de> <88c66a57-e69e-bd9f-7407-3b71fa9c6630@suse.de> From: Luis Machado In-Reply-To: <88c66a57-e69e-bd9f-7407-3b71fa9c6630@suse.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: LO4P123CA0482.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1a8::19) To VI1PR08MB3919.eurprd08.prod.outlook.com (2603:10a6:803:c4::31) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: VI1PR08MB3919:EE_|AM9PR08MB5873:EE_|AM7EUR03FT020:EE_|AS8PR08MB6565:EE_ X-MS-Office365-Filtering-Correlation-Id: dd32eab1-1332-479a-55e0-08dafd3aaa09 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: zT0vAn2VeSQND3TuEsisEnr7GOXSelLyU3YiQ0UseEWRYQxuFWuxqwl1ySf2tyoZ761d/gzt/HKsCvtmVbqVHNRdBHytWQVQdVHDIyXyy6Ej7ibRkgesMgop1Z4KbqnbqUXC1POQsJ5maOkxYLaplJZm4LeqAAMDHBJBDkOD87zhzDS8IPDC+0cXZy5QGoyK2UnqVuL34Pfi4ceTntsBqRCyO4YyARN83z0Gf5Qk6iJxcRDh4fZ/wFI9RgOc8pCKrEPUvL1D5NuEyYkrr6bPpYkffm0lO20S7aw8F5KQG8yJUxIzkYyPuDVquZQBiED0fnDB+WntywpeNMCq/taBek1BkUBWtKcrAaXndBohIssRuZ9WX5gErQRCAV/izwpqw0XRTVT6NT8ILQgKQAzVz2Th+wGkWW+KMFsqefiwnPvwxEheUjmZqSP7YZMuO8yEZbvvDQIddCutSKIVqcSACfXr8NzfJafeDUqENjZkWzQetCthGTkpDBxMuM65sAWSgCdV6hhIT7vcHzN2JWO7eAyXu+8fE+NtKgsKSBGyI2cGTfY/aIC1Zl2GqVhbgGqTc7wNB3KN0PWXlUYx/90W6TErRDzHZin0V6QkZ7tgiA9/DbzUmKDmM3Ou59It2NOKuL+QXxJ5fnisAWOVli9MumkxgYWqkgdsRQxfozt+9WI9rQE7v91disQ/EXkqyrRQTcwKUbIK35tN1IW+CGwHIhC8DEFefkbxpFyUNlxUVw9RvNac5zOjOnCsX5cbuNGE4Xk+7Uls2JrDWo7JfCR7bQ== 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)(396003)(366004)(39860400002)(376002)(136003)(346002)(451199015)(83380400001)(8676002)(6506007)(186003)(478600001)(53546011)(26005)(6512007)(2616005)(31696002)(38100700002)(86362001)(8936002)(5660300002)(2906002)(44832011)(41300700001)(66946007)(66476007)(4326008)(316002)(66556008)(6486002)(54906003)(36756003)(84970400001)(31686004)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR08MB5873 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: AM7EUR03FT020.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 300ab73a-f1ed-4f94-e665-08dafd3aa4bc X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: htQ1IZgkvGNDHvZrOwHj+EH6V56kvRF/roksSjLHD5cOJdYxVQ9QbqNzz4LXKGyWqs0Ewjnr9pwVLBbmKA9DNC90trx2L39vPh7MzVVsXHVskfUw1yx6b2yiUefdv2vGsGa9BaiePDZQ1rDlny5p2o+JQiwTjjAK8W9EPkm7l6tHlYzm28fDaZZwFMNrJXKVmQtfAritW1weqpp4eP818+Ort5FFGbpAv7ZYM2tIjmQGYulGtLesgYLBiSxcplRfJUZEAkQrGkDCsoPgt0J/EfrykT1AM+jC6tSqkO0Pvgsq/Z5nLLBlCEucXxYT9I/T7Mo8Da8Hya/4zCqZIhv/G5bVkqV+FzL/FcMb4FTqxJmXdI56ck6A0xk2KLWyv5hbFLgsPhK5CkNypK0ZSEcnP+E2IZtz9fLTIg7BNCokzRaoLc9AHN8ZzU82mR6VnXhGnrp+OmYdxfMxmn3R17yyz7GJkeXSDQIDc8h7fRjwyj+NdFbu64mA2e1sY1SC4JfD6KgKrThKfpA04DBRy+O/LVF+mZ0o4Tycq2uqsZnlnYexTPpevJz547URKfqgttEE+n8RB29OJNcaCNp+RQDBNDHgunbwTe5JM7AOdCb02WuX7Rcm16QVu8bb/m7NPJNjUm6nDQQv2GMjQPUKXkvg3lIMB0ix3VsJAFH+XciOBSJmVgx/kXxorLpBfKjsf6HbpBkj+K7OJz2yuoaBQjpfQJVye6gmoI0hAG7QXzg577Q= 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)(39860400002)(346002)(396003)(376002)(136003)(451199015)(36840700001)(46966006)(44832011)(2616005)(2906002)(40480700001)(8936002)(336012)(6512007)(26005)(186003)(356005)(316002)(36860700001)(5660300002)(54906003)(81166007)(82740400003)(6486002)(478600001)(31696002)(83380400001)(6506007)(107886003)(47076005)(41300700001)(53546011)(70586007)(4326008)(70206006)(8676002)(86362001)(31686004)(84970400001)(36756003)(82310400005)(43740500002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jan 2023 12:09:22.8234 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dd32eab1-1332-479a-55e0-08dafd3aaa09 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: AM7EUR03FT020.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6565 X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,FORGED_SPF_HELO,KAM_DMARC_NONE,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,TXREP,UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 1/23/23 11:59, Tom de Vries wrote: > On 1/23/23 11:07, Luis Machado wrote: >> On 1/19/23 10:46, Tom de Vries wrote: >>> Consider the test-case test.c, compiled without debug info: >>> ... >>> void >>> foo (const char *s) >>> { >>> } >>> >>> int >>> main (void) >>> { >>>    foo ("foo"); >>>    return 0; >>> } >>> ... >>> >>> Disassembly of foo: >>> ... >>> 0000000000400564 : >>>    400564:       d10043ff        sub     sp, sp, #0x10 >>>    400568:       f90007e0        str     x0, [sp, #8] >>>    40056c:       d503201f        nop >>>    400570:       910043ff        add     sp, sp, #0x10 >>>    400574:       d65f03c0        ret >>> ... >>> >>> Now, let's do "info frame" at each insn in foo, as well as printing $sp >>> and $x29 (and strip the output of info frame to the first line, for brevity): >>> ... >>> $ gdb -q a.out >>> Reading symbols from a.out... >>> (gdb) b *foo >>> Breakpoint 1 at 0x400564 >>> (gdb) r >>> Starting program: a.out >>> >>> Breakpoint 1, 0x0000000000400564 in foo () >>> (gdb) display /x $sp >>> 1: /x $sp = 0xfffffffff3a0 >>> (gdb) display /x $x29 >>> 2: /x $x29 = 0xfffffffff3a0 >>> (gdb) info frame >>> Stack level 0, frame at 0xfffffffff3a0: >>> (gdb) si >>> 0x0000000000400568 in foo () >>> 1: /x $sp = 0xfffffffff390 >>> 2: /x $x29 = 0xfffffffff3a0 >>> (gdb) info frame >>> Stack level 0, frame at 0xfffffffff3a0: >>> (gdb) si >>> 0x000000000040056c in foo () >>> 1: /x $sp = 0xfffffffff390 >>> 2: /x $x29 = 0xfffffffff3a0 >>> (gdb) info frame >>> Stack level 0, frame at 0xfffffffff3a0: >>> (gdb) si >>> 0x0000000000400570 in foo () >>> 1: /x $sp = 0xfffffffff390 >>> 2: /x $x29 = 0xfffffffff3a0 >>> (gdb) info frame >>> Stack level 0, frame at 0xfffffffff3a0: >>> (gdb) si >>> 0x0000000000400574 in foo () >>> 1: /x $sp = 0xfffffffff3a0 >>> 2: /x $x29 = 0xfffffffff3a0 >>> (gdb) info frame >>> Stack level 0, frame at 0xfffffffff3b0: >>>   pc = 0x400574 in foo; saved pc = 0x40058c >>> (gdb) si >>> 0x000000000040058c in main () >>> 1: /x $sp = 0xfffffffff3a0 >>> 2: /x $x29 = 0xfffffffff3a0 >>> ... >>> >>> The "frame at" bit lists 0xfffffffff3a0 except at the last insn, where it >>> lists 0xfffffffff3b0. >>> >>> The frame address is calculated here in aarch64_make_prologue_cache_1: >>> ... >>>    unwound_fp = get_frame_register_unsigned (this_frame, cache->framereg); >>>    if (unwound_fp == 0) >>>      return; >>> >>>    cache->prev_sp = unwound_fp + cache->framesize; >>> ... >>> >>> For insns after the prologue, we have cache->framereg == sp and >>> cache->framesize == 16, so unwound_fp + cache->framesize gives the wrong >>> answer once sp has been restored to entry value by the before-last insn. >>> >>> Fix this by detecting the situation that the sp has been restored. >>> >>> This fixes PR tdep/30011. >>> >>> This also fixes the aarch64 FAILs in gdb.reverse/solib-precsave.exp and >>> gdb.reverse/solib-reverse.exp I reported in PR gdb/PR29721. >> >> I still see failures for gdb.reverse/solib-precsave.exp and gdb.reverse/solib-reverse.exp for both Ubuntu 22.04 and 20.04 >> on aarch64-linux. >> >> Running /work/luimac01/work/builds/binutils-gdb-arm64-jammy/gdb/testsuite/../../../../repos/binutils-gdb/gdb/testsuite/gdb.reverse/solib-prec >> save.exp ... >> FAIL: gdb.reverse/solib-precsave.exp: reverse-step into solib function one >> FAIL: gdb.reverse/solib-precsave.exp: reverse-step within solib function one >> FAIL: gdb.reverse/solib-precsave.exp: reverse-step back to main one >> FAIL: gdb.reverse/solib-precsave.exp: reverse-step into solib function two >> FAIL: gdb.reverse/solib-precsave.exp: reverse-step within solib function two >> >> Running /work/luimac01/work/builds/binutils-gdb-arm64-jammy/gdb/testsuite/../../../../repos/binutils-gdb/gdb/testsuite/gdb.reverse/solib-reve >> rse.exp ... >> FAIL: gdb.reverse/solib-reverse.exp: reverse-step into solib function one >> FAIL: gdb.reverse/solib-reverse.exp: reverse-step within solib function one >> FAIL: gdb.reverse/solib-reverse.exp: reverse-step back to main one >> FAIL: gdb.reverse/solib-reverse.exp: reverse-step into solib function two >> FAIL: gdb.reverse/solib-reverse.exp: reverse-step within solib function two >> >> Maybe it addresses a different issue, but what I'm seeing is possibly something else (the linetable issue? I vaguely recall the situation for that). >>> > > Hi, > > that is very well possible.  I'm not claiming to fix the test-case on aarch64 in general, I'm very specifically claiming to fix the FAILs I reported in a PR. > > BTW the first FAIL in the PR is also different than the one you report above, which is usually a hint that there may be a different root cause. > > I'll commit (using an updated commit message claiming both PRs tdep/30010 and tdep/30011) once I do another round of testing. > > Thanks, > - Tom > Sounds good to me. Thanks for the patch.