From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 4BU0On/q+WS9kRIAWB0awg (envelope-from ) for ; Thu, 07 Sep 2023 11:21:35 -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=xdijpNFC; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id EB5621E0D0; Thu, 7 Sep 2023 11:21:35 -0400 (EDT) Received: from server2.sourceware.org (ip-8-43-85-97.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 DA68F1E092 for ; Thu, 7 Sep 2023 11:21:33 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 89EC53857033 for ; Thu, 7 Sep 2023 15:21:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 89EC53857033 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1694100093; 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=xdijpNFCJFAhir8+V3+nl2hpKdHIX/WwCWoSCOIU4k6r4KBrxMRAH3pyGV4fsyOPK UzyMDzuIwS4YCNe1+tI70eOjbLzTUngc6q60XTSAIJGXQhLkF6E5JOJ6pnorD+UeiZ WINlwa1Y1t1dP1Zexz/8jW5Z5AqBYhmn7bsqMFls= Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2064.outbound.protection.outlook.com [40.107.20.64]) by sourceware.org (Postfix) with ESMTPS id EF5FF3858C2D for ; Thu, 7 Sep 2023 15:20:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EF5FF3858C2D Received: from AS9PR06CA0617.eurprd06.prod.outlook.com (2603:10a6:20b:46e::28) by AS1PR08MB7659.eurprd08.prod.outlook.com (2603:10a6:20b:47a::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.36; Thu, 7 Sep 2023 15:20:33 +0000 Received: from AM7EUR03FT026.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:46e:cafe::1f) by AS9PR06CA0617.outlook.office365.com (2603:10a6:20b:46e::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.30 via Frontend Transport; Thu, 7 Sep 2023 15:20:33 +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 AM7EUR03FT026.mail.protection.outlook.com (100.127.140.154) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.28 via Frontend Transport; Thu, 7 Sep 2023 15:20:33 +0000 Received: ("Tessian outbound d084e965c4eb:v175"); Thu, 07 Sep 2023 15:20:33 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: f1eb73e6e71d3d62 X-CR-MTA-TID: 64aa7808 Received: from d6a8c2638626.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 38B31D06-3023-4206-B78B-539D35FD1351.1; Thu, 07 Sep 2023 15:20:26 +0000 Received: from EUR01-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id d6a8c2638626.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 07 Sep 2023 15:20:26 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=URVcNhlEnjIeCCRqhIArt23eBYADNtA9qrjoq8SZOD50yls7Lxw8UPz3sTA0qci+DQXiGNVh26SEOxoy3k86scrr4/+cW2i5xjqNm2ZsI9WkjVZX3pzD0dMQ+qkYIasWbLw6bCbyI3/UMUmu2JFk0aIJ0OculkODj+Z6rIOnnhIkRI3UNSjhiW6AG1zbXKdtv6r6n14e+6T0kZsRwDQN6LMTys+8wDsxKk6Q6RtETVXrtHkLkSWoy/37mtMACbEDwxLlq8dD/3wzymANGVZSkVJLLa4ksgePCbkUvzfj5uJmkkw65Irmrzl6/ksUV/jNW90RtdxYeARfHOcTe+YTQw== 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=aWqCrLzF9FARk/RZvnCJ0MzUHG3M8vbBA52ltMNvlchb+VNL4xJwrLQi+6+2l2SaB10CwRC1mNwCCzjeRmXqqnrEyIup5DbwbHTe/zSi8jde3M1sJCK7VlDa/UahPSPawqyk3SKDak9KAfpbeYNPjtsTY1XxHO0/aIPkhBACgEniiufrS2nDltptNLwb7Lo5DaKHSZgVOwYI+mrLOmIZUni3Ubjo3iQHD4U6WVBoPecnwk9G1mvRnP4hKHv49hxE1Nv3Qro9P7+tfRUVEZ4xTmcRTnnpeBnIF3r9f6rG4292sndJQqb3zwmD+/WqM6CueKV/Co4ANaBe0VykXxReCA== 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 AS9PR06CA0627.eurprd06.prod.outlook.com (2603:10a6:20b:46e::31) by AS8PR08MB5926.eurprd08.prod.outlook.com (2603:10a6:20b:29d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.36; Thu, 7 Sep 2023 15:20:23 +0000 Received: from AM7EUR03FT011.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:46e:cafe::7d) by AS9PR06CA0627.outlook.office365.com (2603:10a6:20b:46e::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.34 via Frontend Transport; Thu, 7 Sep 2023 15:20:23 +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 AM7EUR03FT011.mail.protection.outlook.com (100.127.140.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6768.30 via Frontend Transport; Thu, 7 Sep 2023 15:20:23 +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.27; Thu, 7 Sep 2023 15:20:23 +0000 Received: from e129171.cambridge.arm.com (10.1.32.59) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Thu, 7 Sep 2023 15:20:23 +0000 To: CC: Subject: [PATCH v5 12/16] [gdb/generic] corefile/bug: Use thread-specific gdbarch when dumping register state to core files Date: Thu, 7 Sep 2023 16:20:14 +0100 Message-ID: <20230907152018.1031257-13-luis.machado@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230907152018.1031257-1-luis.machado@arm.com> References: <20230907152018.1031257-1-luis.machado@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT011:EE_|AS8PR08MB5926:EE_|AM7EUR03FT026:EE_|AS1PR08MB7659:EE_ X-MS-Office365-Filtering-Correlation-Id: 1c410512-8d98-410d-c235-08dbafb5faed 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: RlM6pHwWKO9i32597rgNrNZEqstOX/blwR/njKGTlGb5eYd7JCZ1A1mvPGLnlehJ7PR89DMcbSZmdlugRD07BACNVk0sq56w48+iroWF+QknO4wZ05viMqtZHTkivzXeqzfSxRhYmobJC9Qwk2xq9ad5YlsdDAGpEE/ilS/u6K7AsQ/41mzKPpJxrOnixrlntSWlX6KJ9C1k6ZB5i1R1WcNckUEL6ihXGjMofAACteffnf9b2mkbdEDsw8S02puiT9iH21t0ud7Q0OBZa6qIsX+DcwQBFa+KJdOzlhjeZlYM6PvnJ2NfLBfEtsLf/2ccX2dMI7t8grLpKgIgIaAjHwgSDq/8oVR57rDiARmhwlRqqsLUgxd+mFEqTaV2Fam7aa87+TYN0bbVZImo/1mlUJkUkng3XfhvSeBvqhXi4s/rezFXT3Nb3CzNr8scK/lwr+Ub6rBCXbG4NYfUGU7sZOHlqYf6OB5UrorKurFaTPt3VgFfUYm4AzklcQ4Y+N44WfOViHAYJQLViImWqqAVcj/bzBmiUvZ+lkvhp61VFcaNuFgv9GUjShbt/tFZKfnGcNaY6eBNRfws+i1P3drx2BmspVlia81DHRRISRch1WItP7VMO3EOubBl0ugCmkJ/Rv/wgxGyoaLKLLe4vOznwXVowSAzOjfq6VgtXpPO0VDK3Xk4yIj2/xcbxUF9nB8+zhf6qDKb5XaC9xJn+rvGiBp1hIrjW3yqrQzZG/My0ZSRWSER0kDnYLXO8cJ3GvkAf1XwGMx9AnF8vEDSOveLOKGZIss0pxFe65xg8O3CQZs= 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)(346002)(136003)(39860400002)(376002)(396003)(451199024)(82310400011)(1800799009)(186009)(46966006)(40470700004)(36840700001)(5660300002)(44832011)(8676002)(8936002)(7696005)(4326008)(316002)(6916009)(70586007)(70206006)(41300700001)(2906002)(478600001)(6666004)(26005)(2616005)(1076003)(426003)(336012)(47076005)(36860700001)(83380400001)(81166007)(356005)(82740400003)(40460700003)(86362001)(36756003)(40480700001)(41533002)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB5926 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT026.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 594ef489-6740-4a81-55c0-08dbafb5f505 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bbrBm2PflmCexO+lH2BD9t61BHVAIgCCEFQMWMQaJQJEqGMpkgc1RaI6R5WaQ4BrUyCduxRscJ0/OB5x7Oa6uUk2XCnO1gH2/UY8fJvYJewXGbGKzDEmwIVXFkVm+uYRvKHlIQohsZI5Rh85/lkz7Si5C2cRHLkeFrElJkjta2x+4awUgxhmX3i2KaEYayLEtFODlPT4ebkzPblx0+ky+wPTxrNNPuLj59VFrpvE9OeKocQE2+fEjuPn+Kh+Fn1odPYF3rujtKRp2IRiTp5y2yhXzCJUUPkAIC7R/p2qhKqfsrsTXroS/WASzzH1sB3WLcZiCmgJoHtG3DwHnXquU/AHNjUw7GgAjAeR+/EODrMRuCzplUMnjPOv+iLgfNeTFCv8ds2Z6pWkJc2/+N88+DPyOPtb9GSaCnOix+tiHUCwtohmg1+xhbg57DC+yM+0M84laf7iGJSLco2GbqQI+krKq2+n72deAnMwm4bEzHYjXKF4MZ8IlvPMpLuViUeksejcN6f086O7qXoc5Xxujl8k4mbeeXHIX4MNppOjt0qAjztaMC5vIfpJXm1yOhK2gV5s6Cmk9Ox+8Ay9jp8e8IN+VWTas+k57b5vOvP02exmJUI2GQXsdItJt7jZKoTOyaCVR7z8insilnyDxTxNvK6JOALALParW7GxBmKgJobAlfJWxbIo0nsCm68JB6QsxKKXdErXAF7LRqujG2K5Hbp66v1orGnWZnVbH1dQMt7/y0xa9VOLVM+0qVXvFUEIv/GWfOSaPQAMHaIE4g+O/w== 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)(396003)(136003)(346002)(376002)(39860400002)(186009)(1800799009)(451199024)(82310400011)(36840700001)(40470700004)(46966006)(81166007)(6666004)(7696005)(40460700003)(86362001)(36756003)(36860700001)(40480700001)(82740400003)(47076005)(1076003)(107886003)(2616005)(26005)(426003)(336012)(2906002)(83380400001)(478600001)(70586007)(70206006)(4326008)(8936002)(8676002)(5660300002)(44832011)(6916009)(316002)(41300700001)(41533002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Sep 2023 15:20:33.6259 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1c410512-8d98-410d-c235-08dbafb5faed 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: AM7EUR03FT026.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS1PR08MB7659 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.30 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