From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on2050.outbound.protection.outlook.com [40.107.15.50]) by sourceware.org (Postfix) with ESMTPS id 8ED723858D39 for ; Fri, 19 May 2023 10:25:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8ED723858D39 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=As89mXdimhXkOnvCMR89yP5tTu6/oTisp4/+HfxlzidiMOUyW3WAyv2RE6CxR3Wri1EuiKEWLx3hxzx1nQUnfm1vmHeAu9Et8B6DeCTJqqE5VSTNDmVU6vO7xPzWBGt06/IjF2SwRs8+BUikeKUMprZNcC6llwTy6Ni+ZDpUbWQ= Received: from AS8PR07CA0007.eurprd07.prod.outlook.com (2603:10a6:20b:451::6) by VI1PR08MB5439.eurprd08.prod.outlook.com (2603:10a6:803:13b::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.19; Fri, 19 May 2023 10:25:23 +0000 Received: from AM7EUR03FT061.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:451:cafe::a9) by AS8PR07CA0007.outlook.office365.com (2603:10a6:20b:451::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.6 via Frontend Transport; Fri, 19 May 2023 10:25:23 +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 AM7EUR03FT061.mail.protection.outlook.com (100.127.140.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.18 via Frontend Transport; Fri, 19 May 2023 10:25:23 +0000 Received: ("Tessian outbound 5154e9d36775:v136"); Fri, 19 May 2023 10:25:23 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 2a9b83cdbfd65479 X-CR-MTA-TID: 64aa7808 Received: from 38f8a476949c.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id AA3BE481-A7C3-4D80-B4AC-FCCCB4327850.1; Fri, 19 May 2023 10:25:16 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 38f8a476949c.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 19 May 2023 10:25:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UQG7c8xirhIxag4g+vJl71XUaoiIZRBXn8izUbfeoaOlst+jxhFssJmiVuJ8xU/2V/AWcL9VW96xpvFHJaNrRRwZAmTcoMP49u/iJoDJEdBi73psAAEeTYn51uwKMFJN6lcWQBq5Z6Xa2rhOl9stsGxAyQuZmGPy2Yvq6bjLasc1L+Xk+33+R9KmTKzJrddN42lQxKSrMAXqW2DStMUEW3jeE1ycE0yygzzOyr0Ed00/MuqKUf1hoC4jeVrWTgUOz6QRnkVBZf9kHUbxzK0/3lWOvzKlYVF/GJftgZaGhtm8yD+aSD+UwbSOHYaVoLfpeZMAHVB15rJiFy/ODy7C6Q== 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=KEsDlWEwT+H1wvHCTiwgaclEg3OAQcuBSh6SelJ3XFgY/K2YRW+28Kjsk4kB7DMwXswtFl+xoyUFNUuPxXz202ndGK0ykUglkjcqgpgD52FUg3wpzmH9mETO5CRobv5zjuE/GtTNX1EG3+NthKvbV4SrweYzPdhK3jxi3efkhcLuSuR8e4DrLcQ9/eEwBNTBlGdSMAoN5xxL85JZcFWtVdhmPGTJnWHoRy5rQCNEqZ8GArcLuyiM+TNiRYuKlq0HgoavSl5qtvVSQBTqWgvROYKmJap6iBAdAGVWYG7+WNMv3iRaw/xhqkMH8PqOIuvrpggcQ/bvQFHx4TpcJb4P0Q== 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=As89mXdimhXkOnvCMR89yP5tTu6/oTisp4/+HfxlzidiMOUyW3WAyv2RE6CxR3Wri1EuiKEWLx3hxzx1nQUnfm1vmHeAu9Et8B6DeCTJqqE5VSTNDmVU6vO7xPzWBGt06/IjF2SwRs8+BUikeKUMprZNcC6llwTy6Ni+ZDpUbWQ= Received: from AS9PR05CA0203.eurprd05.prod.outlook.com (2603:10a6:20b:495::13) by GV1PR08MB8380.eurprd08.prod.outlook.com (2603:10a6:150:80::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.21; Fri, 19 May 2023 10:25:14 +0000 Received: from AM7EUR03FT009.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:495:cafe::4c) by AS9PR05CA0203.outlook.office365.com (2603:10a6:20b:495::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.21 via Frontend Transport; Fri, 19 May 2023 10:25:14 +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.6433.7 via Frontend Transport; Fri, 19 May 2023 10:25:14 +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.23; Fri, 19 May 2023 10:25:13 +0000 Received: from e129171.cambridge.arm.com (10.1.37.65) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.23 via Frontend Transport; Fri, 19 May 2023 10:25:13 +0000 From: Luis Machado To: Subject: [PATCH v2 13/17] [gdb/generic] corefile/bug: Use thread-specific gdbarch when dumping register state to core files Date: Fri, 19 May 2023 11:25:04 +0100 Message-ID: <20230519102508.14020-14-luis.machado@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230519102508.14020-1-luis.machado@arm.com> References: <20230519102508.14020-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_|GV1PR08MB8380:EE_|AM7EUR03FT061:EE_|VI1PR08MB5439:EE_ X-MS-Office365-Filtering-Correlation-Id: d52e006c-68a3-40e7-e348-08db58535af2 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: dZn2RrLOqPUA4QlWbnvOV1iODa24eOUYqrdKyMOGBK3gvFDmzaZcQ4LHpqNdfP6ktqQkM/UI9FTIGQUCjtHZn++53IOwbRpsT/00RuJkc14wJvJPaUNIBlps49oKwwuf3HjM+oUGPWoqXOAD1ERVQ+x3DxjxucBQD2bR1BSQYqly4lG0syTW0830z9ks7Un/FryDQux8qpTRGg+jHp+nTZvLMDZ7cloV0XbT/PNlOh+gQcXUaPG1hxeM9WTk0anM3s+TGW6fS9L+manBA364KW0cYd95rxuUlzSO092pCffjju4LN4BurbXOTtuRnlLLLD+6tblqDfWBn3jyqwZK719Xqw+VGduyxGMn1kkPoVw3ok5z05PvlLvXMmdoIj+Vi+tqLiBSUeF+ktMQOMVxa5HazlhwPRmYeFtwxmNXlRdyb9Oc9oA8nXQpkWJRy53iiqCsC22OlER/I4JgWdIqrV7JCOkvjADGMr0HTmHT7Z6MNnOFGSZ3NUgR/31Nxye1psGRW4RrDW477LiMFUwIsJktDXd3a7IxS7OnomgS/PISyOkUDXza14iD6vXUZ8PrfU1L7+YioNBnCFgfetNmvFelSuDoCPM1vOOtOUi/an2ss9D6Sp8iY/SDwXVVZBZfx4TSovMaTDLwqPc12K+vGnLawU8OqbfG9xJQjabvbffJ7pEL5vc016xgTbKXSrv6SC+4iMIQ8WynHeFrcJCd0IYUQgqhHSRGT2m7ErEe4V93a9WDLVAhlE4nzfanZbTh60XaE6r91EauqOiJSuyEPA558A4n6MxGw5C5sSsh2sY= 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)(136003)(396003)(376002)(346002)(451199021)(36840700001)(40470700004)(46966006)(70586007)(70206006)(6916009)(82740400003)(8936002)(8676002)(40480700001)(478600001)(316002)(6666004)(7696005)(41300700001)(40460700003)(2906002)(86362001)(81166007)(356005)(26005)(1076003)(44832011)(47076005)(82310400005)(83380400001)(36756003)(186003)(336012)(426003)(36860700001)(5660300002)(2616005)(41533002)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR08MB8380 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT061.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 64214554-269c-4c5d-df2a-08db5853556b X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: l1W406PhxV2rd/8r4VnP5pIQEd5TZjmcJ6Q44gyjathddVWbc8pT1LsurCCjil9ZWC0NLKjwHr6WLNfTMgL3/UM+irCO+izr8BkazG17+lKCrQGeqftYG281HmaYXexnc5QdCASCvCNc7U6h+iIwS5W99MhcgsOVk28lLA+/7WDhgKVS+DiXtgF7bRYq1n3NFcrAmjs0wvczyAiadO0fFP4Ndw4bOpNR8W145CXOg82vH+rl3BdFDNkjr/6WdViLv4sCnMfS3IphD7TWkhRR2sdsSu6idd+HwGkC8lFpjTXTi2hoRxe5KgPCy+tfnjJ38dZpUAJ4EkCgN3twPRxOFqG4VlINed02bKkXfjVnYTPJK1D2zL2CHc1sjbk4ix+ROFeHfYapOE+2F+tjW+1xUKuMsPhceyP8V7UP0PTD7Q42jspPdrm/wpqRTRb+b722jSGl+mTQm4Vs2uqmQZhFSkP3nL5Z/VARY633D4GcIone4KgsiiLcbyyhmsWg9g/GBpIhGokpLqGR5k9cSApEFUsX7pSm4RAde90b7He4N0uzv0zf5LAlA+eIpbwRP+2otvANdvWyM+RCIukpNcuMVlqj5xR4A2dwIqsspFiRZ7Am+Lntasj0h8tBbXbTpUfbfyFycktb2NTq/yaBxpcje1Uh9WNlbgEDmYMjfnI6SnCAe/TAYFT83r8MR+4PuTUSQGasDsmt23TEkXAcx7okHtIBb15k9cxI0R+4IbwvamjhKj3vWmjDQ5ZuJIwTS/o79sHBrqP3HFg3BWWXSQ8OdQ== 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)(136003)(39850400004)(346002)(376002)(396003)(451199021)(40470700004)(46966006)(36840700001)(478600001)(5660300002)(70206006)(70586007)(2906002)(8936002)(316002)(8676002)(7696005)(6916009)(41300700001)(44832011)(6666004)(26005)(40460700003)(1076003)(82740400003)(186003)(40480700001)(426003)(336012)(47076005)(83380400001)(36756003)(36860700001)(86362001)(82310400005)(2616005)(81166007)(41533002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2023 10:25:23.3829 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d52e006c-68a3-40e7-e348-08db58535af2 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: AM7EUR03FT061.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB5439 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,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