From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on2052.outbound.protection.outlook.com [40.107.15.52]) by sourceware.org (Postfix) with ESMTPS id A9C313857359 for ; Tue, 11 Apr 2023 04:27:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A9C313857359 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=LZ2+i3DZIAhYdVLdS8HHfzM9+Lb/trJYF/SR+V1w3lE=; b=sOv2SiLdpZ6ErrGokXZ+RUMWjorv2atjbe6jbVtmo8eY4DlQgf5//3CYlHvGILlZgkc6ge7KruotucIpi97gZ2rKepZ6DjSuBwiiPleklKG1r51tNWTWDDMYTCag9JlfEiyTA6dEXc0ZPl8XTSqd09Gw5Kc638ygHtmqA1M15+w= Received: from AS8PR04CA0166.eurprd04.prod.outlook.com (2603:10a6:20b:331::21) by AM8PR08MB5636.eurprd08.prod.outlook.com (2603:10a6:20b:1c6::17) 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:34 +0000 Received: from AM7EUR03FT058.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:331:cafe::47) by AS8PR04CA0166.outlook.office365.com (2603:10a6:20b:331::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38 via Frontend Transport; Tue, 11 Apr 2023 04:27:34 +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 AM7EUR03FT058.mail.protection.outlook.com (100.127.140.247) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.25 via Frontend Transport; Tue, 11 Apr 2023 04:27:34 +0000 Received: ("Tessian outbound 945aec65ec65:v136"); Tue, 11 Apr 2023 04:27:34 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: a65c8a3706f22c81 X-CR-MTA-TID: 64aa7808 Received: from c6e7268d1bdf.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 4325322C-CF75-415A-8BB2-77099354C3EC.1; Tue, 11 Apr 2023 04:27:28 +0000 Received: from EUR02-DB5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id c6e7268d1bdf.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 11 Apr 2023 04:27:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mViTIpDXrY63J9w6IsKA2ba2yLINLodzG9j+ksBrkZrX/fUFq9aYVyo+qK/mCRthsgFG9D6ZP8f01RLMSMXVT16PMQ11Fq+lZnVyG0ztPYqvwimS2ki1sqm82ZVKN7IS/FUSAX5dbmsks2feh3Yoymx6+UFQliy51tpLHiXKZEfuJ8MoIbJEpte4cO5RQKJPlzcQroYSGpXbfrHaG0jEpP0dfYMD6GsDlLsbxxpXZRhGGNBcTyYZgh+qfYJPma48yFiXU91t+eSK1qDtSKdcy108mtZjBNPUGfNVhhj8zmcF3kPSBdceHjlmhVGrlPpPG/FA5Nt7da6UZJyUfSHeIw== 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=LZ2+i3DZIAhYdVLdS8HHfzM9+Lb/trJYF/SR+V1w3lE=; b=FDj+2iS8T0+yD6p6UfFYZNuQGM6p+XUiYzU1Pr7wHEBh7L6xrjmVkaXKHTof50SQsTSIJXsQhb0kZuUueFGzCfbEvI6fRG0WgP3NVubb+XlGl7ddAEBZO4zbG7PnhDNiu01d2eagnBBVmTJTshXUQXX7MC6IS951C4D9gTF1iLp6zZz3grKKtQTQyoKv+FN6MtEOYCPaTUbo/UZ/CWOBGfs5g3RW0ShN/PwjWXcW5MQdhQbr9+7x9OJI0oh6rP6xrdgi4SnURG+QUI0awD4+7UGLmy9oP7qTLAVQOV2LOmhhndCoqaZX/tcNpRrqNWzD6mRJ2VVzrAOj3ymS3uP62g== 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=LZ2+i3DZIAhYdVLdS8HHfzM9+Lb/trJYF/SR+V1w3lE=; b=sOv2SiLdpZ6ErrGokXZ+RUMWjorv2atjbe6jbVtmo8eY4DlQgf5//3CYlHvGILlZgkc6ge7KruotucIpi97gZ2rKepZ6DjSuBwiiPleklKG1r51tNWTWDDMYTCag9JlfEiyTA6dEXc0ZPl8XTSqd09Gw5Kc638ygHtmqA1M15+w= Received: from AM5PR0202CA0022.eurprd02.prod.outlook.com (2603:10a6:203:69::32) by AS2PR08MB10251.eurprd08.prod.outlook.com (2603:10a6:20b:647::18) 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:13 +0000 Received: from AM7EUR03FT010.eop-EUR03.prod.protection.outlook.com (2603:10a6:203:69:cafe::e7) by AM5PR0202CA0022.outlook.office365.com (2603:10a6:203:69::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.34 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 AM7EUR03FT010.mail.protection.outlook.com (100.127.141.22) 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-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.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 From: Luis Machado To: Subject: [PATCH 14/17] [gdb/generic] corefile/bug: Fixup (gcore) core file target description reading order Date: Tue, 11 Apr 2023 05:26:55 +0100 Message-ID: <20230411042658.1852730-15-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 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT010:EE_|AS2PR08MB10251:EE_|AM7EUR03FT058:EE_|AM8PR08MB5636:EE_ X-MS-Office365-Filtering-Correlation-Id: b60af0fd-00a2-4b2d-86b8-08db3a4512d9 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: bg6wCbIICfDCoozDQtaDhAPbT9bO+VXRspIdZgRBdFrIgJK/4BOrDZPEGQYRZt1ZszFe2ckJXLV0cVq53SV0KM05kgh+7eo3C0wY/CqfU1Jf5O2Y6HPba6Af224VnhnrQ+GL+760z6jD9qoaGh14ay+Hf4c8oNs86EWoKcAswtV1D7TaUCRmDcOw71OiS7Ki5WtZlxmOWt4Lw2AL3k4kElRZrz+3wtf3Fkd1+BwwF1xiHfKelX+eKms7IYEmvgOY4YvwX8y0SaAqi2x17R6Hf38wvuzxpNrIc9fFgRy8+2y4zWJQV29l7RVCzmuvVasX+XLn1EjUrXlVYPcmiJ2wFsNvcZKiNiFPXBLhpAvATuTJYJKrgVJe+YYnSyuXmfWUhJnS9B2ZItgB4z3Tz5Yj/Pb7zZ3AZqlrEkAlua6g3bbHlIeNK/5J3Wr4Dr9/z6zd6In8YLvkYK+Kap9zZvR0LwBYV2YPQZ38froLMg9JuBblMNNfhwxoiDB2eZP6QbMqgutt+oGlTNTnBOdmeqMgJ41cUBkFEEJSpBPdIcLfZEJhqLNuJAagK4w+NfYqbxLXiDAt/mwapOKwcYS4trjo01/qWQWljbUUZ5nFy4B1zn2GfyQ9pSnCqsutj6fC77OMkden2xOo6Td41jUz5k4CF2Nazwea1Yci1C0YEQYTEH+ryQWxaUg2w8lYnxI27RdNUx5MWTQKKoDv9yOmo7VM6cTEPI3A1jfxalwxqYY/MdQ= 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)(396003)(136003)(39860400002)(346002)(451199021)(46966006)(36840700001)(6666004)(7696005)(478600001)(40480700001)(47076005)(83380400001)(36756003)(356005)(81166007)(82740400003)(86362001)(2616005)(36860700001)(426003)(336012)(2906002)(44832011)(316002)(186003)(1076003)(26005)(8936002)(82310400005)(5660300002)(41300700001)(6916009)(8676002)(70586007)(70206006)(41533002)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR08MB10251 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT058.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 21915e90-5376-47ba-5579-08db3a450659 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rUog+EMAu32pnl+exja+CTZ8TD9lzKVUFi1oqaUdKtDMbekUQGtzE+1Gs5hmxXh2EKpwtdLRb1xU0eFOX9zPWqDv2i6U15eVYTnAFxfXN1QvF1RvIZkyR3/VHU4h867S6viJErRc6NWihzVAN29aMuJ/nHbqY8kFUjAjXRSQQ7phTjZSb3JosTFXT76AARQu8+EdzpFk3RzHjCQYB9B32sUBTlosHHWqY+0nV+sogn1G9sfUkxvWBJxMcG816U8ZFLFzhv2Bt/hAbf0kvielJtNjgVFOITg9XhS+G6PYVlVsoPThAEIz0uJ6PVDapXhT2bsbMlR9LaK8GLyCdwjjAsMISDU378uaEEt3ygdwOhIU62MZZkxsIPfQG06PSfQucT7mpAezcYVOHX9pk000Acr8yfcvvElcJhDJXlI3mAyJO4O7SH5//0gc9vuvahsAh91hZBxnPVfbGRjfBV18eWKfcXqPgO5T/BphQbPB/ZiQpO0APKpTu53OwQjeTpDz+D5RRrKUN34tL01N43lum17LuRkcI4tDk59w5gkJmHn1ry6aYAlqiRbte9JpbmQDrc+rUHbVwW7BLB0KTOqtWW3b2mxRMGPG3PPHbdmYXAbrt0G2NTi2nVfDZWMeNe+Bxjn270MNFV3CUYAu6FAEhFtBegWVuh8ZQRujOgWAtH6FhZxPXPMK1BVHlVsVWLz1OQ3RHyAtuhycIBKKVIIDQJmPivYbThUD2XhZ0gAJOe4= 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)(346002)(396003)(376002)(39860400002)(136003)(451199021)(40470700004)(36840700001)(46966006)(5660300002)(40460700003)(44832011)(8936002)(26005)(1076003)(40480700001)(6666004)(2906002)(83380400001)(47076005)(36756003)(426003)(186003)(336012)(2616005)(81166007)(82740400003)(86362001)(82310400005)(36860700001)(478600001)(70586007)(41300700001)(6916009)(8676002)(70206006)(7696005)(316002)(41533002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2023 04:27:34.5832 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b60af0fd-00a2-4b2d-86b8-08db3a4512d9 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: AM7EUR03FT058.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR08MB5636 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,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: 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(-) diff --git a/gdb/corelow.c b/gdb/corelow.c index db489b4280e..e3ad9772869 100644 --- a/gdb/corelow.c +++ b/gdb/corelow.c @@ -1078,6 +1078,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; @@ -1101,15 +1116,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 (); } -- 2.25.1