From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id QN/xEXia5GS2qwgAWB0awg (envelope-from ) for ; Tue, 22 Aug 2023 07:22:32 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=TyysxbSB; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 4568C1E0C3; Tue, 22 Aug 2023 07:22:32 -0400 (EDT) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 2C25A1E098 for ; Tue, 22 Aug 2023 07:22:30 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9283F38319E0 for ; Tue, 22 Aug 2023 11:22:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9283F38319E0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1692703349; bh=six1ycyc4SE9sTZ2EOkSRmQWo8Uq64X+oPo5GzoFfbM=; h=To:CC:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=TyysxbSBCx8rXGNml9zFYtjiPoYI+MwocNIk2W+DABuBai17b2Qr/Msy7/s5fR05M 10HVn8amF7gsBusrQ8VwiGTbS1WrYGHRrDcjpRO1rbFwk7WxnIQv2zwouAB01Ng4Nk iMs14pjJD7nBLXpufz1oOeR8kpBIK8rIVCvGzsRM= Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on2072.outbound.protection.outlook.com [40.107.15.72]) by sourceware.org (Postfix) with ESMTPS id D61A038582B0 for ; Tue, 22 Aug 2023 11:21:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D61A038582B0 Received: from DB8PR04CA0017.eurprd04.prod.outlook.com (2603:10a6:10:110::27) by AS8PR08MB6709.eurprd08.prod.outlook.com (2603:10a6:20b:395::17) 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:47 +0000 Received: from DBAEUR03FT010.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:110:cafe::80) by DB8PR04CA0017.outlook.office365.com (2603:10a6:10:110::27) 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:47 +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 DBAEUR03FT010.mail.protection.outlook.com (100.127.142.78) 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:47 +0000 Received: ("Tessian outbound d084e965c4eb:v175"); Tue, 22 Aug 2023 11:21:47 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 100dd4dd64b4da70 X-CR-MTA-TID: 64aa7808 Received: from dc6e81f4a038.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 7CDEEB62-8294-449F-A78C-D905D9AC1D94.1; Tue, 22 Aug 2023 11:21:40 +0000 Received: from EUR01-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id dc6e81f4a038.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 22 Aug 2023 11:21:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h/gzTh6poy+gPvHNvJxjerAJBnzFcU91ZHv7oiIjTWqxvDde+Dc2cQHauzpJCsSYpn6qqe2oYCSH+Ac05wM7KUaa1VqMBsEerUG3R6KraeLB0nMjCJHq/TcA1nLdBIeYClyafIiYTRm/ElWoVCUgevNfoPS9enJgRrVYp6YLlZEdMRlA+iCIS1uJ9TjazK+LPBGKGmUb2uzaORXZq+uVP1oSfsVZf80DYkYmwk4mgyHZdQjRO9+cIXlelhpKGRVgvShdmUHU7EsAVUfzLA45+8xa49e5zuXTu+sJHPJx5rEWjq45HJwj3RGgO/iYvDK/gvCcKi+Pbj1KG+m8Ro1y9Q== 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=Uj42eM04gkxh9pZSz1iM5UPqarMVGechQLRSm17bwuu53mWCSNYcw4AVZsFC294NKnh+AFaRQh0uPBCd13GMpLBEoP8SFWjGEVQOBr/FK43jxIYOy+7KWPL2TuRYF3qpt6iZtJaNk2Ezd/0WFqNoQzQe3idwDGZkB0OtACKHq4HESO0t49OQSS5T6YUXsR29FyUwIC0KhgkYirWjEbNvopW0W5G/HRyVk4Nm2KZZSpLwOs8qs+4C0CI3JGmutI+7K84zcuxLqe1PorzZpIBtyShfaG4wIi9axF3tIaewmqNJzF9EP3fMnMKAlJr+Xy/jzupD85gvLVg7SajjeA43kA== 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 DUZPR01CA0329.eurprd01.prod.exchangelabs.com (2603:10a6:10:4ba::28) by AS4PR08MB8070.eurprd08.prod.outlook.com (2603:10a6:20b:589::20) 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:38 +0000 Received: from DBAEUR03FT045.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:4ba:cafe::30) by DUZPR01CA0329.outlook.office365.com (2603:10a6:10:4ba::28) 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:38 +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 DBAEUR03FT045.mail.protection.outlook.com (100.127.142.142) 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:38 +0000 Received: from AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) 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; Tue, 22 Aug 2023 11:21:38 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) 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 To: CC: Subject: [PATCH v4 12/16] [gdb/generic] corefile/bug: Use thread-specific gdbarch when dumping register state to core files Date: Tue, 22 Aug 2023 12:21:26 +0100 Message-ID: <20230822112130.1513216-13-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: DBAEUR03FT045:EE_|AS4PR08MB8070:EE_|DBAEUR03FT010:EE_|AS8PR08MB6709:EE_ X-MS-Office365-Filtering-Correlation-Id: 48c59f65-319f-4e1f-728d-08dba301f8ff 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: Q8OlsDoLGD3eRU+iqxZwW+ksT8LhL0z4GzENOzePJHPKSapK4tDjKOdS3F2HPdmbB2dqOneszSVW317d51aQlyd9QpaZg60AUqc1hDS6x9VHsIe/13+GvpsfvIMEyjZyxmIXf5sEp+LmyY81ym47D0s5IiCh1XjSo8sYY5K4f+WVdka6k4nv30tG04M5EsQIFJF0Kcof9owQlpiWdaLVySC4YlO0HtpG04xZhOFsUsI5hlixHcRZDoISaRbmesE9xKJGDvXl+D+RFNiD+i6p43++sP6R4TFFvFYAtLZXnoBI2yxi79mCdGpDCwuHWRxtcs1yF612ZIxn50YXAoiEPitS5xsVNRli8c3F+o6rvwvsXVS3wZTs32eJ8R8TuKRUfm3JXx/9RBcHTkfVnyaKODSC8NLJ80ex5VfMDxxSsTcKiCBx2cMAicte1t7mk9NCj8wafT7KiYUCBfVDNkFAA3M2G5nT/D0EqV0IZ6RTdC5ZzWQ1mCH/HiJRTsI4N/a8BzRv6aBO2njZmLGt8jeJq6E9vPPkY9ESr6O6kmdkWrLsLWYOlVTDCLk3xyFABKenXct2mlv9ahgPSTXt/k8Rzptgj3/87E6xbTmnHpXmx8gRAxCxIzhrvd3cNwywflM0qeZVJJaJn1uAwKazmCsiUi0gRUJs5OZirxMSFDXTCiC93spTvCbUK1lOuVHT0FuMNX1gx56tQS8NmwF+wpd+fY80sHvsa+8Z/GLlPOvTaE+RqP7/fBJ8bbgjMkAoB8tuJQqaOg0twOT79ip3atVL3gwGUZmtzG0ihvQlKo0Tw8c= 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: AS4PR08MB8070 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT010.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 12a9dfbd-53bb-4373-066f-08dba301f3e3 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9mhAGAy8f6E89GlCvSlW5a4GlvKccAzgWNHhyw2tiiEbMPAZaUBlgyBndU6A/a3mXHMzZwCU70N7K9AKGecqHKfx35GuHoT5sYC1KtLrY0k3IlQABJEUkufc4TWyFiCSI0O+RY3vzBFuSlFCc7yYCRHcyFf1oRQQSYWhM0uFFRQWhLVXhCsFhw3YbRPyLnZwANDM/87N27hUCF2BNHZfUNc1uF+StLTac2tC+wt8rP3LtduDKZ67ikldj1NkO71hxMwbjpyKThdWicvobjzEBoDTS6WO/sSb3m7ULDQnImt2uj6j50rK06ZECaVDHPAjj5CNbnY5ZOw3ftgBQNweRV/SnJSLnA5PmoGZcWfJjPeMiiMW5bphbCPB9nCl0Vv9k87cA1siGU2SJKBL4fjm/5EI8742AK3qfcyWEyZUg7MDBb/TeqT3RROmK1shBnrJHUauS8MHHYmjB4z63alxjsc+JYURDsCbiO6Pc6KHQsTIjMzpf9xmS10/PTKhCsPzaqKLPjvuUwRNS4dOTmCVACgwg+siMjQxBnbCS2AdRiHhJk0/HQ48uTVNxSPRAVy1y5/gJj8xTumulo4W3ef63MC9r3nXHcAyofJJ0BBv6XqCMaf3r7wySZBXnVgKX2c7Q7qYRQiZsnLbZyOyVwtqsUV0GX0bxc9SF85Nz544UOiKeGdMPRga6p1B3L2Z4ooG1LK3+7eYbDbTdpHHnD1tuHYRwgZ7EiAuEf8rwIl8swMiz5+s82OsHIKGEWNT8MqKLaY1MFZSazsgQ39YMe8fVA== 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)(376002)(396003)(39860400002)(346002)(1800799009)(186009)(451199024)(82310400011)(36840700001)(40470700004)(46966006)(6916009)(316002)(70586007)(70206006)(8676002)(8936002)(2616005)(107886003)(4326008)(36756003)(40460700003)(41300700001)(1076003)(82740400003)(81166007)(478600001)(6666004)(40480700001)(83380400001)(2906002)(86362001)(47076005)(7696005)(36860700001)(336012)(44832011)(426003)(5660300002)(26005)(41533002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2023 11:21:47.0686 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 48c59f65-319f-4e1f-728d-08dba301f8ff 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: DBAEUR03FT010.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6709 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 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Luis Machado via Gdb-patches Reply-To: Luis Machado Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" 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