Message ID | 20230607094010.57892-1-luis.machado@arm.com |
---|---|
State | New |
Headers |
Return-Path: <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D55D33858288 for <patchwork@sourceware.org>; Wed, 7 Jun 2023 09:40:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D55D33858288 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1686130858; bh=zPxkte9qovFqsXC4UK14v6mgE0l2iy7Jlrku84jTgJA=; h=To:CC:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=fQWiQ27vR5bnExELoRTr1hIOQ6Z2N06k+/QEoyxEi8Pks5WXPZ1E+Bxm11pLfdfM1 BuqED2fKQ+ZHb2aasuyNUwPkRYbvhvs5+0O5phePHtIdsxLbz8eh5OGsQ7eJVt7wwp +zCFkUlfWS7OOxVQ7ZRiHlF+8ZCDATZ83Q6zXjgE= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2051.outbound.protection.outlook.com [40.107.241.51]) by sourceware.org (Postfix) with ESMTPS id 958D83858C54 for <gdb-patches@sourceware.org>; Wed, 7 Jun 2023 09:40:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 958D83858C54 Received: from AS9PR06CA0194.eurprd06.prod.outlook.com (2603:10a6:20b:45d::29) by DBBPR08MB6284.eurprd08.prod.outlook.com (2603:10a6:10:20e::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.32; Wed, 7 Jun 2023 09:40:25 +0000 Received: from AM7EUR03FT052.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:45d:cafe::c4) by AS9PR06CA0194.outlook.office365.com (2603:10a6:20b:45d::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.33 via Frontend Transport; Wed, 7 Jun 2023 09:40:25 +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 AM7EUR03FT052.mail.protection.outlook.com (100.127.140.214) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.19 via Frontend Transport; Wed, 7 Jun 2023 09:40:25 +0000 Received: ("Tessian outbound 3570909035da:v136"); Wed, 07 Jun 2023 09:40:25 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 4c15e7061922d666 X-CR-MTA-TID: 64aa7808 Received: from ad106c36dbae.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 4F73D31B-CB5A-4835-9F88-68EC53A8A150.1; Wed, 07 Jun 2023 09:40:19 +0000 Received: from EUR01-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id ad106c36dbae.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 07 Jun 2023 09:40:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RmVpKl0bv+tl30WLTKsFS0ND5dHcAXhyd6JNRYu/ZOCiSU9S2oZMc9bnP+xKKPI5YOt6p9W95OQQOrw2nyvXMBWeB9IjIFVciV3kqecEsiKzpjbFuuD/sit+7gS2qRbjt8pvAgdJ2f1R5u5lu0IIDAaNfrBNh+ZUxz8e5aj7eTXGmkocruvW06icq817FnwJz01Q1AINX8T96lYih8Ku9P9fezxZpCGFI/1ibiCsZT/E+tHEqmYznIOmHrW4M63PZFcDyCF0h6raob1x5fcx3GpRx3493IoK46rRRy1if22+6gORMFqfHklcJO6AbOKwVaQsafR7FyfWujFHA8Lr2w== 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=zPxkte9qovFqsXC4UK14v6mgE0l2iy7Jlrku84jTgJA=; b=AcrxK643DDxCMFeP8VERBIzlnmqmMHTxzihttSlExW7CCaaH4+Vh5PEvXu10JrZS3yuK0jtKC5e4NFivOWP7yCWAV/ympoliYbKJeLzAe9E3+10CdD2hjfEVNsghhT5q4jjAYGLDmSoWnaK6FZ7UrpvUnprGLoINxg/Qe+UJnDuBCaxblwad9l9sZAJEasP6cA86S1r6VxERsKkRwe8o4GNSIlWtJy5XLe4vMs9vd5mG1R//ANtnMc+4gu0UFqGWku/O2lsPz9K3UPsGtsGU0k9KSDOhwtINugFupEY8fasrBA/teUnA6h2HPto5BCnb5NV6zXh9dN32lwp+T7aMWQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=sourceware.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none Received: from AS8PR04CA0101.eurprd04.prod.outlook.com (2603:10a6:20b:31e::16) by AS4PR08MB8023.eurprd08.prod.outlook.com (2603:10a6:20b:586::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.32; Wed, 7 Jun 2023 09:40:17 +0000 Received: from AM7EUR03FT032.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:31e:cafe::d3) by AS8PR04CA0101.outlook.office365.com (2603:10a6:20b:31e::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.19 via Frontend Transport; Wed, 7 Jun 2023 09:40:17 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; pr=C Received: from nebula.arm.com (40.67.248.234) by AM7EUR03FT032.mail.protection.outlook.com (100.127.140.65) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6477.19 via Frontend Transport; Wed, 7 Jun 2023 09:40:17 +0000 Received: from AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Wed, 7 Jun 2023 09:40:17 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Wed, 7 Jun 2023 09:40:16 +0000 Received: from e129171.arm.com (10.57.74.1) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.23 via Frontend Transport; Wed, 7 Jun 2023 09:40:16 +0000 To: <gdb-patches@sourceware.org> CC: <tdevries@suse.de> Subject: [PATCH] Fix PR30369 regression on aarch64/arm (PR30506) Date: Wed, 7 Jun 2023 10:40:10 +0100 Message-ID: <20230607094010.57892-1-luis.machado@arm.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT032:EE_|AS4PR08MB8023:EE_|AM7EUR03FT052:EE_|DBBPR08MB6284:EE_ X-MS-Office365-Filtering-Correlation-Id: eb34c78a-0f8e-4210-ba3d-08db673b38bc 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: V1PFZUnHtvyJ4B40Bth07dxHRD26trTSLIal8jh7vm4TzLC5DFa85MAzUPCqF6HA4DdEVVmAKojkQKybTF+cYcTtVJNbzUwxf28sUX9tu6n5ejFc55gLFBBvZP41PpnAlru0k6u1TIMJRMmMcXKFEw/tySw2h2drW2+LNcuX9nKosvou+qHv5vO3WBgf9O879QCowWwjD1d7n3WTd61RIUR3T+cqGmEdkThizZXaQBgQCqnOcoLRyDs6aBSGOifexFfZZ9GojPIso+BUoWxlOtlwDMBVg29uCyfHzcriTw/CB7Sg1lvmC27QNNwxF15YTWihO9lCT/0ZCXJe5VZO+pB1cMEJhaYA6ywfXpRYNkDX8lL6vREOac7yLYjF9iAe1gGlhMjo8iuw4EfhfPKNssnhXHMIK4Wi+GqJwhMv7ZY92A7R1ohV4GIVkQb11VP02AxLs9D/Q/m4SXGUBCe+cylFGNPyNoysfZSY8864fRxPwJsX7v06QLzM5ByvWCahxoppdo+qKossMmO95t2w/PxqtGh4t+f/msZybEb0wu2/CZcoyRvm3ryVN88gsJJIwpcaT892zE7IdmpE80G0VrJL9uxbBttnOERZXzqBF6hX8aKU4qR5/WJMb7RrkwOIytVukqn9ZglUW9R/N3AsZyhy6mHEpYfbdTnqI59Y4RIKMQ/K0xVCNPvRtJBX6wuPWzCoq34atxGS4qT7V0sh1tnnrVbetvDTISSkkPs7ZOCaN+//so8qTf2E6zuJ6S8M X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:nebula.arm.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230028)(4636009)(396003)(39860400002)(376002)(136003)(346002)(451199021)(36840700001)(40470700004)(46966006)(186003)(83380400001)(40460700003)(47076005)(426003)(2906002)(336012)(2616005)(86362001)(36756003)(82310400005)(81166007)(82740400003)(40480700001)(356005)(36860700001)(1076003)(966005)(316002)(41300700001)(6666004)(5660300002)(8936002)(8676002)(7696005)(478600001)(4326008)(70206006)(70586007)(6916009)(26005)(44832011)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR08MB8023 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT052.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: d95fd673-82ba-45e0-d140-08db673b33dd X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: waH7CLQIaoCbVmi5vP8LNfQkzscFDlAn3+NJJEBO3vSZ1FtV68jyQmgrR4pZ5MRGbBS7pF/dGkb+au/nPs4Pb2tQtNvFKwxGWWR5xn4pyHUz4sQDp3b0dMl9+zjYaLDHirwOCrigkavy9GrcNwYpMk80nacavvwAnBw06jXH9FeYezhyP7ptfAu70lushWzl5tXfZHWbXREgmR4U2aAPNCDHPcnXG2QAFjOVZopz/4vfBIh3UKmjXsZm4xwpfzEXkPSb5Uj2nqdvwxH2PdawCtXRYaiuyNb6QVj9bQ8NC6GAFmgGMnwNkLB+WGDnjwO+3l5CL+PRx7LYvCG/LTr7unsvboOIp+4bO8rWr+LZdrg2Cm+ba0wZY+bGdIDkPzuUxqkdsmNzfXj3N1lnoUN1CcPUVXsWmoToReVnz1QcwIKImo0gbwYU7bD3oGW3tThdtJX3RqmxjMk0ITMRpZFYDwXBl+GFCtwbnZqcVdof07X+EXOccOjXzXqCaeg1UQiMzGX/BWclAOeX3lcArU5cneGcn1x695TKVnyb/wAZq/++FuWtBpmQJKWf4Rd2BOSwS5EbVnQoRq7uJbtCd7qCjBTN5OPoXRHT3BcGkCXXHD/ne74tkQXlayFw3ddQRWNpLW47ZetvJtKWltjSshPMdKhURet6hd/fucKMkj+ipzPXsaXa6B2/gBbU3cXVlTLuECDygYivv5p5yZ4obkQ72Df/v003GKStR7tYe5XmTAE= 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:(13230028)(4636009)(39860400002)(376002)(396003)(136003)(346002)(451199021)(40470700004)(46966006)(36840700001)(40460700003)(47076005)(336012)(2906002)(426003)(83380400001)(2616005)(36756003)(82310400005)(86362001)(40480700001)(82740400003)(81166007)(36860700001)(966005)(316002)(41300700001)(6666004)(5660300002)(107886003)(7696005)(8936002)(186003)(8676002)(478600001)(4326008)(70586007)(70206006)(6916009)(26005)(1076003)(44832011); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jun 2023 09:40:25.5212 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: eb34c78a-0f8e-4210-ba3d-08db673b38bc 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: AM7EUR03FT052.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB6284 X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_NONE, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, 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 <gdb-patches.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=subscribe> From: Luis Machado via Gdb-patches <gdb-patches@sourceware.org> Reply-To: Luis Machado <luis.machado@arm.com> Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> |
Series |
Fix PR30369 regression on aarch64/arm (PR30506)
|
|
Commit Message
Luis Machado
June 7, 2023, 9:40 a.m. UTC
From: Tom de Vries <tdevries@suse.de>
The gdb.dwarf2/dw2-prologue-end-2.exp test was failing for both AArch64 and
Arm.
As Tom pointed out here (https://inbox.sourceware.org/gdb-patches/6663707c-4297-c2f2-a0bd-f3e84fc62aad@suse.de/),
there are issues with both the prologue skipper for AArch64 and Arm and an
incorrect assumption by the testcase.
This patch fixes both of AArch64's and Arm's prologue skippers to not skip past
the end of a function. It also incorporates a fix to the testcase so it
doesn't assume the prologue skipper will stop at the first instruction of the
functions/labels.
Regression-tested on aarch64-linux/arm-linux Ubuntu 20.04/22.04 and
x86_64-linux Ubuntu 20.04.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30506
Co-Authored-By: Tom de Vries <tdevries@suse.de>
Co-Authored-By: Luis Machado <luis.machado@arm.com>
---
gdb/aarch64-tdep.c | 10 +++++++--
gdb/arm-tdep.c | 21 ++++++++++++++++---
.../gdb.dwarf2/dw2-prologue-end-2.exp | 10 ++++-----
3 files changed, 31 insertions(+), 10 deletions(-)
Comments
On 6/7/23 11:40, Luis Machado wrote: > From: Tom de Vries <tdevries@suse.de> > > The gdb.dwarf2/dw2-prologue-end-2.exp test was failing for both AArch64 and > Arm. > > As Tom pointed out here (https://inbox.sourceware.org/gdb-patches/6663707c-4297-c2f2-a0bd-f3e84fc62aad@suse.de/), > there are issues with both the prologue skipper for AArch64 and Arm and an > incorrect assumption by the testcase. > > This patch fixes both of AArch64's and Arm's prologue skippers to not skip past > the end of a function. It also incorporates a fix to the testcase so it > doesn't assume the prologue skipper will stop at the first instruction of the > functions/labels. > > Regression-tested on aarch64-linux/arm-linux Ubuntu 20.04/22.04 and > x86_64-linux Ubuntu 20.04. > Hi Luis, thanks for picking this up. LGTM. Thanks, - Tom > Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30506 > > Co-Authored-By: Tom de Vries <tdevries@suse.de> > Co-Authored-By: Luis Machado <luis.machado@arm.com> > --- > gdb/aarch64-tdep.c | 10 +++++++-- > gdb/arm-tdep.c | 21 ++++++++++++++++--- > .../gdb.dwarf2/dw2-prologue-end-2.exp | 10 ++++----- > 3 files changed, 31 insertions(+), 10 deletions(-) > > diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c > index d8603c45fd3..84a90b63b55 100644 > --- a/gdb/aarch64-tdep.c > +++ b/gdb/aarch64-tdep.c > @@ -917,12 +917,15 @@ aarch64_analyze_prologue_test (void) > static CORE_ADDR > aarch64_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) > { > - CORE_ADDR func_addr, limit_pc; > + CORE_ADDR func_addr, func_end_addr, limit_pc; > > /* See if we can determine the end of the prologue via the symbol > table. If so, then return either PC, or the PC after the > prologue, whichever is greater. */ > - if (find_pc_partial_function (pc, NULL, &func_addr, NULL)) > + bool func_addr_found > + = find_pc_partial_function (pc, NULL, &func_addr, &func_end_addr); > + > + if (func_addr_found) > { > CORE_ADDR post_prologue_pc > = skip_prologue_using_sal (gdbarch, func_addr); > @@ -942,6 +945,9 @@ aarch64_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) > if (limit_pc == 0) > limit_pc = pc + 128; /* Magic. */ > > + limit_pc > + = func_end_addr == 0? limit_pc : std::min (limit_pc, func_end_addr - 4); > + > /* Try disassembling prologue. */ > return aarch64_analyze_prologue (gdbarch, pc, limit_pc, NULL); > } > diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c > index d5128754f02..a0f59557072 100644 > --- a/gdb/arm-tdep.c > +++ b/gdb/arm-tdep.c > @@ -1769,12 +1769,18 @@ arm_skip_stack_protector(CORE_ADDR pc, struct gdbarch *gdbarch) > static CORE_ADDR > arm_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) > { > - CORE_ADDR func_addr, limit_pc; > + CORE_ADDR func_addr, func_end_addr, limit_pc; > > /* See if we can determine the end of the prologue via the symbol table. > If so, then return either PC, or the PC after the prologue, whichever > is greater. */ > - if (find_pc_partial_function (pc, NULL, &func_addr, NULL)) > + bool func_addr_found > + = find_pc_partial_function (pc, NULL, &func_addr, &func_end_addr); > + > + /* Whether the function is thumb mode or not. */ > + bool func_is_thumb = false; > + > + if (func_addr_found) > { > CORE_ADDR post_prologue_pc > = skip_prologue_using_sal (gdbarch, func_addr); > @@ -1811,7 +1817,8 @@ arm_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) > associate prologue code with the opening brace; so this > lets us skip the first line if we think it is the opening > brace. */ > - if (arm_pc_is_thumb (gdbarch, func_addr)) > + func_is_thumb = arm_pc_is_thumb (gdbarch, func_addr); > + if (func_is_thumb) > analyzed_limit = thumb_analyze_prologue (gdbarch, func_addr, > post_prologue_pc, NULL); > else > @@ -1837,6 +1844,14 @@ arm_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) > if (limit_pc == 0) > limit_pc = pc + 64; /* Magic. */ > > + /* Set the correct adjustment based on whether the function is thumb mode or > + not. We use it to get the address of the last instruction in the > + function (as opposed to the first address of the next function). */ > + CORE_ADDR adjustment = func_is_thumb? 2 : 4; > + > + limit_pc > + = func_end_addr == 0? limit_pc : std::min (limit_pc, > + func_end_addr - adjustment); > > /* Check if this is Thumb code. */ > if (arm_pc_is_thumb (gdbarch, pc)) > diff --git a/gdb/testsuite/gdb.dwarf2/dw2-prologue-end-2.exp b/gdb/testsuite/gdb.dwarf2/dw2-prologue-end-2.exp > index 488f85f9674..c506cfd55cc 100644 > --- a/gdb/testsuite/gdb.dwarf2/dw2-prologue-end-2.exp > +++ b/gdb/testsuite/gdb.dwarf2/dw2-prologue-end-2.exp > @@ -95,15 +95,15 @@ if { $break_addr == "" } { > > # Get the "foo_label" address. > > -set foo_label_addr "" > -gdb_test_multiple "print /x &foo_label" "" { > +set bar_label_addr "" > +gdb_test_multiple "print /x &bar_label" "" { > -re -wrap "= ($hex)" { > - set foo_label_addr $expect_out(1,string) > + set bar_label_addr $expect_out(1,string) > pass $gdb_test_name > } > } > > -if { $foo_label_addr == "" } { > +if { $bar_label_addr == "" } { > return > } > > @@ -115,4 +115,4 @@ gdb_test "print &foo_end == &bar_label" " = 1" > # Check that the breakpoint is set at the expected address. Regression test > # for PR30369. > > -gdb_assert { $break_addr == $foo_label_addr } > +gdb_assert { $break_addr < $bar_label_addr }
On 6/7/23 10:55, Tom de Vries wrote: > On 6/7/23 11:40, Luis Machado wrote: >> From: Tom de Vries <tdevries@suse.de> >> >> The gdb.dwarf2/dw2-prologue-end-2.exp test was failing for both AArch64 and >> Arm. >> >> As Tom pointed out here (https://inbox.sourceware.org/gdb-patches/6663707c-4297-c2f2-a0bd-f3e84fc62aad@suse.de/), >> there are issues with both the prologue skipper for AArch64 and Arm and an >> incorrect assumption by the testcase. >> >> This patch fixes both of AArch64's and Arm's prologue skippers to not skip past >> the end of a function. It also incorporates a fix to the testcase so it >> doesn't assume the prologue skipper will stop at the first instruction of the >> functions/labels. >> >> Regression-tested on aarch64-linux/arm-linux Ubuntu 20.04/22.04 and >> x86_64-linux Ubuntu 20.04. >> > > Hi Luis, > > thanks for picking this up. > > LGTM. > Great. Thanks. Pushed now. > Thanks, > - Tom > >> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30506 >> >> Co-Authored-By: Tom de Vries <tdevries@suse.de> >> Co-Authored-By: Luis Machado <luis.machado@arm.com> >> --- >> gdb/aarch64-tdep.c | 10 +++++++-- >> gdb/arm-tdep.c | 21 ++++++++++++++++--- >> .../gdb.dwarf2/dw2-prologue-end-2.exp | 10 ++++----- >> 3 files changed, 31 insertions(+), 10 deletions(-) >> >> diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c >> index d8603c45fd3..84a90b63b55 100644 >> --- a/gdb/aarch64-tdep.c >> +++ b/gdb/aarch64-tdep.c >> @@ -917,12 +917,15 @@ aarch64_analyze_prologue_test (void) >> static CORE_ADDR >> aarch64_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) >> { >> - CORE_ADDR func_addr, limit_pc; >> + CORE_ADDR func_addr, func_end_addr, limit_pc; >> /* See if we can determine the end of the prologue via the symbol >> table. If so, then return either PC, or the PC after the >> prologue, whichever is greater. */ >> - if (find_pc_partial_function (pc, NULL, &func_addr, NULL)) >> + bool func_addr_found >> + = find_pc_partial_function (pc, NULL, &func_addr, &func_end_addr); >> + >> + if (func_addr_found) >> { >> CORE_ADDR post_prologue_pc >> = skip_prologue_using_sal (gdbarch, func_addr); >> @@ -942,6 +945,9 @@ aarch64_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) >> if (limit_pc == 0) >> limit_pc = pc + 128; /* Magic. */ >> + limit_pc >> + = func_end_addr == 0? limit_pc : std::min (limit_pc, func_end_addr - 4); >> + >> /* Try disassembling prologue. */ >> return aarch64_analyze_prologue (gdbarch, pc, limit_pc, NULL); >> } >> diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c >> index d5128754f02..a0f59557072 100644 >> --- a/gdb/arm-tdep.c >> +++ b/gdb/arm-tdep.c >> @@ -1769,12 +1769,18 @@ arm_skip_stack_protector(CORE_ADDR pc, struct gdbarch *gdbarch) >> static CORE_ADDR >> arm_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) >> { >> - CORE_ADDR func_addr, limit_pc; >> + CORE_ADDR func_addr, func_end_addr, limit_pc; >> /* See if we can determine the end of the prologue via the symbol table. >> If so, then return either PC, or the PC after the prologue, whichever >> is greater. */ >> - if (find_pc_partial_function (pc, NULL, &func_addr, NULL)) >> + bool func_addr_found >> + = find_pc_partial_function (pc, NULL, &func_addr, &func_end_addr); >> + >> + /* Whether the function is thumb mode or not. */ >> + bool func_is_thumb = false; >> + >> + if (func_addr_found) >> { >> CORE_ADDR post_prologue_pc >> = skip_prologue_using_sal (gdbarch, func_addr); >> @@ -1811,7 +1817,8 @@ arm_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) >> associate prologue code with the opening brace; so this >> lets us skip the first line if we think it is the opening >> brace. */ >> - if (arm_pc_is_thumb (gdbarch, func_addr)) >> + func_is_thumb = arm_pc_is_thumb (gdbarch, func_addr); >> + if (func_is_thumb) >> analyzed_limit = thumb_analyze_prologue (gdbarch, func_addr, >> post_prologue_pc, NULL); >> else >> @@ -1837,6 +1844,14 @@ arm_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) >> if (limit_pc == 0) >> limit_pc = pc + 64; /* Magic. */ >> + /* Set the correct adjustment based on whether the function is thumb mode or >> + not. We use it to get the address of the last instruction in the >> + function (as opposed to the first address of the next function). */ >> + CORE_ADDR adjustment = func_is_thumb? 2 : 4; >> + >> + limit_pc >> + = func_end_addr == 0? limit_pc : std::min (limit_pc, >> + func_end_addr - adjustment); >> /* Check if this is Thumb code. */ >> if (arm_pc_is_thumb (gdbarch, pc)) >> diff --git a/gdb/testsuite/gdb.dwarf2/dw2-prologue-end-2.exp b/gdb/testsuite/gdb.dwarf2/dw2-prologue-end-2.exp >> index 488f85f9674..c506cfd55cc 100644 >> --- a/gdb/testsuite/gdb.dwarf2/dw2-prologue-end-2.exp >> +++ b/gdb/testsuite/gdb.dwarf2/dw2-prologue-end-2.exp >> @@ -95,15 +95,15 @@ if { $break_addr == "" } { >> # Get the "foo_label" address. >> -set foo_label_addr "" >> -gdb_test_multiple "print /x &foo_label" "" { >> +set bar_label_addr "" >> +gdb_test_multiple "print /x &bar_label" "" { >> -re -wrap "= ($hex)" { >> - set foo_label_addr $expect_out(1,string) >> + set bar_label_addr $expect_out(1,string) >> pass $gdb_test_name >> } >> } >> -if { $foo_label_addr == "" } { >> +if { $bar_label_addr == "" } { >> return >> } >> @@ -115,4 +115,4 @@ gdb_test "print &foo_end == &bar_label" " = 1" >> # Check that the breakpoint is set at the expected address. Regression test >> # for PR30369. >> -gdb_assert { $break_addr == $foo_label_addr } >> +gdb_assert { $break_addr < $bar_label_addr } >
>>>>> "Luis" == Luis Machado via Gdb-patches <gdb-patches@sourceware.org> writes:
Luis> + = func_end_addr == 0? limit_pc : std::min (limit_pc,
Luis> + func_end_addr - adjustment);
Missing space before the "?". There's another instance as well.
Tom
On 6/9/23 15:25, Tom Tromey wrote: >>>>>> "Luis" == Luis Machado via Gdb-patches <gdb-patches@sourceware.org> writes: > > Luis> + = func_end_addr == 0? limit_pc : std::min (limit_pc, > Luis> + func_end_addr - adjustment); > > Missing space before the "?". There's another instance as well. > > Tom Oops. How about the following to address this and other such issues I found? diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index 84a90b63b55..21dd6c7a38c 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -946,7 +946,7 @@ aarch64_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) limit_pc = pc + 128; /* Magic. */ limit_pc - = func_end_addr == 0? limit_pc : std::min (limit_pc, func_end_addr - 4); + = func_end_addr == 0 ? limit_pc : std::min (limit_pc, func_end_addr - 4); /* Try disassembling prologue. */ return aarch64_analyze_prologue (gdbarch, pc, limit_pc, NULL); diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index a0f59557072..6d4c9d04cbc 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -1504,7 +1504,7 @@ thumb_analyze_prologue (struct gdbarch *gdbarch, arm_debug_printf ("Found pacbti instruction at %s", paddress (gdbarch, start)); arm_debug_printf ("RA is %s", - *ra_signed_state? "signed" : "not signed"); + *ra_signed_state ? "signed" : "not signed"); cache->ra_signed_state = ra_signed_state; } @@ -1847,11 +1847,11 @@ arm_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) /* Set the correct adjustment based on whether the function is thumb mode or not. We use it to get the address of the last instruction in the function (as opposed to the first address of the next function). */ - CORE_ADDR adjustment = func_is_thumb? 2 : 4; + CORE_ADDR adjustment = func_is_thumb ? 2 : 4; limit_pc - = func_end_addr == 0? limit_pc : std::min (limit_pc, - func_end_addr - adjustment); + = func_end_addr == 0 ? limit_pc : std::min (limit_pc, + func_end_addr - adjustment); /* Check if this is Thumb code. */ if (arm_pc_is_thumb (gdbarch, pc)) @@ -8625,7 +8625,7 @@ arm_displaced_init_closure (struct gdbarch *gdbarch, CORE_ADDR from, arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch); unsigned int i, len, offset; enum bfd_endian byte_order_for_code = gdbarch_byte_order_for_code (gdbarch); - int size = dsc->is_thumb? 2 : 4; + int size = dsc->is_thumb ? 2 : 4; const gdb_byte *bkp_insn; offset = 0; @@ -10935,13 +10935,13 @@ arm_dump_tdep (struct gdbarch *gdbarch, struct ui_file *file) gdb_printf (file, _("arm_dump_tdep: vfp_register_count = %i\n"), (int) tdep->vfp_register_count); gdb_printf (file, _("arm_dump_tdep: have_s_pseudos = %s\n"), - tdep->have_s_pseudos? "true" : "false"); + tdep->have_s_pseudos ? "true" : "false"); gdb_printf (file, _("arm_dump_tdep: s_pseudo_base = %i\n"), (int) tdep->s_pseudo_base); gdb_printf (file, _("arm_dump_tdep: s_pseudo_count = %i\n"), (int) tdep->s_pseudo_count); gdb_printf (file, _("arm_dump_tdep: have_q_pseudos = %s\n"), - tdep->have_q_pseudos? "true" : "false"); + tdep->have_q_pseudos ? "true" : "false"); gdb_printf (file, _("arm_dump_tdep: q_pseudo_base = %i\n"), (int) tdep->q_pseudo_base); gdb_printf (file, _("arm_dump_tdep: q_pseudo_count = %i\n"), @@ -10949,7 +10949,7 @@ arm_dump_tdep (struct gdbarch *gdbarch, struct ui_file *file) gdb_printf (file, _("arm_dump_tdep: have_neon = %i\n"), (int) tdep->have_neon); gdb_printf (file, _("arm_dump_tdep: have_mve = %s\n"), - tdep->have_mve? "yes" : "no"); + tdep->have_mve ? "yes" : "no"); gdb_printf (file, _("arm_dump_tdep: mve_vpr_regnum = %i\n"), tdep->mve_vpr_regnum); gdb_printf (file, _("arm_dump_tdep: mve_pseudo_base = %i\n"), @@ -10971,13 +10971,13 @@ arm_dump_tdep (struct gdbarch *gdbarch, struct ui_file *file) gdb_printf (file, _("arm_dump_tdep: Lowest pc = 0x%lx\n"), (unsigned long) tdep->lowest_pc); gdb_printf (file, _("arm_dump_tdep: have_pacbti = %s\n"), - tdep->have_pacbti? "yes" : "no"); + tdep->have_pacbti ? "yes" : "no"); gdb_printf (file, _("arm_dump_tdep: pacbti_pseudo_base = %i\n"), tdep->pacbti_pseudo_base); gdb_printf (file, _("arm_dump_tdep: pacbti_pseudo_count = %i\n"), tdep->pacbti_pseudo_count); gdb_printf (file, _("arm_dump_tdep: is_m = %s\n"), - tdep->is_m? "yes" : "no"); + tdep->is_m ? "yes" : "no"); } #if GDB_SELF_TEST @@ -12328,7 +12328,7 @@ arm_record_ld_st_reg_offset (arm_insn_decode_record *arm_insn_r) break; case 1: - offset_12 = (!shift_imm)?0:u_regval[0] >> shift_imm; + offset_12 = (!shift_imm) ? 0 : u_regval[0] >> shift_imm; break; case 2:
>>>>> "Luis" == Luis Machado via Gdb-patches <gdb-patches@sourceware.org> writes: Luis> Oops. How about the following to address this and other such issues I found? Looks good, thank you. Reviewed-By: Tom Tromey <tom@tromey.com> Tom
On 6/9/23 16:26, Tom Tromey wrote: >>>>>> "Luis" == Luis Machado via Gdb-patches <gdb-patches@sourceware.org> writes: > > Luis> Oops. How about the following to address this and other such issues I found? > > Looks good, thank you. > > Reviewed-By: Tom Tromey <tom@tromey.com> > > Tom Thanks. Pushed now.
diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index d8603c45fd3..84a90b63b55 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -917,12 +917,15 @@ aarch64_analyze_prologue_test (void) static CORE_ADDR aarch64_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) { - CORE_ADDR func_addr, limit_pc; + CORE_ADDR func_addr, func_end_addr, limit_pc; /* See if we can determine the end of the prologue via the symbol table. If so, then return either PC, or the PC after the prologue, whichever is greater. */ - if (find_pc_partial_function (pc, NULL, &func_addr, NULL)) + bool func_addr_found + = find_pc_partial_function (pc, NULL, &func_addr, &func_end_addr); + + if (func_addr_found) { CORE_ADDR post_prologue_pc = skip_prologue_using_sal (gdbarch, func_addr); @@ -942,6 +945,9 @@ aarch64_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) if (limit_pc == 0) limit_pc = pc + 128; /* Magic. */ + limit_pc + = func_end_addr == 0? limit_pc : std::min (limit_pc, func_end_addr - 4); + /* Try disassembling prologue. */ return aarch64_analyze_prologue (gdbarch, pc, limit_pc, NULL); } diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index d5128754f02..a0f59557072 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -1769,12 +1769,18 @@ arm_skip_stack_protector(CORE_ADDR pc, struct gdbarch *gdbarch) static CORE_ADDR arm_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) { - CORE_ADDR func_addr, limit_pc; + CORE_ADDR func_addr, func_end_addr, limit_pc; /* See if we can determine the end of the prologue via the symbol table. If so, then return either PC, or the PC after the prologue, whichever is greater. */ - if (find_pc_partial_function (pc, NULL, &func_addr, NULL)) + bool func_addr_found + = find_pc_partial_function (pc, NULL, &func_addr, &func_end_addr); + + /* Whether the function is thumb mode or not. */ + bool func_is_thumb = false; + + if (func_addr_found) { CORE_ADDR post_prologue_pc = skip_prologue_using_sal (gdbarch, func_addr); @@ -1811,7 +1817,8 @@ arm_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) associate prologue code with the opening brace; so this lets us skip the first line if we think it is the opening brace. */ - if (arm_pc_is_thumb (gdbarch, func_addr)) + func_is_thumb = arm_pc_is_thumb (gdbarch, func_addr); + if (func_is_thumb) analyzed_limit = thumb_analyze_prologue (gdbarch, func_addr, post_prologue_pc, NULL); else @@ -1837,6 +1844,14 @@ arm_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) if (limit_pc == 0) limit_pc = pc + 64; /* Magic. */ + /* Set the correct adjustment based on whether the function is thumb mode or + not. We use it to get the address of the last instruction in the + function (as opposed to the first address of the next function). */ + CORE_ADDR adjustment = func_is_thumb? 2 : 4; + + limit_pc + = func_end_addr == 0? limit_pc : std::min (limit_pc, + func_end_addr - adjustment); /* Check if this is Thumb code. */ if (arm_pc_is_thumb (gdbarch, pc)) diff --git a/gdb/testsuite/gdb.dwarf2/dw2-prologue-end-2.exp b/gdb/testsuite/gdb.dwarf2/dw2-prologue-end-2.exp index 488f85f9674..c506cfd55cc 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-prologue-end-2.exp +++ b/gdb/testsuite/gdb.dwarf2/dw2-prologue-end-2.exp @@ -95,15 +95,15 @@ if { $break_addr == "" } { # Get the "foo_label" address. -set foo_label_addr "" -gdb_test_multiple "print /x &foo_label" "" { +set bar_label_addr "" +gdb_test_multiple "print /x &bar_label" "" { -re -wrap "= ($hex)" { - set foo_label_addr $expect_out(1,string) + set bar_label_addr $expect_out(1,string) pass $gdb_test_name } } -if { $foo_label_addr == "" } { +if { $bar_label_addr == "" } { return } @@ -115,4 +115,4 @@ gdb_test "print &foo_end == &bar_label" " = 1" # Check that the breakpoint is set at the expected address. Regression test # for PR30369. -gdb_assert { $break_addr == $foo_label_addr } +gdb_assert { $break_addr < $bar_label_addr }