From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2085.outbound.protection.outlook.com [40.107.104.85]) by sourceware.org (Postfix) with ESMTPS id 8941F3858D32 for ; Mon, 23 Jan 2023 10:07:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8941F3858D32 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=+xlINJtHXB2Brlc8ivHB0WtYtrzxhRW0Cw7Tw2CQCCI=; b=zTD2jaiFKWgwNbZfNZp0jFBXLSOdsK6SjS6IcUeCESfWcPE1TbnCqvRD3YipAao2m84UH/qiwF0uAEuebFrjm8q2qlzdfjMUWlSjGWDBmY2hkNNMjOskL228KEA5ppijw/QYI4BCfgr9/CE59qyUlGCeyfG1GofM4uZ8ITgWBoI= Received: from DB6PR0301CA0049.eurprd03.prod.outlook.com (2603:10a6:4:54::17) by GV1PR08MB7329.eurprd08.prod.outlook.com (2603:10a6:150:1c::16) 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 10:07:16 +0000 Received: from DBAEUR03FT021.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:54:cafe::34) by DB6PR0301CA0049.outlook.office365.com (2603:10a6:4:54::17) 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 10:07:16 +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 DBAEUR03FT021.mail.protection.outlook.com (100.127.142.184) 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 10:07:16 +0000 Received: ("Tessian outbound 43b0faad5a68:v132"); Mon, 23 Jan 2023 10:07:16 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: b36db31c4b92dac9 X-CR-MTA-TID: 64aa7808 Received: from a8e56b9997fd.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id CAA9CB97-8773-4C65-B4AE-568394EEFB51.1; Mon, 23 Jan 2023 10:07:08 +0000 Received: from EUR01-DB5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id a8e56b9997fd.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 23 Jan 2023 10:07:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OURutWg8PCCsPeOFFn+L2iVs0d1urWu50wJjFisedqyeSUx2vWkftisnOzueFP85FFIk2cvITzNsLIgr7GXijupISU9xm+WFUm/wx2D1Zo0sYpECTZHm2lGaG5buzEn68QxQ6QKkk/BeV2MD1fZlA2pA6ZcKiBxMnU14hfAy0ausBf8qMCIiLdooaVCf8JeYEUm6p+ZoM28ubJADTZJnMz3sWGDD1hFQbhBTps2iz9E906A78Q32KPuIhwm+rRaD/dgIgs65A9vmsrc06lOnNJRwsxlngqA85Jf0wBiWellq0NHUwOFJQgf2FxibNjWch/hfCdXFbsMGFHqZ9l4WKA== 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=+xlINJtHXB2Brlc8ivHB0WtYtrzxhRW0Cw7Tw2CQCCI=; b=hQg2zjPdr85rzRiHDrJu2YVBjDHtQqO2j9COQeCDNTulQxBMEGGN/xp5M/MlezmZ6FLxYQDOkPUWIfiYQYaDiBfIkk3aNarwp5FcKANipz5qXz8m5tNU+re43VJotnCod+vu/VKqqFLmu/2jnKOA6beSzhmXN2wDbUC/UUkuXwwRWIHibVyGEeJZyI4cF8trd1INx0CkI/fScootNczqD2c9OLDwzCmxaAli81uuzZBKTzzgPaekoozsWx3afY1idswXIsjMvQdRvR3rKN2YNAJcQJGs+U/hGw+efP32MbZc+owLCpx2cgd72ENrqoh5tlC4SR/ZbfkE8eBNugUAIQ== 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=+xlINJtHXB2Brlc8ivHB0WtYtrzxhRW0Cw7Tw2CQCCI=; b=zTD2jaiFKWgwNbZfNZp0jFBXLSOdsK6SjS6IcUeCESfWcPE1TbnCqvRD3YipAao2m84UH/qiwF0uAEuebFrjm8q2qlzdfjMUWlSjGWDBmY2hkNNMjOskL228KEA5ppijw/QYI4BCfgr9/CE59qyUlGCeyfG1GofM4uZ8ITgWBoI= 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 AM8PR08MB6625.eurprd08.prod.outlook.com (2603:10a6:20b:357::10) 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 10:07:05 +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 10:07:04 +0000 Message-ID: Date: Mon, 23 Jan 2023 10:07:05 +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> From: Luis Machado In-Reply-To: <20230119104618.15503-4-tdevries@suse.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LO2P265CA0176.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a::20) To VI1PR08MB3919.eurprd08.prod.outlook.com (2603:10a6:803:c4::31) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: VI1PR08MB3919:EE_|AM8PR08MB6625:EE_|DBAEUR03FT021:EE_|GV1PR08MB7329:EE_ X-MS-Office365-Filtering-Correlation-Id: c7274828-4762-4dca-d7a6-08dafd299b0e 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: jAqxEzJaWB220smuXcsTykGFdqhY57L9eEhBE210Otv4KrY1cdqQb+eTe3ImoZTA4rgpVuZSqG90zMnizpEtdzb3k49YjE6oILLbe80jlvHwCD+eRZJjnR7jNFx8U8hdb3wSmosDL1XU0Sw236WEFyhpR5WhVIdWint9qfBCf45JqmA/rvlFOz11tOFpCaNARW2fZorXw+61NZ6zYzQJ+vxMQO3xt2j3BXPoQchuqVdB09QpsMkgF6EnuCDVvl9MIWQfGmFoDrebDRFm+6BoNNJJtN8WnnL8Ezf+QPFMnfWQ030rG1aCw9SDGs/dtWFfDWT2mG7TNfbFoFCZjUUSK/BeIsPcNiZXoZTx7XGOlVqk4qURZrTwBEj6vMZwLnYt6q0J8/QRvObXakplh5jPNTiTwVmEdHioTeQY9Og23+vkaJNoRScc61NRgjPI71gGOeIvlMBz05xmzbc2T4Pu6w24Xq8gPLJW91oO27FASGJ3OQ9+etylHrzU8W4Seb8g1EhtOHMpH+WCRN5P9bWXFTxgHR6xo9EBhl2CSWTfrimkeOg5krByhrqpFT2UyVI7X0D3YAu5lXFZFuJ8uxdRW5Xm9AV7/xXfkU4Xi314t6hGjSWQTXzHCNnf/esHE4EL+ka69an4rPai4ididvvNBRaPK7EEoWaqe/uHXdY2iWhx4BBPyC46uGbSmQZ62xO/4tgHP+tYmUHSdyhy0fRHlqfRFD+rJC3GYmK0VQmwGuhyigGsUrmXMfVzepURVZeDn6tkNkn3AQNfWytRdV3xZA== 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)(376002)(396003)(39860400002)(136003)(366004)(346002)(451199015)(2616005)(4326008)(44832011)(66556008)(41300700001)(8936002)(36756003)(83380400001)(5660300002)(8676002)(316002)(54906003)(66946007)(66476007)(2906002)(6506007)(26005)(31696002)(86362001)(31686004)(38100700002)(6486002)(186003)(6512007)(478600001)(53546011)(966005)(84970400001)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR08MB6625 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: DBAEUR03FT021.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: e0e8fd0f-2655-46e5-9896-08dafd2993fb X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qDbId5rEqVWo24utMkOc4W4FmoSA4EdjzmT85RnY+vM93AH0e2Do9IsFz4lIOkKE786SeLIMSqn601HwqesROFB4twYrfLTf8dH5PWwEfoir89TWY6rEj4ObhZjRpZhLlCcHJ+fRmlfXFm48Ptr9IVDNeg7oflimLkMcNnl/byE2+51DjPXVTQ+xqjjm34g2oa0ZPWhmbsPr72FFztUc58Rvv01uqEcN3CCsYPFB+VDXhMKc9uah2sGe/OxBqIzleWbQKNYEue9Ii7xUvAaKmV+kFW1CouMRctjKjTV4jAobOlzOb02vhM9hxfCY6aP4IVoW9sOTgyD4wo0K4RQSlQsPAWuFKOGDlpOSij3JrP/N9GIMOFsfraEYhsvv9O0CXRLWl/AP6xHnEbyl8rPk8qYJc7FIQXzB2A0k1FbiA9KyqYXtKUeSEvhJFBkQZ9wrIqc+NRxGAUGOI5elc3DOFemxJirvRuSdh+wnGgYIHb2u2K0OLYniULGyRyWCXxAKfgVf6EN7wVyIeofst3aaX6o6JGBgQ8mouiTcflNR6iQXMnW7Kz04oBcUvsQz7N7Teas5WJaaOJvAzSMhU5TC3dduuBoFs3zZHxAj5O5mXod1gUknBjCqcJXRGGHpY1cawKmeda9RrXWD+MPdSoJmJuK31JXEH5K/Jsa9koVJRkB58GjAFcwrN+lDNLxUbCoh9tmh1d803rsvJ/xlIq6Ry158SbU76yaKY7ymhnU51sJF3pWXqm/UMYXpzOEi13RsNZX6u3L/fkcqtML3JgPVog== 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)(346002)(39860400002)(376002)(396003)(136003)(451199015)(46966006)(36840700001)(40470700004)(81166007)(82740400003)(36860700001)(31696002)(70586007)(86362001)(41300700001)(44832011)(5660300002)(40480700001)(2906002)(8936002)(70206006)(356005)(478600001)(82310400005)(2616005)(6512007)(6506007)(186003)(26005)(53546011)(83380400001)(336012)(47076005)(54906003)(4326008)(107886003)(8676002)(316002)(966005)(40460700003)(6486002)(84970400001)(31686004)(36756003)(43740500002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jan 2023 10:07:16.3117 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c7274828-4762-4dca-d7a6-08dafd299b0e 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: DBAEUR03FT021.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR08MB7329 X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,GIT_PATCH_0,KAM_DMARC_NONE,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,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 List-Id: 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). > > Tested on aarch64-linux. > PR tdep/30011 > Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30011 > --- > gdb/aarch64-tdep.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c > index b576d3b9d99..06349353716 100644 > --- a/gdb/aarch64-tdep.c > +++ b/gdb/aarch64-tdep.c > @@ -996,7 +996,11 @@ aarch64_make_prologue_cache_1 (frame_info_ptr this_frame, > if (unwound_fp == 0) > return; > > - cache->prev_sp = unwound_fp + cache->framesize; > + if (cache->framereg == AARCH64_SP_REGNUM > + && get_frame_register_unsigned (this_frame, AARCH64_FP_REGNUM) == unwound_fp) > + cache->prev_sp = unwound_fp; > + else > + cache->prev_sp = unwound_fp + cache->framesize; > > /* Calculate actual addresses of saved registers using offsets > determined by aarch64_analyze_prologue. */