From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2079.outbound.protection.outlook.com [40.107.7.79]) by sourceware.org (Postfix) with ESMTPS id D1B143871011 for ; Fri, 30 Jun 2023 13:46:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D1B143871011 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=six1ycyc4SE9sTZ2EOkSRmQWo8Uq64X+oPo5GzoFfbM=; b=9aS+2nw1osRU/oN56yHLOxBwep038X3853COdijjqX27KCl1NODesq0tcQuV3dx3RJ1QqPGn8nsimybKdLJgt6QjGfkWwdtCiVzmJruorp9XRdcWli6Rp0RzQpCuTIUK84kELf58TNi5w1UO/Oq2/OEWUpYyvO81xu8HBAWJpNU= Received: from DU2PR04CA0262.eurprd04.prod.outlook.com (2603:10a6:10:28e::27) by AM9PR08MB6228.eurprd08.prod.outlook.com (2603:10a6:20b:281::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.19; Fri, 30 Jun 2023 13:46:45 +0000 Received: from DBAEUR03FT040.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:28e:cafe::a0) by DU2PR04CA0262.outlook.office365.com (2603:10a6:10:28e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.22 via Frontend Transport; Fri, 30 Jun 2023 13:46:44 +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 DBAEUR03FT040.mail.protection.outlook.com (100.127.142.157) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.13 via Frontend Transport; Fri, 30 Jun 2023 13:46:44 +0000 Received: ("Tessian outbound 7c913606c6e6:v142"); Fri, 30 Jun 2023 13:46:44 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 05f9a1a3b47e1585 X-CR-MTA-TID: 64aa7808 Received: from 9095fab9f724.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id D54F5C19-D578-4D8D-88DC-DFD023F68908.1; Fri, 30 Jun 2023 13:46:37 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 9095fab9f724.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 30 Jun 2023 13:46:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ej03qj4IVGMGnNcicFExiJfOJYHVkl/AAOEOEkmtXn/Iar09bbYoUtTVtbP49JST43YKaxdfaOsMGMzEozkngT0eIuDQmCPLNuJofBX+VpxPJzWEknnKqfy5gLdJtzL12lA3dvW4S6BaIfcXRbM1LEx5N91v0JNY8bvX2ysYPpW563Of6scab8UgG26ZWqiNDpecLKZ85tSgKCASQO8Y66MYoJwu578OEb8uAU5kREYoLzlM0dzUapIkYLq55Mw4X8/PqsbY1YKZTBAZ2+e69PNJqMhzvcbpIfp/KrHlSpJq4MZKw3AKwkbSq8jPP9JfpJ5ef+Rh0ezhjS1TDAiRWw== 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=six1ycyc4SE9sTZ2EOkSRmQWo8Uq64X+oPo5GzoFfbM=; b=Ccp6tw2Dx4cad4i54rHhGdbYgNQdUqB/T9wdl7CG/GTcap1rMKeQulj2GuzC/XSqgQMKxjSYgPfL+RcgzCWcGHIHzH3pDidmML5srDwDMKvQ7tI/jkWoQoK2GiGbeMWRAky75/fiOKphZ/NvosYeP63soOwnD0+K9EH+PqQG0/S8YinSxCL9KCm+ktUcELbNqHzk61PYnEwp7WwtehfHLeKIEWUxLFYgA/4tKa/45QAGYPcmcTPEWx6xAWHvfxCGQQH3Sd/eAJHWTH8P1Z81DxZaWi7EhkaUlejZgSQ+LTAL+l9m1dAPCw3Am4aeARBo+lYlG2AOslGkZ1Mpv1SU4A== 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 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=six1ycyc4SE9sTZ2EOkSRmQWo8Uq64X+oPo5GzoFfbM=; b=9aS+2nw1osRU/oN56yHLOxBwep038X3853COdijjqX27KCl1NODesq0tcQuV3dx3RJ1QqPGn8nsimybKdLJgt6QjGfkWwdtCiVzmJruorp9XRdcWli6Rp0RzQpCuTIUK84kELf58TNi5w1UO/Oq2/OEWUpYyvO81xu8HBAWJpNU= Received: from AM6P191CA0089.EURP191.PROD.OUTLOOK.COM (2603:10a6:209:8a::30) by GV1PR08MB8238.eurprd08.prod.outlook.com (2603:10a6:150:5e::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.26; Fri, 30 Jun 2023 13:46:35 +0000 Received: from AM7EUR03FT053.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:8a:cafe::ba) by AM6P191CA0089.outlook.office365.com (2603:10a6:209:8a::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.22 via Frontend Transport; Fri, 30 Jun 2023 13:46:35 +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 AM7EUR03FT053.mail.protection.outlook.com (100.127.140.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6544.22 via Frontend Transport; Fri, 30 Jun 2023 13:46:35 +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.27; Fri, 30 Jun 2023 13:46:34 +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.27; Fri, 30 Jun 2023 13:46:34 +0000 Received: from e129171.arm.com (10.57.27.17) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Fri, 30 Jun 2023 13:46:34 +0000 From: Luis Machado To: Subject: [PATCH v3 12/16] [gdb/generic] corefile/bug: Use thread-specific gdbarch when dumping register state to core files Date: Fri, 30 Jun 2023 14:46:12 +0100 Message-ID: <20230630134616.1238105-13-luis.machado@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230630134616.1238105-1-luis.machado@arm.com> References: <20230630134616.1238105-1-luis.machado@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT053:EE_|GV1PR08MB8238:EE_|DBAEUR03FT040:EE_|AM9PR08MB6228:EE_ X-MS-Office365-Filtering-Correlation-Id: 06725503-5e81-45e7-18e1-08db7970715f 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: Kz06TtSf8nQZdllvKfnRWv7yYDPnEUwrIJmulgXejf2I7SK8lbsJxd5raGMKcjeQfIwKj/kmGh50lhNTYWJcIIdssCn5CkG1CkVZ8EF5h2Ynj2RYU5V1BVKdN1Bhh0XhGdVBK+OZRraZpLWI/KWdAocUVf4M8xGeVQnLdLF6nkwPZb4wZHZ47fhNA/TFZHme5rA7CzKyzkne2ESg5ODfreqi4foNnXB+/8G0/t8jUZtopezDSaZuCjxR5nONlj6PPj61odd2fTDUV+h8L/KlJwEdo4R6l0j6EKqziDQY8N5T8Y/OymchJJyfs2peT3D6mpnrfJpsn5yxx8+C34A7wvj/AJ7XQSeTxbhoyAQLZdD/ghFxosWyxLRGJ1g/c2uQZfx1zs7AJSjaFaemvVqhjbFeEdhabNOm+HgU/OPdUvtHZBzN7ON7fOMlNu7XJpWxoCVwemiRxsWs7tb6B4AMPRvZtpth1psvStzE0ykeAWWjvdNUyWEr9pDIizimSIk+LrAv83XUdFHLCjhHEAMVniJmZC55O5xSofMr7f8RboJSG+6saHy7hsl70ardY7tlFuCGAYm0SGYjJzwdT6QRCnWlXyQN7oCANON+uUbGJ7JV4wLDuYncFI+o/qBJnhsv1m6rRNm1/WDozWO1IbrN5A2VbK1ddtzhac5oPcL2I9WQupVPGHn3u6fSaJSVvjByi/O0bR3j9Xo4bdPnWBGheN3A7xmUwbERHdakL4tcQ+yH0/WumCZn2zJFupb0aURoPWwKAaTPXgyPcrYN6hpvQ8Yt79V0DHuFAV9to/WRxnQ= 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)(376002)(39860400002)(396003)(346002)(136003)(451199021)(46966006)(36840700001)(40470700004)(81166007)(82740400003)(356005)(47076005)(83380400001)(426003)(36860700001)(86362001)(36756003)(478600001)(70586007)(7696005)(40460700003)(6666004)(2616005)(41300700001)(70206006)(316002)(8936002)(8676002)(1076003)(336012)(186003)(26005)(6916009)(82310400005)(44832011)(5660300002)(2906002)(40480700001)(41533002)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR08MB8238 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT040.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 4508d315-7f42-4593-09f9-08db79706b97 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UvUA+tTH/kqYoT1N3goCbOR3pKszyuISnZMNL3AQvDzsH1DUAnSStiqdVyPpY+Ssn6cgXGunqJ2JsRih5dmF/9umzBMUa+8C+rBamHCaFN7YVQL1gDOJXsdcDtvYsTJuEuwC0YXUCsAbgdGYSpqdyUtcacKcpvQKjLsF/8/IzbMKDd3mQnzLGJZUXa0jQEaibfalnyeZzEEL0OrQstm47lVg3IBNu2D9QIlPnjL1yY8dtV13P2q+P5fFab+PujxVkT7xiB2DzYJNRvf/RA2dBxPLv3YFZ+U1QYalUV2X37RnGj6rgr5RawiOChzvGPmFE3M78hQYWA2Df1N/j/UFflKotLSnGayDsY3vxugFcR9imFUlbEq0+/8G6994oGzBhZ0qkgdrsql6JXrEbumUimnOYMMVaCkj7/NnkjHZ2qaP49eJZILOTg/SsIx5wyzAY8hfpLwVKwlpBlbajEU4pmQl9OKL9wen5EoHEC+mUTYXgae6NuThm+EQD68Nvd3BoJ8pheIga04+HrCDuLx7E6BAX0kxwL8TUGoZVYrlCTHA972SUA3G2C0FurSuEQR/n72fmi31peoChsAdniS0AdMFXtX9SrNm4GON9px+THSCWgyyttpiloABHPur4ewvXFwWBwR8VcwvczE39eSbX8G+s7XOT9R/YFm1RaI8ONSo0LI1puNq36VWjwMoL7TQrrn+PWqtmxZbo95MQSB5/NcpoTjYjhh/stXFW9+AIt0f7NMHfZ8rR4BQVTPB+vvEa+5YND4+GaHWib3vcQvV3g== 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)(396003)(376002)(136003)(346002)(39860400002)(451199021)(36840700001)(46966006)(40470700004)(316002)(40460700003)(41300700001)(83380400001)(82310400005)(86362001)(336012)(36860700001)(426003)(26005)(186003)(44832011)(1076003)(2616005)(2906002)(82740400003)(81166007)(40480700001)(47076005)(5660300002)(36756003)(8676002)(8936002)(6666004)(6916009)(7696005)(478600001)(70586007)(70206006)(41533002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jun 2023 13:46:44.8412 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 06725503-5e81-45e7-18e1-08db7970715f 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: DBAEUR03FT040.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR08MB6228 X-Spam-Status: No, score=-11.8 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 List-Id: 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 b5eee5e108c..7d0976932c6 100644 --- a/gdb/linux-tdep.c +++ b/gdb/linux-tdep.c @@ -2099,12 +2099,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); } -- 2.25.1