From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on2052.outbound.protection.outlook.com [40.107.14.52]) by sourceware.org (Postfix) with ESMTPS id 8C44D3858D35 for ; Fri, 8 Sep 2023 11:09:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8C44D3858D35 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=NFTW8L1PimK/kFffN6Wa+XibZfN9c+0rcv2m6D8+n8U=; b=l5AElp0h113LJsyOqLRYQulcqnQ4Fr2u+Hz3Mv2CSX4ej7i3eHp5uXRMeWN47F8wulRJSQE0rUV7YQhFiua3/6ttL7VIGq2AEAZ8jgU0Cew/BsljQahXxt7UFX4KGBlL8XqdBcj9JyaHw9QPxKG1u0sl0S2hV+WhAb/rZ/5HdRg= Received: from AS9PR06CA0205.eurprd06.prod.outlook.com (2603:10a6:20b:45d::31) by DB4PR08MB7935.eurprd08.prod.outlook.com (2603:10a6:10:379::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.30; Fri, 8 Sep 2023 11:09:35 +0000 Received: from AM7EUR03FT023.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:45d:cafe::d9) by AS9PR06CA0205.outlook.office365.com (2603:10a6:20b:45d::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.30 via Frontend Transport; Fri, 8 Sep 2023 11:09:35 +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 AM7EUR03FT023.mail.protection.outlook.com (100.127.140.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.28 via Frontend Transport; Fri, 8 Sep 2023 11:09:35 +0000 Received: ("Tessian outbound 1eb4e931b055:v175"); Fri, 08 Sep 2023 11:09:35 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: a11453bef32d4777 X-CR-MTA-TID: 64aa7808 Received: from 4536aadc45dd.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 5070CB3F-D613-4FF4-8C5A-64265DD26300.1; Fri, 08 Sep 2023 11:09:28 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 4536aadc45dd.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 08 Sep 2023 11:09:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VQVRUs8vVIdu0v7EqX0LArAKB/vpdWUt4yITfNgHrRe3tQwRqwe3XfA/ExVSH9WpfUJm7hEIdZ7Pdu1dt16r7GNNHiD4/icRSYfhPT/HrnIyZdapnt4+ibYblXkRbwKCIyb8NaeE45xFxzFTZFuDkhOk6lFcYfoYRhaZpvxH0uolzlHsf72pvD5l5Hy1GDCkVl3LLVJ2i7O6xLtPDpuKoTa10e7p7TcCxQwoT+LP6+p5Cg7HqRX8fWGklzy2w0PkMJOl4z42i7whwKs+wQrYqBR6JspPpmnd3PW1ltHxtAHamMU8+Ckp88nEA+sv3igKZXXhP8JxMTeLs+16/YeSYg== 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=NFTW8L1PimK/kFffN6Wa+XibZfN9c+0rcv2m6D8+n8U=; b=VJzBx+8mAd3yTznLlACmGyHVY+pmSjFUc52CqusLBE0fDM1Qfyach0F6Qv4HcQUrT/VXorjMcObKyOlgCodEHrrk/qLwRGH5U3eH7+R7UlfKTuLbHXG4LRp2vs8msNtutoV9s7W8gI0tmD3EruEhZlGsg9yh8foH0nOXAdVtlk/ieGfiHjzcIH2O7ETtdcfNdfNfGWAuCama6dM66nO7WuBfZQrwI7RW98cOnmzXlO4kXKN0fp0oKpVGnDTZx5sFFd8nuRXe9N+YcXuCXBMDOnth7IAICrDQcynu/imGyJ8moNPbYaooMP+QQQLamz0W6jzL3tJIy9E9Y3xkTd5sdg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; 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=NFTW8L1PimK/kFffN6Wa+XibZfN9c+0rcv2m6D8+n8U=; b=l5AElp0h113LJsyOqLRYQulcqnQ4Fr2u+Hz3Mv2CSX4ej7i3eHp5uXRMeWN47F8wulRJSQE0rUV7YQhFiua3/6ttL7VIGq2AEAZ8jgU0Cew/BsljQahXxt7UFX4KGBlL8XqdBcj9JyaHw9QPxKG1u0sl0S2hV+WhAb/rZ/5HdRg= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from VI1PR08MB3919.eurprd08.prod.outlook.com (2603:10a6:803:c4::31) by AS8PR08MB9410.eurprd08.prod.outlook.com (2603:10a6:20b:5a9::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.30; Fri, 8 Sep 2023 11:09:26 +0000 Received: from VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::7743:60fe:4859:2df2]) by VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::7743:60fe:4859:2df2%6]) with mapi id 15.20.6768.029; Fri, 8 Sep 2023 11:09:26 +0000 Message-ID: <971a9e69-a802-7354-728e-573d4c85c3f9@arm.com> Date: Fri, 8 Sep 2023 12:09:21 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.0 Subject: Re: [PATCH v5 12/16] [gdb/generic] corefile/bug: Use thread-specific gdbarch when dumping register state to core files Content-Language: en-US To: gdb-patches@sourceware.org Cc: thiago.bauermann@linaro.org References: <20230907152018.1031257-1-luis.machado@arm.com> <20230907152018.1031257-13-luis.machado@arm.com> From: Luis Machado In-Reply-To: <20230907152018.1031257-13-luis.machado@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LO4P265CA0019.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2ae::21) To VI1PR08MB3919.eurprd08.prod.outlook.com (2603:10a6:803:c4::31) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: VI1PR08MB3919:EE_|AS8PR08MB9410:EE_|AM7EUR03FT023:EE_|DB4PR08MB7935:EE_ X-MS-Office365-Filtering-Correlation-Id: db12eb60-77a8-463d-ccac-08dbb05c15e3 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: XwYP1J32CzyYTgZXQaenEUFdLCp5O+oGpW1mQTMSuDutYGBzYrzG/EjhF6aVMVJg0QvU4pJkNHTtYOjR1zTge+Wzc8qJBewqvuQo4uiMir6KBleutV28nIxJchMHHQi6EzZmeezkH+7wAUfPV0mG+nBQCgf8kSsYb0k4dQFt5h9rl+ieIMMCGhoYqxi9cgUCJtKi4DKqvqMtae41Uvhx0HK0JRgQwu4PkEQMnUPwjLFRJf11YyRogE8PEnAcmXIs8RC+bmxYn8ybaa7GWPK/pZ8D4F9R9SJboFoZiNLAn3PZjVZlKtku0rC1tPo4Djiw3AN4B4WU/xrbQxx/ZyBh9BPghaDS9colKDJm/wo7TYZNqtK17nJ0cDgibS0J/z60rgMcFRcFKM1xRYmbShlzysmy8kQq4b6Gq0Sx4HFt2g7hjfNOb1gpQb/HbU4lRdWKtxXeF2vufOo7gZR0T+ZMUq8gTPN26y9AwajiZpjH9L9xrF8aO0OGLdEiekXABIW62rXR8n+JdCzgC2rG/qNr6wp/tQ0/0VKd/xX0OhZB6OzxvXcYS+dLdHIb3ZCiVogW8t2xYgJv2rZPrtLMoNYo1cPkBqFaSAyP93oXcrhIAMtr5qEmb8AAGpcz36Ysc05FfiJkAJBlrrdAzFpBXKo0PV09FA/qYqahk5ZYpuzxOQs= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR08MB3919.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376002)(39860400002)(346002)(136003)(396003)(366004)(1800799009)(186009)(451199024)(38100700002)(36756003)(86362001)(31696002)(478600001)(6512007)(53546011)(6666004)(8676002)(8936002)(6506007)(6486002)(4326008)(44832011)(5660300002)(41300700001)(31686004)(66556008)(66946007)(66476007)(2906002)(316002)(6916009)(83380400001)(26005)(2616005)(41533002)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB9410 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT023.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 51b1a0c5-b6f3-4e5a-6865-08dbb05c1088 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YnXHEk1yAz2BlzTpnoV/ouvmKMfcH7pgKvTyGjJtNXYSx2p3upDSQzXRQdUviT5i4ZKb5XGmCEGjwZtpE3iYGSytho52E1bgKz5Xx1VqMmtDldxkPPf10ZwjY12DgJ/pz+PZ1BS1SBvPez9cpy0sc1pHRXesK8+hP6sV8Mdl5gNfAE2rqQj+Q6hwo3CLZB+8X4wnKtGtlutcdoaXKHiOOAukBC+I4MxNBCOShPfVX+j3nyeW4bYXVomBPlaZt2t1XtttZFWLMcsF04ryBwiYlq5rQjvBQ+5u9AEZR4kv26OKAeTh//dhEtiOjVUXMz4ikABovAqJubDmfz8sFBSpw4JVERVkPl28178DAjIQDgzHzRkVYZl9/nQk4DfO6NdDwf4eL+0wpiBJdr8V6pMm3Ckxo6oOZz0oN3aSr9qL9XW11zX0sDHNv/3xyXPKpHpDaHges0vEg1TaY4is4pRZ4TflD3adKhCBQip7n8yQ2TME10WYZVIx5LbduAKtZ5B6Ce4p7/p30iHiPTcARL2OnPdBgRvFn8vBZ1ZznhyEg6VTVvbmoQj98vLajkhBB8tpUe19v6475ton8NHaB4HArVFZUBS3zU2N2gVebkM4rDNbfhnmJHlqJSdAgf4wNz3/UGVO0Srw2SuV8K8fTnyqULBkG17vRUDPgUDd7L89oKgfMb679jIBjTc0uwWCu6OnAYDrv6WdHTOabY22i8yNGmlTooy6dFiAMn7bP8iZztQ/8uyRM9VhoOluvk+VVmLImzGw4T9qfuLPIsSyB67jdRo1h299xOnzr5l9XhyZy4I= 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)(346002)(396003)(376002)(136003)(39850400004)(186009)(82310400011)(1800799009)(451199024)(46966006)(36840700001)(40470700004)(53546011)(6506007)(6486002)(41300700001)(40460700003)(316002)(81166007)(82740400003)(36756003)(2906002)(478600001)(31696002)(86362001)(356005)(70206006)(6916009)(70586007)(6666004)(40480700001)(5660300002)(2616005)(83380400001)(107886003)(47076005)(8936002)(8676002)(4326008)(26005)(336012)(31686004)(44832011)(6512007)(36860700001)(41533002)(43740500002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Sep 2023 11:09:35.3162 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: db12eb60-77a8-463d-ccac-08dbb05c15e3 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: AM7EUR03FT023.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB4PR08MB7935 X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,FORGED_SPF_HELO,GIT_PATCH_0,KAM_DMARC_NONE,NICE_REPLY_A,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: Could a global maintainer please go through this change and let me know if it is OK? It touches a generic part of gdb. Though I don't think it should change the behavior of non-aarch64 targets. On 9/7/23 16:20, Luis Machado via Gdb-patches wrote: > 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); > } >