From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id QNMPN1EmAGWhzBQAWB0awg (envelope-from ) for ; Tue, 12 Sep 2023 04:50:25 -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=nyLq7xI/; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id DD0AB1E0C3; Tue, 12 Sep 2023 04:50:25 -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 C0ED41E028 for ; Tue, 12 Sep 2023 04:50:23 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 247DB3858404 for ; Tue, 12 Sep 2023 08:50:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 247DB3858404 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1694508623; bh=uxVzfDOxLTo3NvgwzWMBVW+rqKtnNCz9jlKzk2wyJEI=; h=Date:Subject:To:Cc:References:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=nyLq7xI/Ou/Ahpxmz/A2FSi+5eYwkZg2yUv1P+iLAL+1UXRbhPVte2iiU9LzzaNAm C4PBQAxqMung+2veu6Rfb2K0t5bfm2kU7d7YZ4T/0CCuehYwmlQJRhqH9u+RK6JUOs sGMUj6qXEKj9BLOUwR1iSji+AXHNjOnZdLg0mKH8= Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2071.outbound.protection.outlook.com [40.107.8.71]) by sourceware.org (Postfix) with ESMTPS id 4FBAB3858D3C for ; Tue, 12 Sep 2023 08:49:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4FBAB3858D3C Received: from AS9PR04CA0161.eurprd04.prod.outlook.com (2603:10a6:20b:530::7) by DBBPR08MB6092.eurprd08.prod.outlook.com (2603:10a6:10:20e::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.37; Tue, 12 Sep 2023 08:49:50 +0000 Received: from AM7EUR03FT025.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:530:cafe::84) by AS9PR04CA0161.outlook.office365.com (2603:10a6:20b:530::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.37 via Frontend Transport; Tue, 12 Sep 2023 08:49:50 +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 AM7EUR03FT025.mail.protection.outlook.com (100.127.140.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.17 via Frontend Transport; Tue, 12 Sep 2023 08:49:49 +0000 Received: ("Tessian outbound 5c548696a0e7:v175"); Tue, 12 Sep 2023 08:49:49 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 0a25b3131db8f809 X-CR-MTA-TID: 64aa7808 Received: from dc1feb90da13.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id F484C94C-9D38-4F47-BBB2-5B9E2D8F0736.1; Tue, 12 Sep 2023 08:49:42 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id dc1feb90da13.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 12 Sep 2023 08:49:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i9cvjYNz1Pf720mCub6tZSA7yrMdu7L4XjPhaARDN7phSZNspLY3wGC3HLCoNZsZNuC7+d3MzNAP7MljNqsgQqn+NvEFiPjFNDfx+VcPO1GMYCDXvj5/e7iUy37SZeBgTii0XxyqdFJdmx0qPHTJUcxdCew0wP3+nXF2nViJmB3tcKeYjJW9SWmHIUVmLN3SLG4e7W0LAgCHSUwTtRb/f7o7K8te6yalT5G+YIzj3TNdNmfkxanT4UOXSLwrg5skb0P+J7zBFD3wJhCiz+6RRqBMcryhP2xRqx/Eaf7MAke1n33Z36MStdmWMGYH2v1iYkIvf9IlpDWrxhsdaXdPQA== 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=uxVzfDOxLTo3NvgwzWMBVW+rqKtnNCz9jlKzk2wyJEI=; b=dr55ro67ugbS1l8lQ4esGcRw4Sq86cWZ30fx8VHzJRH5l1/6WLDKv9/EoWH3psBq3FaenfAVevX2qhMHODMS8fzbffcHzzec+QuQ6obJNjAkfjnaaJuKtBWo/BF5rvn71obhDid67ilxjMHaHsRuIfNklBdQE7mSNcFfpo3d0Y/JAEE99fHqiy3s7nTDz4wEz6lkPp82ASMBL1uQNjSXXyTR31UXv9fjmY04G03GO/BGdhtwFyXq12XjtJ161T/riRC5ILK/q6RUOLSZPDnUn7kZkgTgDbYDw+GMof0qa9uHJryPCmwM4aNsBme6uZ6LU10toEnYHluwwFWD4gV8ww== 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 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 PA4PR08MB6096.eurprd08.prod.outlook.com (2603:10a6:102:eb::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.35; Tue, 12 Sep 2023 08:49:40 +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; Tue, 12 Sep 2023 08:49:39 +0000 Message-ID: <5b65717d-0a67-5f4c-e9ae-ff99cc00f369@arm.com> Date: Tue, 12 Sep 2023 09:49:29 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.0 Subject: Re: [PATCH v5 13/16] [gdb/generic] corefile/bug: Fixup (gcore) core file target description reading order To: Simon Marchi , gdb-patches@sourceware.org Cc: thiago.bauermann@linaro.org References: <20230907152018.1031257-1-luis.machado@arm.com> <20230907152018.1031257-14-luis.machado@arm.com> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: SN6PR04CA0085.namprd04.prod.outlook.com (2603:10b6:805:f2::26) To VI1PR08MB3919.eurprd08.prod.outlook.com (2603:10a6:803:c4::31) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: VI1PR08MB3919:EE_|PA4PR08MB6096:EE_|AM7EUR03FT025:EE_|DBBPR08MB6092:EE_ X-MS-Office365-Filtering-Correlation-Id: 8c00e985-325b-425f-559a-08dbb36d3973 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: exzAnWxQtohrfxsdeO0T+LdmYdw7UaVOJl/G2doxXK+azyMsd0tzf+4LZDNpVIYjSHqMZv1tqb3pMsOJlLV+muyfpkN/tDUk6eQZzQibp+mPfgRI0DC4g1vGLtCr29uECbdvCTJJP5c3G3aOZNdQACDmjiRxmosWe/DrVlBENGs8mekGsEapSHESugfBRkosvevlsRGavn9B2Z2Pld3tWbR4DYgRsMy+/CSZYqdp2rBtkOgvNU4s9vbw2icgRdVwwg4D2+MbQCIu0tn73YwEZ600O/+/GB2NqB8X7HihJsLPF/3yslT9V7s0GXfhcttBitEepaMh4Vu/pAYb0BJOA3h2qja9ZW9eG4cCxlROyQogn/IrtSx2byk/9VblSEcpKkAGk3wJgqT1BPwNik3qWkTv1TLZSuqWGWrqjwZi3TzJ23VU/SC8iapI7sngMdXM3T4LlZcf81Tnt4rhE6SG2FH7Wa6Dt3dzNj8quhMYzjL3Z91oEVZA+g0L5AG1wMjx3ApCCR9fMTIiUwcGrc96zRgS8tw7J8CLcWIUhdYOLBRYZrkqaiiFId07CKKPHKxcFGIYnKMQIBQrFnHjenKbDcgD9jSZhQ3WwFGVewIYX5VQyV+caA/Mc/LQiURW2Z+zlfU8LAei8NP6VgLPw4/9i6NrKcr+5pStF1Tty/Thziw= 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)(396003)(136003)(366004)(376002)(346002)(39860400002)(1800799009)(451199024)(186009)(5660300002)(41300700001)(44832011)(31686004)(8676002)(66556008)(8936002)(4326008)(66946007)(316002)(66476007)(36756003)(478600001)(31696002)(6666004)(53546011)(2616005)(6506007)(86362001)(26005)(2906002)(83380400001)(38100700002)(6512007)(6486002)(41533002)(43740500002)(45980500001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB6096 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: AM7EUR03FT025.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: b05c6945-a8b5-42e5-95e9-08dbb36d31a6 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rWZZHqJjmEcXgWB0XwRpBFFjrnVl828YDe9dTQJjTwwErCWgh+MhBWWBAg01yv8VAgS0uCAk7Pln6omVm1aobVng5Jbqi4wh7tviyGITK2ISoT9dngP99oTs/z9XYZEkYBUEvi4jLDxdh+tiGWCocCRs/DKCIqCdmhn0IsvtjAFIKYyMImQEpUtgEkW/+0LtjRihJq99dSdd2Og6TEn06gh+4PpcJHdcmEVgMcUw8jEBzbqddal3tLMLOvLvoljd7I2bb8hu3aVf+JOcczgTuq4x7RsOjUuqkHcxTw7uLYMn/l24uxJ6B2RZ2ZAU4FkMcxlIxl7NqfluVVUFyL0scTQw8VT3FFTZXWUahg57/IZHNQV2Ago01eygZzXjGYq9MezdIhb5oCAfYeR6ofe9ejNuKdq36EylCpMypCNEfdlL1GwtmQiFlpW0/NoKU1omACQRzxRT7eVluRETKP4Lri09vCnNuFQsErzRblxG+nc5SLBEHJo70fhBllCwuv4DJ+2+IvtShnud81kn/W59dAjIKZNu3B8svzZBeghG7Z5EAJYglUOa+uBWnhNBNYLfsleShq24UXqiUNCQKlQQMnxRfcCq7gJqySezCBK15RffL8mgQy+mBb+yY6JhV9WQ8/RFQa+f7aaeSfTQ6+jsDe8hpFmgD+yH1pbz0HSFF3EfnkYqBN7EzGTj1nh3y2C6Yixn3vUjnqZZ4ROuDzJjPWVCxnuHltrWNGTrkdIe2REbxkmDCL3MirY//Q+LvDNarQd/3IJHlK+lH0GlaV/E11Seey0z/gFr+cYDzQFoCvg= 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)(39860400002)(376002)(396003)(346002)(186009)(451199024)(82310400011)(1800799009)(36840700001)(46966006)(40470700004)(316002)(70586007)(41300700001)(70206006)(40480700001)(478600001)(81166007)(356005)(40460700003)(86362001)(36756003)(31696002)(2906002)(44832011)(5660300002)(4326008)(8676002)(8936002)(31686004)(47076005)(336012)(26005)(107886003)(2616005)(83380400001)(36860700001)(6486002)(6506007)(53546011)(6512007)(82740400003)(6666004)(41533002)(43740500002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Sep 2023 08:49:49.8942 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8c00e985-325b-425f-559a-08dbb36d3973 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: AM7EUR03FT025.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB6092 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 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" On 9/8/23 18:10, Simon Marchi wrote: > On 9/7/23 11:20, Luis Machado via Gdb-patches wrote: >> Due to the nature of the AArch64 SVE/SME extensions in GDB, each thread >> can potentially have distinct target descriptions/gdbarches. >> >> When loading a gcore-generated core file, at the moment GDB gives priority >> to the target description dumped to NT_GDB_TDESC. Though technically correct >> for most target, it doesn't work correctly for AArch64 with SVE or SME >> support. >> >> The correct approach for AArch64/Linux is to rely on the >> gdbarch_core_read_description hook, so it can figure out the proper target >> description for a given thread based on the various available register notes. >> >> I think this should work for other architectures as well. If not, we may >> need to adjust things so all architectures get the information that they >> need for discovering the target description of the core file. >> >> Regression-tested on aarch64-linux Ubuntu 22.04/20.04. >> --- >> gdb/corelow.c | 24 +++++++++++++++--------- >> 1 file changed, 15 insertions(+), 9 deletions(-) >> >> diff --git a/gdb/corelow.c b/gdb/corelow.c >> index 439270f5559..ae1641fe5d2 100644 >> --- a/gdb/corelow.c >> +++ b/gdb/corelow.c >> @@ -1229,6 +1229,21 @@ core_target::thread_alive (ptid_t ptid) >> const struct target_desc * >> core_target::read_description () >> { >> + /* If the architecture provides a corefile target description hook, use >> + it now. Even if the core file contains a target description in a note >> + section, it is not useful for targets that can potentially have distinct >> + descriptions for each thread. One example is AArch64's SVE/SME >> + extensions that allow per-thread vector length changes, resulting in >> + registers with different sizes. */ >> + if (m_core_gdbarch && gdbarch_core_read_description_p (m_core_gdbarch)) >> + { >> + const struct target_desc *result; >> + >> + result = gdbarch_core_read_description (m_core_gdbarch, this, core_bfd); >> + if (result != nullptr) >> + return result; >> + } >> + >> /* If the core file contains a target description note then we will use >> that in preference to anything else. */ >> bfd_size_type tdesc_note_size = 0; >> @@ -1252,15 +1267,6 @@ core_target::read_description () >> } >> } >> >> - if (m_core_gdbarch && gdbarch_core_read_description_p (m_core_gdbarch)) >> - { >> - const struct target_desc *result; >> - >> - result = gdbarch_core_read_description (m_core_gdbarch, this, core_bfd); >> - if (result != NULL) >> - return result; >> - } >> - >> return this->beneath ()->read_description (); >> } > > I'm not convinced that this is right. The current role of > gdbarch_core_read_description (AFAIU) is to provide a fallback to the > note method. Usually, the note method is preferred, because it's > precise, but if there's no note, maybe the gdbarch can derive a tdesc > from what it sees in the core. Naturally, this use of > gdbarch_core_read_description (as a fallback) has to go after trying the > note method. > > Now, you want to to use gdbarch_core_read_description as an override to > the note method, which is why you want to call it before trying the note > method. I don't think the same gdbarch method can be used for both > fallback and override. With your change, with an arch that defines a > gdbarch_core_read_description hook, where we would have used the note > before, we will now always use the hook. Not what we want. Yeah, it seems that way unfortunately. Looking back, maybe it would've been better to define the gdb tdesc note as a per-thread entry instead. I suppose we can still do it from now on, but the previous core files generated by gdb would still need to be handled in a special way for AArch64. > > Some options I see: > > - Add another gdbarch hook, so one is called before trying the note, > and one after. > - Add another gdbarch hook that allows the arch to modify the target > desc read from the note. So the flow would be: > core_target::read_description creates a target from the note, then > calls the gdbarch hook. The latter could return the same tdesc, or a > new tdesc. The AArch64 hook could then create a new tdesc based on > the one read from the note, but with the SVE/SME bits tweaked. I think the first solution would work. But I see it as a temporary measure until we update the core file target description note to be per-thread. After that, I believe the gdbarch hook wouldn't be too useful. > > Simon