From patchwork Tue Apr 11 04:26:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Machado X-Patchwork-Id: 67603 Return-Path: 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 4D2EA3854144 for ; Tue, 11 Apr 2023 04:28:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4D2EA3854144 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1681187326; bh=JbnQvPTlVprlstoi/plTxbeZbt3sqmzvhXPD4OSnbzM=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=VAa1riwClgNmyp8eeFEkLO7gDptwrtNlp4CSVGArLGzeucwswMUiiTS/CqZQyaXGF PdRLUHCZYGSY90rZoLLB8W3fU1nJjTUXAePd6k4YFd8DIqGJTjD2joOZokVyvmt+RO eYVm8+Rn5Ys0WSAjEOW73enBDGYAXzSX4dUiq5lI= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2070.outbound.protection.outlook.com [40.107.20.70]) by sourceware.org (Postfix) with ESMTPS id 4F27B3857720 for ; Tue, 11 Apr 2023 04:27:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4F27B3857720 Received: from AS8PR04CA0009.eurprd04.prod.outlook.com (2603:10a6:20b:310::14) by DB3PR08MB8796.eurprd08.prod.outlook.com (2603:10a6:10:433::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.36; Tue, 11 Apr 2023 04:27:21 +0000 Received: from AM7EUR03FT013.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:310:cafe::3b) by AS8PR04CA0009.outlook.office365.com (2603:10a6:20b:310::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.39 via Frontend Transport; Tue, 11 Apr 2023 04:27:21 +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 AM7EUR03FT013.mail.protection.outlook.com (100.127.140.191) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.28 via Frontend Transport; Tue, 11 Apr 2023 04:27:21 +0000 Received: ("Tessian outbound 8b05220b4215:v136"); Tue, 11 Apr 2023 04:27:21 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 0c48f11271d9977a X-CR-MTA-TID: 64aa7808 Received: from 4eb28081e741.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 62C5E450-B2C2-4898-B815-72FFE705BA7F.1; Tue, 11 Apr 2023 04:27:15 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 4eb28081e741.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 11 Apr 2023 04:27:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QTGkkpBL8YY2PD1iRjYbNuypI+gflIo6dw6avBqG0yz22NOYULCNpxnqZJPIxmoXTJ78kgdILZA91eVNMzzQj9EWSCx96K+/BN8oNKPzfXaqEmSto1dixpowEuKALTW36rMsq2svp3vR1r4dfK5juA/lT8k3Lnpd5a1SXv7vFQ4zwWzcASK2KUJ3KpmTd16JASHyArbrX7sOUk+sM2WXClYDGoee7DpR1piv3aorrqQX4m7zzxiFplhzIJzUswJJrLTvWZBiHkiMW65CGGSS+OZBAUdakNET1rCftC/TsoAFwhNxt7K5wOFjlSvOdJwqpUBNfFCHIl3MQkpD6sZQ1A== 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=JbnQvPTlVprlstoi/plTxbeZbt3sqmzvhXPD4OSnbzM=; b=ErybaDGQDdt5dxj9hYxhzYaDfgPqKuqYaIjiF+/VGNN8X0Pxtc6t3WrUjfV3Dl2HPNIFFhuSvMfj7EtNpbu3S2y9CoA0C+28ExtUmLVE/N57vO/u41dWnlh/RglRadZ8o0no84FGQplrQ0pqEupnk6xiIt+ocorw6vklRoBdX9stJoYBNoFg0q6LhWvVou+rlF0CbnC8ByjUdqtGSjdTJPyLKuhsyl97/D93MP79twhKCYLGSEvpvu4X+GHSBcx62mk2VV02Lo4UENVpmxJTT2BOdL7A27X+41ghzu2oyEMVEfPHazSKqDpnrVQ4bfs+srnxNKKs5Yyr254gVOdcOw== 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 AS9PR07CA0007.eurprd07.prod.outlook.com (2603:10a6:20b:46c::15) by VI1PR08MB5310.eurprd08.prod.outlook.com (2603:10a6:803:135::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38; Tue, 11 Apr 2023 04:27:13 +0000 Received: from AM7EUR03FT005.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:46c:cafe::c7) by AS9PR07CA0007.outlook.office365.com (2603:10a6:20b:46c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.27 via Frontend Transport; Tue, 11 Apr 2023 04:27:13 +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 AM7EUR03FT005.mail.protection.outlook.com (100.127.140.218) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.28 via Frontend Transport; Tue, 11 Apr 2023 04:27:13 +0000 Received: from AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.17; Tue, 11 Apr 2023 04:27:06 +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.17; Tue, 11 Apr 2023 04:27:06 +0000 Received: from e129171.arm.com (10.57.80.123) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.17 via Frontend Transport; Tue, 11 Apr 2023 04:27:06 +0000 To: Subject: [PATCH 13/17] [gdb/generic] corefile/bug: Use thread-specific gdbarch when dumping register state to core files Date: Tue, 11 Apr 2023 05:26:54 +0100 Message-ID: <20230411042658.1852730-14-luis.machado@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230411042658.1852730-1-luis.machado@arm.com> References: <20230411042658.1852730-1-luis.machado@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT005:EE_|VI1PR08MB5310:EE_|AM7EUR03FT013:EE_|DB3PR08MB8796:EE_ X-MS-Office365-Filtering-Correlation-Id: 6cf2a724-072d-41b3-f817-08db3a450af9 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: 59q6YvdO0eZZguQ4gPzGJdv7VLclRcgroYMESOP3v/IsHdLdsT9U5q02Ilm3I8t9iepg5frfqS37DxorQs2isCY8BFRxAI/UWd0Mv/5OndMyM2P5Kw5xwwLGOt32xYhf8no7qtAaujM0j/PhASK1+sfvUTChYiglbBCEXxmwEsfeiZjohUrjZIb5D98nw1EoNpD8x2dxZJZ/akdDi2E6AlDRPYhGaa/m03eD+khmYN9Sgs2L3OUcO3l4Vurt2f+nuYCnFPTfryzXDZqzK5aZ8UwVoDJWy4CWuE5bqe101vkjzAgqo6BFJv2a/3xNdh/jn/jj0LLQFcWOX/pd+JGjG5Q/l0pJp41BzxojVV+7NbGSWHyMWWR1qAxhs+OkUTx34lqw3XuBBQ0lmD54HTCScnXinBj2Nkh2QNOq7+vI4fEKHz0D9YuOauf3Lmo+dqRApwO4Pdh7nmLvBcr5IHDFxmhBAyXE8OSihDcaJq075GzsboKGfp36xBsgbw5+KlMjbJJA0jNUGnzGt40hx/MqKSc2+urKS79n2B5DkLon7ZkpLp4ePnjEoWtnAJvSqJPCubA5O7hqd19NCCLZVnfuB/UBt+Y8AuqyCGLfM5qks/4bRv/4W1cKLrjCB6GLxDQaWrNwMmrhZ6pr1Cql3UvVT7nh+RbVu7A4ZSvqzvAChyeyS/0xFDeB+l8F0t9kq4JcEg96iYKBIGUWEUQrl655JbyEjMDi30M3A9q/IcvlxUU= 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)(136003)(376002)(346002)(39850400004)(451199021)(36840700001)(46966006)(36756003)(83380400001)(36860700001)(5660300002)(41300700001)(8936002)(47076005)(316002)(44832011)(82740400003)(478600001)(356005)(6666004)(81166007)(2616005)(186003)(70586007)(70206006)(6916009)(2906002)(86362001)(8676002)(7696005)(26005)(82310400005)(336012)(426003)(1076003)(40480700001)(41533002)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB5310 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT013.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 36ff55b0-f832-4bdd-8314-08db3a450654 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vOF1h8QFPHMFnaOiuj6SHfydoBEiSq5QGWCGHtNE5WJPWU6et3iLHoCR5jqmOMw145sB/CZeSuWRYgYtR6amac98047VOyiVuSOwN3mZkEBnZn7NmtLLCxfVj8NHrPVBEYjyBAq5ZF3asE3FVywMtbJzgr62EZJsuDVl2s6hmtmkxlgEq8MY4SmomWvKQeHi9xQJVjT5WpVgqgh05gQwLW96q96thquhLCkZxipxzcnL7LrcZpVGpY4gHp/LXLMXB4C22wWr0qIU/PhdffYYj/pUgQru2XjeZxnQcYrurBDqPyKiVABPesQMf9D2/P1AFlggLAjP/+mzd17bL+/iO1O8qBdJxH6jNi+pP6m33Qkap6VLG7Buk+HN+ANOfJ2VvuJTbFiay8GNMNK3MvMgoBnXSaM4jL+2hSG2bqw32A61hbX3O6Fa1tYHbioE3cJzUZQWuEh7K9haeyJEj3dqA879AcK7HCDpJQYvmTFV/7LRfepWPfMVXUg5z8Xp2xXL1XS5Y4L7bZjecqysR41jPuD0QMkNzZ1uUl8WYeMrDZtwDr5J+4zgw3eYLp3k0aX9WLiIxYZ27gzmRvidPP9ZX9+Mmayp2mFJZsmHOUazrxExFx48cSpCq9w+jawN5e4qf7UQFsYd2zoLZ5ReJqUwP4ih8icd1cYJi4ajnhXaStpLpj463Iii7gZp4NCP/ywyc1/Fyd1thmWhqYYRUUCuUA== 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)(376002)(346002)(39850400004)(396003)(136003)(451199021)(36840700001)(46966006)(8936002)(6666004)(7696005)(40480700001)(44832011)(5660300002)(6916009)(86362001)(8676002)(70586007)(70206006)(478600001)(316002)(82310400005)(36860700001)(82740400003)(81166007)(83380400001)(2906002)(1076003)(186003)(2616005)(336012)(426003)(47076005)(41300700001)(36756003)(26005)(41533002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2023 04:27:21.3740 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6cf2a724-072d-41b3-f817-08db3a450af9 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: AM7EUR03FT013.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR08MB8796 X-Spam-Status: No, score=-11.2 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, RCVD_IN_VALIDITY_RPBL, 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-Patchwork-Original-From: Luis Machado via Gdb-patches From: Luis Machado Reply-To: Luis Machado Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" When we have a core file generated by gdb (via the gcore command), gdb dumps the target description to a note. During loading of that core file, gdb will first try to load that saved target description. This works fine for almost all architectures. But AArch64 has a few dynamically-generated target descriptions/gdbarch depending on the vector length that was in use at the time the core file was generated. The target description gdb dumps to the core file note is the one generated at the time of attachment/startup. If, for example, the SVE vector length changed during execution, this would not reflect on the core file, as gdb would still dump the initial target description. Another issue is that the gdbarch potentially doesn't match the thread's real gdbarch, and so things like the register cache may have different formats and sizes. To address this, fetch the thread's architecture before dumping its register state. That way we will always use the correct target description/gdbarch. --- gdb/linux-tdep.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c index 1fc9cb6faee..6749a39cfc2 100644 --- a/gdb/linux-tdep.c +++ b/gdb/linux-tdep.c @@ -2091,12 +2091,28 @@ linux_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, int *note_size) stop_signal); if (signalled_thr != nullptr) - linux_corefile_thread (signalled_thr, &thread_args); + { + /* On some architectures, like AArch64, each thread can have a distinct + gdbarch (due to scalable extensions), and using the inferior gdbarch + is incorrect. + + Fetch each thread's gdbarch and pass it down to the lower layers so + we can dump the right set of registers. */ + thread_args.gdbarch = target_thread_architecture (signalled_thr->ptid); + linux_corefile_thread (signalled_thr, &thread_args); + } for (thread_info *thr : current_inferior ()->non_exited_threads ()) { if (thr == signalled_thr) continue; + /* On some architectures, like AArch64, each thread can have a distinct + gdbarch (due to scalable extensions), and using the inferior gdbarch + is incorrect. + + Fetch each thread's gdbarch and pass it down to the lower layers so + we can dump the right set of registers. */ + thread_args.gdbarch = target_thread_architecture (thr->ptid); linux_corefile_thread (thr, &thread_args); }