From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on2042.outbound.protection.outlook.com [40.107.13.42]) by sourceware.org (Postfix) with ESMTPS id 11CF3386075C for ; Tue, 22 Aug 2023 11:21:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 11CF3386075C 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=nWN4Vo3iVq2xVsI19K/RDvOsvuJLdcA56W/2yv78MSU=; b=fcuuf408LjaNr5asJgncrsSN6AFgufuMFutbNiNdpg4GF0SHMtUQeHzJ84yWDA6f1FW2cpPwix8m2etDXbAKvonfMqXoo2nRjsM38NduLUxWfCCEIsBJCqENtzfO3KFDXy5pen+6SHF5wdZhPhIVF3CVGN3wj3DjRdyAS7qa9RI= Received: from AM9P193CA0028.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:21e::33) by GV1PR08MB7938.eurprd08.prod.outlook.com (2603:10a6:150:8d::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.20; Tue, 22 Aug 2023 11:21:54 +0000 Received: from AM7EUR03FT055.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:21e:cafe::78) by AM9P193CA0028.outlook.office365.com (2603:10a6:20b:21e::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.20 via Frontend Transport; Tue, 22 Aug 2023 11:21:54 +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 AM7EUR03FT055.mail.protection.outlook.com (100.127.141.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6723.15 via Frontend Transport; Tue, 22 Aug 2023 11:21:54 +0000 Received: ("Tessian outbound 169aaa6bf2b7:v175"); Tue, 22 Aug 2023 11:21:53 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: c9acefd53d34f1a6 X-CR-MTA-TID: 64aa7808 Received: from bfa1a8c7b9c3.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 4D45EA30-260A-4623-8829-B85B60C80D2A.1; Tue, 22 Aug 2023 11:21:47 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id bfa1a8c7b9c3.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 22 Aug 2023 11:21:47 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bj8AiO/j5dvo82lfkjuwwEBav5nDiI7U6kJW+S3fiA2ZnsOxqujRts4G5aN7/Kw3YNXQkZLXsZ1QECG0RpUDGdU6odbSKoziCRA9RvYMt/z2hOpRFENLBOm3vBWy/B4rKO8+P0uvyEgotf/oL9OT3TqI8JiO6wml3IF5Wcrc6qIi6v8kWa1Q3bSrCUKvSAV4YcH73NWTW8nLOzpUvfAcGB8j7HHsnPnfj8mJ7dzSr55FGShrU+WAk8q8zdtr9gL05fz7+mfhHtVZoUXa0uNxzO2bLK4Xw/ml9xuVBPlu7ba7+OVO7YU4R5B0wMVjEuntzYv4eyxL8g6z3WCupUVrpA== 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=nWN4Vo3iVq2xVsI19K/RDvOsvuJLdcA56W/2yv78MSU=; b=DmOJR6hCcwxUcwRPkVv3rO0B7oLpl7V8GOrFMmixZvGEGNR0vDkEVyp8OJL4CyWxBfb3Pl1AJALB0I0FYDIZtb4YtXAyx/DmFC54oOwGBGYUnSAmAgjPc8RG6gYgOgMpItrspqTjfXxp3xLuGvcNdes77gH6xaF6sAdYgmF+JtD4VIB/pGVXmLyGvKzpdqcSxdOHkB8co3BCTLnVJDz98Sqk9p+ThFl6NuBcrzSFqnSrkZKehXvwyQHqvZ4n5WOEc9VbsPDPw/bRxXEzRdm2YGxCItdGUHpw9KRKeLYxW4pj2hg9vjqlWRIyh6mB9NBr2Rgs7MTBKVk3K4jL9EpkiQ== 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=nWN4Vo3iVq2xVsI19K/RDvOsvuJLdcA56W/2yv78MSU=; b=fcuuf408LjaNr5asJgncrsSN6AFgufuMFutbNiNdpg4GF0SHMtUQeHzJ84yWDA6f1FW2cpPwix8m2etDXbAKvonfMqXoo2nRjsM38NduLUxWfCCEIsBJCqENtzfO3KFDXy5pen+6SHF5wdZhPhIVF3CVGN3wj3DjRdyAS7qa9RI= Received: from AS9PR07CA0013.eurprd07.prod.outlook.com (2603:10a6:20b:46c::10) by AS8PR08MB10097.eurprd08.prod.outlook.com (2603:10a6:20b:63f::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.24; Tue, 22 Aug 2023 11:21:40 +0000 Received: from AM7EUR03FT027.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:46c:cafe::8f) by AS9PR07CA0013.outlook.office365.com (2603:10a6:20b:46c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.14 via Frontend Transport; Tue, 22 Aug 2023 11:21:40 +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 AM7EUR03FT027.mail.protection.outlook.com (100.127.140.124) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6723.15 via Frontend Transport; Tue, 22 Aug 2023 11:21:40 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) 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; Tue, 22 Aug 2023 11:21:38 +0000 Received: from e129171.cambridge.arm.com (10.1.34.58) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Tue, 22 Aug 2023 11:21:38 +0000 From: Luis Machado To: CC: Subject: [PATCH v4 13/16] [gdb/generic] corefile/bug: Fixup (gcore) core file target description reading order Date: Tue, 22 Aug 2023 12:21:27 +0100 Message-ID: <20230822112130.1513216-14-luis.machado@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230822112130.1513216-1-luis.machado@arm.com> References: <20230822112130.1513216-1-luis.machado@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT027:EE_|AS8PR08MB10097:EE_|AM7EUR03FT055:EE_|GV1PR08MB7938:EE_ X-MS-Office365-Filtering-Correlation-Id: 29a22480-654d-447a-d2c8-08dba301fd31 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: +Nerz7m+gWuYAbHD3cf2oJZXbuUfm8sVz74qZhgg3lB2a5woKlg0fuj0N02drFD2+oq5uNRWkHJFM50eThfLtaetuG6Lu+VLiupEqLbYSDPLkvUFaDC8q3FOL+55SXWBpYOKo+pc7DMZfIqvzUgIlHnORWw+9fjhkLvvwp45yIJZTwh7gMJ9sacaCKBuLi0jarN8dG0DLVGvwEyxYqXkGx+uLsMfgj+s2Mk9VZAnlTzeLU7inbdprr4an/vO/W+NBJzy60C9KyzEekUDLfsxIcsNC8JTuLcUaW8NNVgwvHkbExQoVEXBxzd4Y5cbYtaKl8+DSL5jMb+naZpAGpJgzSIlth2aBeWIXgvLmz4CdfhXzmC/r7tfFH9GlPhqREcKRKDNmYxTRkADDros794XboGdD4yERmKfbDu8jqXVfBjwsUG192cDMLqSNV/N4P2nkZqwZoMHLwhqWUYL3EEC0s7wGiFefzl1dExHd1XOVTCQPNWcG5vLjeqwGDwD0qo3II6x0tL//9x7lMi7CTSBOBGfAQ5ys9UjXSbtZNMEGCMhxORuAgD1lpltQQGv5OfPEXeP7FYucoQx9+3iOtH/ZmWjmw3zMwe1YsNbElhfiNKjlM0gDM9xJ6/PXph7lis54ZTctSl6m8OceUhV+1aeMZjHZm8LchgRwDo4ldnCylYg4W4fhJSyS6JAn+dXBp0MRznNKVr0KnPvYjnDqgWKmP3a6FDFB7/L/RuPoBhQ9+B9CAk6k4TNasJYyzJT2JVtprXcwzaYBD/1szCz4UWxdu0Kk2AsgkW6BgNlkY4FJj4= 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:(13230031)(4636009)(136003)(376002)(396003)(39860400002)(346002)(1800799009)(186009)(451199024)(82310400011)(36840700001)(40470700004)(46966006)(6916009)(316002)(70586007)(70206006)(8676002)(8936002)(2616005)(4326008)(36756003)(40460700003)(41300700001)(1076003)(82740400003)(356005)(81166007)(478600001)(6666004)(40480700001)(83380400001)(2906002)(86362001)(47076005)(7696005)(36860700001)(336012)(44832011)(426003)(5660300002)(26005)(41533002)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB10097 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT055.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 14bc1334-87c4-4d5f-f9d6-08dba301f546 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NOTuHYQoHvQ2vc9sT+TkYc4eWjwZONqFPM22Fv5h1uZRlOzp/EWwk2CFCrnvFTGqxn8uFUuYSdkaOMzqmHarzu4qqGwvQ1NKm/1feLMFSbhv32jEku5hiqiZkqtPI2/gp3hC3HcLzE13AFrwEaGcNNzjeChfR07AUnIs+HqPCWdPtOvS/9VKqQ6fh2fVlU4JzpJ2PyM1B5bGFyj8w9nYrOJtE5fTcWwGBkbuvBNL/TToE6wsRA+fXZFdXoC1Q9wJf3V/ZiL0txqE0laOqi81IuvLdQu3t/Wa7LSGjzz1ByoQbhD7AeZ9z+bWg26bUyTuDfMzQsHV2DER46bpYfvE6YaJ83l2RkCyadSZx5waL//Bi0jS0uQwpDOe7wiG+0fGEllcAuyiXZwU6JQK0CZgOpykEas43nZoLClj1TWwtsxF+5Q3YuLwMpi1vnimpeibQvrorO2J19AM4B8s1MoJqB//NgR6FXUy1lm9IYteciOJ+tuKuGy5J3FTsm6SH/CQDFXWXm8vXWipjOWEgTfHuBAfyEC4TxVDT4/ICgub0aiHYiIweFChBgeix1JkVYQYNfWctYhK2kbKP42Z4CpecJM9rjZDiW5V1ZR4OuSqBI/njtg788suL5/v274FAJ8Y9DRhbsMRk6h21AQx9iI4QkFna0mMFmbC3QXMl/Zo56GhsDaUXqqCH8tdTklv3UAS/kRk/b250U4gR3UkOzYRERAhtkcr16I3S5nlv/TCJ1IdTBCtBgTNwQ2H1SgnugUM0cCqnOiLGuAmbIjBxQ73wg== 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:(13230031)(4636009)(376002)(39860400002)(396003)(346002)(136003)(451199024)(186009)(1800799009)(82310400011)(36840700001)(40470700004)(46966006)(86362001)(5660300002)(70586007)(44832011)(2616005)(70206006)(316002)(6916009)(2906002)(8676002)(478600001)(4326008)(8936002)(41300700001)(40460700003)(6666004)(7696005)(26005)(36756003)(82740400003)(47076005)(81166007)(336012)(426003)(36860700001)(1076003)(83380400001)(40480700001)(107886003)(41533002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2023 11:21:54.0627 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 29a22480-654d-447a-d2c8-08dba301fd31 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: AM7EUR03FT055.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR08MB7938 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,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 46bb1077b6d..b650396ae3d 100644 --- a/gdb/corelow.c +++ b/gdb/corelow.c @@ -1226,6 +1226,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; @@ -1249,15 +1264,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