From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2083.outbound.protection.outlook.com [40.107.21.83]) by sourceware.org (Postfix) with ESMTPS id 6ACD23858C50 for ; Mon, 18 Sep 2023 21:27:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6ACD23858C50 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=xlZ+UHdC6mDnVmWZlDPVyBXmN8XiqtRTeQvl3R5DY30=; b=2UA54Deqy5TP0IRuKuqpiZY15NqRfxuFcD2O43qCQyR0RoWKZxoBFjOv+PmZeaqKEwMGk8ek7dL9wCr9aMXtwHketSrvctMTrRGKwUicg0oGmrLDHBdZpPb1L3s4iMt8ig4USq88jqyZKg1B7JCyMEKX9ySfq5TL/YACMSM+f9c= Received: from DUZPR01CA0086.eurprd01.prod.exchangelabs.com (2603:10a6:10:46a::13) by DU0PR08MB8042.eurprd08.prod.outlook.com (2603:10a6:10:3e6::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.26; Mon, 18 Sep 2023 21:27:16 +0000 Received: from DBAEUR03FT059.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:46a:cafe::32) by DUZPR01CA0086.outlook.office365.com (2603:10a6:10:46a::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.26 via Frontend Transport; Mon, 18 Sep 2023 21:27:16 +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 DBAEUR03FT059.mail.protection.outlook.com (100.127.142.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.14 via Frontend Transport; Mon, 18 Sep 2023 21:27:16 +0000 Received: ("Tessian outbound d084e965c4eb:v175"); Mon, 18 Sep 2023 21:27:16 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: d81631a5b2a8102c X-CR-MTA-TID: 64aa7808 Received: from a57c0351156c.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 0A0FD283-9F6C-4774-917C-DB029E13AFA8.1; Mon, 18 Sep 2023 21:27:08 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id a57c0351156c.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 18 Sep 2023 21:27:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fAUaO8JMo856YE1CtXEY94J4AejSjASyn1j2b719L6G+WOrW1Lb1l0OFHsoFnDZsGZI5McfwNUNarUKNXX6a3SUkPWyXzy6EazembrDKMOvfp4+9Ca+GwbOzSmZHtJUCcVVJKTQsTOPTZM0fg4Ltt9PkHByXylqjWnA4WU/L2YBJMwE/kw0mkA0nclL33CMkEtnuP0N/kxSEaukrOhe4oa+rQrwimguYNnjazds5zD44uF1ywqEFzr0AsMGCWxnGnT3O4TZdblheVQyFKSg4aEGFhAkdu0NJVHt/m2g/oA0zvxgBUZ9ByPUegdltSYENTMQvYCjCaC/mOIp0rBUQLQ== 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=xlZ+UHdC6mDnVmWZlDPVyBXmN8XiqtRTeQvl3R5DY30=; b=TZH+cpbOBriRnWEKHYFdQUfbrSRRURaAU09qiEO+lu/RV42cyiY9yJxfWtiBJrhXefOclIfF8MoAUh60TZuCREjkwEvjwum4QNxtXcrSK1zaQaf0XkAGU6khNP0cTyhz01sELBnElk2ShxEbCDE/KT+8oH4BmH2tKdUrpb7nbyuntalPObF+68bU6Jidt60dglNY9tfUVYCuMp4pSmSOGRdoVWBOIh9dUdsbQnfXxZvo69oWdikKiwT8+MXtZZSNBkXVZ+3R7L/KIoNUoUgymPb4gJJiBt8eCzHpke3SE1QeALpRKz8THyCP13OCmC/Hggw8zjijnAT0IyhLn6+wXQ== 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=xlZ+UHdC6mDnVmWZlDPVyBXmN8XiqtRTeQvl3R5DY30=; b=2UA54Deqy5TP0IRuKuqpiZY15NqRfxuFcD2O43qCQyR0RoWKZxoBFjOv+PmZeaqKEwMGk8ek7dL9wCr9aMXtwHketSrvctMTrRGKwUicg0oGmrLDHBdZpPb1L3s4iMt8ig4USq88jqyZKg1B7JCyMEKX9ySfq5TL/YACMSM+f9c= Received: from AM6P193CA0142.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:85::47) by DB5PR08MB10048.eurprd08.prod.outlook.com (2603:10a6:10:48e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.27; Mon, 18 Sep 2023 21:27:07 +0000 Received: from AM7EUR03FT009.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:85:cafe::9a) by AM6P193CA0142.outlook.office365.com (2603:10a6:209:85::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.26 via Frontend Transport; Mon, 18 Sep 2023 21:27:07 +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 AM7EUR03FT009.mail.protection.outlook.com (100.127.140.130) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6813.16 via Frontend Transport; Mon, 18 Sep 2023 21:27:07 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) 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; Mon, 18 Sep 2023 21:27:07 +0000 Received: from e129171.arm.com (10.57.64.238) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Mon, 18 Sep 2023 21:27:06 +0000 From: Luis Machado To: CC: , Subject: [PATCH v7 14/18] [gdb/generic] corefile/bug: Use thread-specific gdbarch when dumping register state to core files Date: Mon, 18 Sep 2023 22:26:47 +0100 Message-ID: <20230918212651.660141-15-luis.machado@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230918212651.660141-1-luis.machado@arm.com> References: <20230918212651.660141-1-luis.machado@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT009:EE_|DB5PR08MB10048:EE_|DBAEUR03FT059:EE_|DU0PR08MB8042:EE_ X-MS-Office365-Filtering-Correlation-Id: 1fb96950-68db-40a5-a52a-08dbb88e080c 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: npotTvnoDAwhOHjizrSlE8Fk2a7kOn78lZTEz1hlyEFjTmkxhJDCDOZozu0gKwvUVrQ1/YuhTPwwDavmL5IUeGxR2pYsYu+8wsaYxF3/U6l6IvCmt6qmkqHi8AmYJxFZD8hFQYKgFLTVynwkX7/mRl0t+Lmba8ku4bJyXnqVkLVjl4Si5KDWvxdVt56wv+B+bylJyeWXjZiohbZBWRZX1YNmwXeTPPFLEMtcEq6trLodTluDGMc4Ja8JYIpBkA1sdm/lMYat575y11I1cl/r350qprOlkyvC0bvqEH4Ld2bfFr+n5+t1scihWh31bLapN4o8Qx0KvLdMVaWFiFXyj3o9INQ0p6oaaBH6m+zegMoTjmWWvoVkL7YJIKJCXkPZbWFOY0KCDxxn4l+0jfQjHklNe9vSdQ+MYJn25cQgovJZZXFvsC7sGlwCJfR9Qb5TDD8Ak30wyOCHiaYP1jtBx1DgES7LR/z12UvvXjK9iipWS/6ydRjpFgFIBWY7mUl628XcjBNahCUMkFm5AjP6jcOCk9ga9DBe0VtiO4FOV4SXp93grN6+grg/QDPgKPdQ0Y+7DwnuRXmuF6MUP8ovBgKqRL5jqvUZbJOITJnxagojlZpQW/m8DPzDOd9UhZG6F6ilOfg/RDg1h/gWYqupVPXEE2g3+kWhVgsJ71aGfe7wF10JNGBgb7CueVAFuQM1K+Pf0Z8DqR3zr4gA4YJBqdGQpxLxvfLapkVL41MKBSAPpam+6ScUtl9imShTX99+LvSxORWbdQ8XqsubLbJ0og== 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)(39850400004)(376002)(346002)(396003)(136003)(82310400011)(451199024)(186009)(1800799009)(36840700001)(46966006)(7696005)(6666004)(83380400001)(82740400003)(81166007)(356005)(86362001)(36860700001)(47076005)(36756003)(2616005)(426003)(336012)(1076003)(40480700001)(26005)(6916009)(316002)(54906003)(70586007)(70206006)(41300700001)(2906002)(5660300002)(44832011)(8936002)(8676002)(4326008)(478600001)(41533002)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR08MB10048 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT059.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 01797a9b-2661-4280-bed9-08dbb88e02d5 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LZbE0bZiA+pzoYyMqMEbvqlKdfYQHw/JaGASalq+INZFReUprD2tK0+LtMNT2cqEapHCQOnmgvZGfVPkVMtZHQCtw4Qo4asxSt9dKTqgeS/dbxqWcod1MqKspNTtgQqoxn+QMvwFzKA9N+LJ/BHIWmHOBi31c3vXju4k9EhwO7c2jLjeHAgbhozkymD3oSC7w766Og7Pa8tSI8GhvgDqumW7PQVDrMsycvIoSMd+a34yx1TduJFv8aXOiT9CyIfYiEHUvp+te8fF728/WFiDcmJvJ25AGro7vEibBbSmhVZSFd+7Rr3RduCKtlE44LsN6Jwn/0hTDZWUKue1wa2OE8Ga1gT/hX2rabE5c8rXPn53D21VkQVa9ifDQTplRZ0KIqG8fYRfsaCtF6SmCbH25TRroOZ3lmMIM8Dm6ZXxrXGBLknCp6OL7V3k9Zd475GYgg1zsxTPThUBl0NkLfu3wFL1DMbnZ6bSdhmdUSi98j2UoTSh5E1RBFo9U8PFHbJ6BqCxri+Or9JT9SkMxL2oDIb3L1ui8Bwi18zu1/EzM37k/BwJegVLDcBXWCzuYAI4ZWM6oTh5wG2aZJJUvMCVFnoNCpOHiN3VSoEtsuHXfO58cNnO1sosdUYnr4cj2XKRQpgxF9/F8QIYB/CjmYwkgmK7j8pw3OyCFAdqGUeIe6xRZgYFKCKh9YTtyRYrzR2YWWdYAd8m+JC2F/e7mVZNpHMWi0Zm5BPGf0UH0fe6mMdsTAArJUJuFeqTW3wDrwt2BERM3vBGNSCVzLdVNxHD9Q== 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)(136003)(346002)(39860400002)(396003)(376002)(82310400011)(186009)(1800799009)(451199024)(36840700001)(46966006)(40470700004)(81166007)(26005)(82740400003)(2616005)(8936002)(8676002)(4326008)(1076003)(40460700003)(107886003)(83380400001)(36860700001)(2906002)(36756003)(47076005)(426003)(336012)(5660300002)(40480700001)(44832011)(86362001)(7696005)(478600001)(6666004)(6916009)(316002)(54906003)(70206006)(70586007)(41300700001)(41533002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2023 21:27:16.2970 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1fb96950-68db-40a5-a52a-08dbb88e080c 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: DBAEUR03FT059.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB8042 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: 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. Approved-By: Simon Marchi Approved-By: Tom Tromey Reviewed-by: Thiago Jung Bauermann --- gdb/linux-tdep.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c index a4a86b01bdb..2885afd60c7 100644 --- a/gdb/linux-tdep.c +++ b/gdb/linux-tdep.c @@ -2078,15 +2078,30 @@ linux_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, int *note_size) stop_signal = GDB_SIGNAL_0; if (signalled_thr != nullptr) - linux_corefile_thread (signalled_thr, gdbarch, obfd, note_data, note_size, - stop_signal); + { + /* 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. */ + linux_corefile_thread (signalled_thr, + target_thread_architecture (signalled_thr->ptid), + obfd, note_data, note_size, stop_signal); + } for (thread_info *thr : current_inferior ()->non_exited_threads ()) { if (thr == signalled_thr) continue; - linux_corefile_thread (thr, gdbarch, obfd, note_data, note_size, - stop_signal); + /* 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. */ + linux_corefile_thread (thr, target_thread_architecture (thr->ptid), + obfd, note_data, note_size, stop_signal); } if (!note_data) -- 2.25.1