[v3,13/16,gdb/generic] corefile/bug: Fixup (gcore) core file target description reading order
Message ID | 20230630134616.1238105-14-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 8E2323870C2A for <patchwork@sourceware.org>; Fri, 30 Jun 2023 13:47:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8E2323870C2A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1688132871; bh=deVpjU4isaDUiTDh0rII9/5T1HubXEKwpZzGNmjkTvE=; 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=a6j1RDJuZ3fLWH3+/bYyaZQTrY/Rx4BL7UT3snSnRSPv0TVUBswCkPfQYsEf9hn23 3fLBe9NksZ6qJZ4pAogd1P7zZNEdsyDXZFMjnwRX2XFfTrdNu5bD9G83G5aO6ZjOyo xex/mn8a9OlCXJIB96pszhv3tTHfQQeK1BRpfktY= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2072.outbound.protection.outlook.com [40.107.105.72]) by sourceware.org (Postfix) with ESMTPS id 2C07B3870C37 for <gdb-patches@sourceware.org>; Fri, 30 Jun 2023 13:46:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2C07B3870C37 Received: from DUZPR01CA0177.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b3::26) by AM9PR08MB6017.eurprd08.prod.outlook.com (2603:10a6:20b:2dc::14) 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:44 +0000 Received: from DBAEUR03FT045.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:4b3:cafe::1f) by DUZPR01CA0177.outlook.office365.com (2603:10a6:10:4b3::26) 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 DBAEUR03FT045.mail.protection.outlook.com (100.127.142.142) 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 Received: ("Tessian outbound c63645f235c1:v142"); Fri, 30 Jun 2023 13:46:44 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: b5e7c8ac5af6a39d X-CR-MTA-TID: 64aa7808 Received: from df89bf784878.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 3A6383BC-E0F2-4C04-A97E-8F6D5A87807E.1; Fri, 30 Jun 2023 13:46:37 +0000 Received: from EUR03-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id df89bf784878.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=MKgswfX9p5zHyjYLt/3eXJmqjqCwSH/F1wig8LizOWUIDrbj9vouppT5bxxr7JQ5YyhwWP6cnzITCtoclY2YW0hd2XotqGGRlS5l8zNJz3M4C6+46lgNiQKG4t1GjIIvmop9sdebyGhXXz904ZCSw5jPUBvlJgfnSbweUFAWPsFoUxqYrfQhvT42rcdYxPkwT5sbpGM4FyU71dRWg8IPRjMFMHvx+eUXYa8JvZE358U19aBvCFXXrbzb3gZh8CdfZPE6xTiOmPDQsElh2iKaKhfSvc9tothQgEWMuCks0IlXPIw0g6hF/6L3eXPZntwmMPrLgld6iOhLH+NmxOUVqg== 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=deVpjU4isaDUiTDh0rII9/5T1HubXEKwpZzGNmjkTvE=; b=oOwpkyOySaA0lomUqLg2sgsGFQx0dx6MUA8SgAl2Z7HFHU6G3r9afHR/as/KnuTvGq+JmA1E9Ire4CzdejdlAoyDFVM84o/L7nQEaoZIX9M1j99IWPKHW/FDgrigVK2ypN7OBp6VYBy7xn+XOw4op4rOV7mjLkS+tXVnao43NX/rX525gD+8p9SLcl/lMvue+fUCakS7cOgalv0l4U8AVmTKIPyOCbFnhkoMgrlHRwRwLQSvVhkdOmwp7i4k/owaJLWAVunRFkfTtBqKtIwXcw3I/o1yBpBSHFcwcnDi5Bg7wsH6uNwzn26VEkyuB7PoKXDmQsj4eYfKG/2EZUZLDQ== 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 AS9PR04CA0111.eurprd04.prod.outlook.com (2603:10a6:20b:531::6) by VI1PR08MB5440.eurprd08.prod.outlook.com (2603:10a6:803:134::16) 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:36 +0000 Received: from AM7EUR03FT014.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:531:cafe::85) by AS9PR04CA0111.outlook.office365.com (2603:10a6:20b:531::6) 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:36 +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 AM7EUR03FT014.mail.protection.outlook.com (100.127.140.163) 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-EX03.Arm.com (10.251.24.31) 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.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 To: <gdb-patches@sourceware.org> Subject: [PATCH v3 13/16] [gdb/generic] corefile/bug: Fixup (gcore) core file target description reading order Date: Fri, 30 Jun 2023 14:46:13 +0100 Message-ID: <20230630134616.1238105-14-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: AM7EUR03FT014:EE_|VI1PR08MB5440:EE_|DBAEUR03FT045:EE_|AM9PR08MB6017:EE_ X-MS-Office365-Filtering-Correlation-Id: 5aa4227b-3b06-41e8-8bbf-08db797070fe 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: zA7HXflsh4K0+4uSsO9ILIWO1/CdAqGPdct95SL/LlFb9eIl3GzlDeMctoP42QITPO/KOMHNapb93jeWaJTeIvlWljIt2GQD8y882gGxVRtOHQgv+luEadOG7giaKwM1KTFcm8FQUW77AQiIbsz0uVu4NPofcuKWcF2GRcLJ/43IVJF5V8Kc0fEYe1VIjxKP18AOzIdYHigUbxUILve0AwTELdfNCnuf/pYRSYBjT8wezN/C6Cmcdv7DWrpa9SLxgUzVVSjznza8iXL0GTlIVH5T2FCmQAJPmUXERkjKGug3i6Zo6Yc0pnwzWTotxJiVn539WF4HTMnfAxAeq/3kfG+EVGi2ZmXFchPsZruzobZT79HV83CEZmuV5NdXm9SHFHI5MGFsfhIG5/M2ZP/RSgQeGfthwoj/fnEXwUTZCFyqVzSJeCajdOgX+EwEgEB8I/gi0OesSx8BucEngo5/hnM+S1kDJ6QZOvCAFcnlE0Gd5I6eGlgPYmEnBONtfzxsb6ZjGCzaumJoB2+Ekk9zocnJhFVQL59reMpE+49yDt02erCnTX+yy3/0obtvj/QXwJ6GKaA6hnJzaCzOa0pfPqD8204i+0Rjnn/v+9kpfwJpMxhcatk9jc2bsYmtoB0joW/3reokp+jMFvQIpY+speaDEw0WO+s8SCaUyiriCnMb2a6Q+J+Rtni7ptjM/4HopUDI272whYlpQ/iSFgPgtGQBIixJ4bh9DOiKsiMHrLAsaD3P7nIJiNKY6ObWdJ2eyS9h45RjMR3Zgbvno89vyLqcuSlYmGhQWJLXnizLbOk= 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)(39860400002)(346002)(136003)(396003)(376002)(451199021)(40470700004)(36840700001)(46966006)(6666004)(5660300002)(8676002)(8936002)(36756003)(478600001)(70206006)(70586007)(7696005)(6916009)(316002)(41300700001)(40460700003)(40480700001)(356005)(81166007)(47076005)(186003)(44832011)(2616005)(1076003)(26005)(86362001)(82310400005)(83380400001)(36860700001)(426003)(336012)(82740400003)(2906002)(41533002)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB5440 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT045.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 82660e91-9299-4b28-fc24-08db79706c1a X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wB1HYDVwvE35qhw56Wb7hlCe5T/iWp3za4sKDhOx8wyE4ddGH7h+Oylyx5i7bigGrqhMGDC9YmZCt+EzE2MHpWpFLh06RsR+smnIIJ/so+Adtuds7nvLH61ITEJbZOG1jTDky2qycfnv3EBxCUOTlhAOwG+AAD69onXUsDrIUU+OKjnFQ6qH4JW1PJxEt/Rs/ZaEjWNSMCxxDOQuOTbpnuF0HrePnFFQq2Py+E6CTmQ7R1/+SYRjROhwl9baa+R+qWS1PTn3sQTgWsqIxCtVnpu3LvtsKFjEkUXtbj6yLw5Vu4Qia6YHTpYE+HZijWa6ruxP/0qoq04rdcHvDw4JuFmhuyNYIAek0qD7c7kx3fRJcwZyJvbUnmwVGUIStc8nPnwx6NZWboJ6wcZRAo5PmJVmT04Y+vzZyfciWRAm0UQrba3O713H0gD3Oz7A4qqe6DCHTHkCKgmhmxxy9rurJl/2vmzIs7QOIo+dMwBOMCPZpkCojapo1/N+9mIqA0ryRh4LfdrJTK/RqY6gXAmVWu6XGWgXltboAKGmrL5ZvwQKiy3y6fOoZkya7PlRLTy1Bi6LOsHbXrOCDYlqVs634B3ROOOqP3WofGL2MOlZRD9/0PykcA8l77oTCuwNzZB+dy9oxFYdG7c1zfgEw12VGmi1lAK23jg9ncI0fdouftV4//z1/h+emv2RnOT6gtGAGQ6ryjbKN3AnboqIo2h9UEiWNPttr1gdT3X23VuNLCPUsVieMl+NXX0bckSph1x0N6tJqxMZEhxiPUaV06TL8Q== 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)(46966006)(40470700004)(36840700001)(316002)(40460700003)(41300700001)(83380400001)(426003)(82310400005)(36860700001)(86362001)(186003)(44832011)(26005)(2616005)(1076003)(336012)(2906002)(82740400003)(81166007)(40480700001)(47076005)(5660300002)(36756003)(8676002)(8936002)(6666004)(7696005)(6916009)(478600001)(70586007)(70206006)(41533002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jun 2023 13:46:44.1929 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5aa4227b-3b06-41e8-8bbf-08db797070fe 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: DBAEUR03FT045.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR08MB6017 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 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 |
SME support for AArch64 gdb/gdbserver on Linux
|
|
Commit Message
Luis Machado
June 30, 2023, 1:46 p.m. UTC
Due to the nature of the AArch64 SVE/SME extensions in GDB, each thread can potentially have distinct target descriptions/gdbarches. When loading a gcore-generated core file, at the moment GDB gives priority to the target description dumped to NT_GDB_TDESC. Though technically correct for most target, it doesn't work correctly for AArch64 with SVE or SME support. The correct approach for AArch64/Linux is to rely on the gdbarch_core_read_description hook, so it can figure out the proper target description for a given thread based on the various available register notes. I think this should work for other architectures as well. If not, we may need to adjust things so all architectures get the information that they need for discovering the target description of the core file. Regression-tested on aarch64-linux Ubuntu 22.04/20.04. --- gdb/corelow.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-)
Comments
Luis Machado via Gdb-patches <gdb-patches@sourceware.org> writes: > Due to the nature of the AArch64 SVE/SME extensions in GDB, each thread > can potentially have distinct target descriptions/gdbarches. > > When loading a gcore-generated core file, at the moment GDB gives priority > to the target description dumped to NT_GDB_TDESC. Though technically correct > for most target, it doesn't work correctly for AArch64 with SVE or SME > support. > > The correct approach for AArch64/Linux is to rely on the > gdbarch_core_read_description hook, so it can figure out the proper target > description for a given thread based on the various available register notes. > > I think this should work for other architectures as well. If not, we may > need to adjust things so all architectures get the information that they > need for discovering the target description of the core file. The code to load the target description from the core file was added in commit 95ce627aeb9d "gdb: write target description into core file", by Andrew Burgess. My understanding of that commit message is that it was added before the gdbarch hook on purpose, and my reading of: “My primary motivation for adding this feature is that, in a future commit, I will be adding support for bare metal core dumps on some targets. For RISC-V specifically, I want to be able to dump all the available control status registers. As different targets will present different sets of register in their target description, including registers that are possibly not otherwise known to GDB I wanted a way to capture these registers in the core dump.” is that it doesn't work if reading from the target description comes last, though I'm not sure about that. I copied him in this email to see if he would like to chime in.
On 7/28/23 04:12, Thiago Jung Bauermann wrote: > > Luis Machado via Gdb-patches <gdb-patches@sourceware.org> writes: > >> Due to the nature of the AArch64 SVE/SME extensions in GDB, each thread >> can potentially have distinct target descriptions/gdbarches. >> >> When loading a gcore-generated core file, at the moment GDB gives priority >> to the target description dumped to NT_GDB_TDESC. Though technically correct >> for most target, it doesn't work correctly for AArch64 with SVE or SME >> support. >> >> The correct approach for AArch64/Linux is to rely on the >> gdbarch_core_read_description hook, so it can figure out the proper target >> description for a given thread based on the various available register notes. >> >> I think this should work for other architectures as well. If not, we may >> need to adjust things so all architectures get the information that they >> need for discovering the target description of the core file. > > The code to load the target description from the core file was added in > commit 95ce627aeb9d "gdb: write target description into core file", by > Andrew Burgess. My understanding of that commit message is that it was > added before the gdbarch hook on purpose, and my reading of: > > “My primary motivation for adding this feature is that, in a future > commit, I will be adding support for bare metal core dumps on some > targets. For RISC-V specifically, I want to be able to dump all the > available control status registers. As different targets will present > different sets of register in their target description, including > registers that are possibly not otherwise known to GDB I wanted a way > to capture these registers in the core dump.” > > is that it doesn't work if reading from the target description comes > last, though I'm not sure about that. I copied him in this email to see > if he would like to chime in. > I think the risc-v case should still work as it doesn't provide a core_read_description hook. If one is added though, then gdb will give that hook preference. Usually the core_read_description hook is provided when the target runs hosted on an OS. So for bare metal we wouldn't have that hook implemented. Still, I agree we might want to make sure both of these features coexist. The assumption a tdesc is the same for all the threads of a process, and that this tdesc is exposed through a single note in the core file, doesn't hold true for AArch64 unfortunately. It would've been true if we had a sizeless vector type, in which case all the threads of a process for AArch64 would have the exact same tdesc.
Hi Andrew, On 7/28/23 04:12, Thiago Jung Bauermann wrote: > > Luis Machado via Gdb-patches <gdb-patches@sourceware.org> writes: > >> Due to the nature of the AArch64 SVE/SME extensions in GDB, each thread >> can potentially have distinct target descriptions/gdbarches. >> >> When loading a gcore-generated core file, at the moment GDB gives priority >> to the target description dumped to NT_GDB_TDESC. Though technically correct >> for most target, it doesn't work correctly for AArch64 with SVE or SME >> support. >> >> The correct approach for AArch64/Linux is to rely on the >> gdbarch_core_read_description hook, so it can figure out the proper target >> description for a given thread based on the various available register notes. >> >> I think this should work for other architectures as well. If not, we may >> need to adjust things so all architectures get the information that they >> need for discovering the target description of the core file. > > The code to load the target description from the core file was added in > commit 95ce627aeb9d "gdb: write target description into core file", by > Andrew Burgess. My understanding of that commit message is that it was > added before the gdbarch hook on purpose, and my reading of: > > “My primary motivation for adding this feature is that, in a future > commit, I will be adding support for bare metal core dumps on some > targets. For RISC-V specifically, I want to be able to dump all the > available control status registers. As different targets will present > different sets of register in their target description, including > registers that are possibly not otherwise known to GDB I wanted a way > to capture these registers in the core dump.” > > is that it doesn't work if reading from the target description comes > last, though I'm not sure about that. I copied him in this email to see > if he would like to chime in. > It would be great to have your input on this, as the approaches seem to conflict somewhat. Could you please take a look at this entry (and, if possible, in the other generic pieces too), to make sure we can come up with something that works for all cases? Thanks, Luis
diff --git a/gdb/corelow.c b/gdb/corelow.c index 0a7ff56848a..de750b6c039 100644 --- a/gdb/corelow.c +++ b/gdb/corelow.c @@ -1080,6 +1080,21 @@ core_target::thread_alive (ptid_t ptid) const struct target_desc * core_target::read_description () { + /* If the architecture provides a corefile target description hook, use + it now. Even if the core file contains a target description in a note + section, it is not useful for targets that can potentially have distinct + descriptions for each thread. One example is AArch64's SVE/SME + extensions that allow per-thread vector length changes, resulting in + registers with different sizes. */ + if (m_core_gdbarch && gdbarch_core_read_description_p (m_core_gdbarch)) + { + const struct target_desc *result; + + result = gdbarch_core_read_description (m_core_gdbarch, this, core_bfd); + if (result != nullptr) + return result; + } + /* If the core file contains a target description note then we will use that in preference to anything else. */ bfd_size_type tdesc_note_size = 0; @@ -1103,15 +1118,6 @@ core_target::read_description () } } - if (m_core_gdbarch && gdbarch_core_read_description_p (m_core_gdbarch)) - { - const struct target_desc *result; - - result = gdbarch_core_read_description (m_core_gdbarch, this, core_bfd); - if (result != NULL) - return result; - } - return this->beneath ()->read_description (); }