From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2045.outbound.protection.outlook.com [40.107.20.45]) by sourceware.org (Postfix) with ESMTPS id 107993858C52 for ; Fri, 3 Feb 2023 10:57:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 107993858C52 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=9yX4ipNGbFe4gIhQe2Esx8El7EZzm3XUd2cSXXEznEk=; b=3JBw3/zg0PqohgpEk4KvP6E2zlPW92FtA/5s4rroZqeXT6IvvIl82VrkPR2S9al0qDlVIsBRie0ypQFfrSu9bR2q+1QhguQMegNtTQwckipfU8cJ93W7nnA81rYXwhSK4AGZIPqM4TlagANsNMUHChNbbsBr0x/wLWQPz/xXQ90= Received: from AM6PR0202CA0042.eurprd02.prod.outlook.com (2603:10a6:20b:3a::19) by AS2PR08MB9593.eurprd08.prod.outlook.com (2603:10a6:20b:60b::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.22; Fri, 3 Feb 2023 10:57:42 +0000 Received: from AM7EUR03FT030.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:3a:cafe::e3) by AM6PR0202CA0042.outlook.office365.com (2603:10a6:20b:3a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.29 via Frontend Transport; Fri, 3 Feb 2023 10:57:42 +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 AM7EUR03FT030.mail.protection.outlook.com (100.127.140.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.28 via Frontend Transport; Fri, 3 Feb 2023 10:57:42 +0000 Received: ("Tessian outbound 3ad958cd7492:v132"); Fri, 03 Feb 2023 10:57:42 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: b2164ef3264f62d7 X-CR-MTA-TID: 64aa7808 Received: from 59d2274a9a3a.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 820B342C-FE64-4C5F-AB5D-1DBAD827CDFA.1; Fri, 03 Feb 2023 10:57:35 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 59d2274a9a3a.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 03 Feb 2023 10:57:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Q6rK2vfheOogvpwnKtX/q4VbJXwdVLOrepjz5/5R4P/NVuqscxvQm7RS/A3yLHXwkD/MkRv3j+2ICLhcKOqhByopjfQImlSTA6q6by1MuvTrITqI2bPhhq6x6nXNGGjoFOS3DRQ/1dsGmkUN0diRPrB9m1XcBUEF8vIdJnE07dLKIco+XDjUGQY0DsfhkaXw3Q8LbJjwgeM3QOb93gfY9BL+ncLl6n7wHXZu6HjxQ4UgcybzSsB2mhvA/B/vJNXxgP9UXTw82TCUn+UMbGUz/5gnLaOq6GyS/Bu7NY3Sg/EShhRDITEnGHGDIdbeIaPUvXiU5cd6yQ/O1yehVusgGg== 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=9yX4ipNGbFe4gIhQe2Esx8El7EZzm3XUd2cSXXEznEk=; b=g1jUw1bmt9UopyZPVPYpyRbX5Uq4n4unqKaN9STX25jChYtv5C3vl0tgFXhXapHgBYPsw/Qr7BY/ijZpgknoC3woVn2SdNeNIxvrkgytWlRiSIMZcsp4gXeXLUkjEYxyN0prUOmJ5dlr8jZ8ZYnWPjQA9qhC93bVxhmmoTkVx13UHljNlnz2FqXYFHrSyoCrkqjndqEYAC2JSSFcnZ2k9BRbSMxTGGm04uofZK+SiFg4rvLTABMEzOOwa+moKp22C9Nv+tN3V77eSbS2MmhaielsokK4WGL6Xs2nQ8JDDCDs1uMYlaSiSPO6rremUPomWvj7WHBX7ffsvZ/4oIqmWQ== 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=9yX4ipNGbFe4gIhQe2Esx8El7EZzm3XUd2cSXXEznEk=; b=3JBw3/zg0PqohgpEk4KvP6E2zlPW92FtA/5s4rroZqeXT6IvvIl82VrkPR2S9al0qDlVIsBRie0ypQFfrSu9bR2q+1QhguQMegNtTQwckipfU8cJ93W7nnA81rYXwhSK4AGZIPqM4TlagANsNMUHChNbbsBr0x/wLWQPz/xXQ90= 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 AS8PR08MB7885.eurprd08.prod.outlook.com (2603:10a6:20b:508::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.36; Fri, 3 Feb 2023 10:57:33 +0000 Received: from VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::bced:32a3:b77e:90a6]) by VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::bced:32a3:b77e:90a6%3]) with mapi id 15.20.6064.028; Fri, 3 Feb 2023 10:57:32 +0000 Message-ID: <7aa9cb50-7353-e9e5-6812-7615aaad6f93@arm.com> Date: Fri, 3 Feb 2023 10:57:28 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: [PATCH v3 4/8] gdbserver/linux-aarch64: When thread stops, update its target description To: Thiago Jung Bauermann Cc: Simon Marchi , Andrew Burgess , Thiago Jung Bauermann via Gdb-patches References: <20230130044518.3322695-1-thiago.bauermann@linaro.org> <20230130044518.3322695-5-thiago.bauermann@linaro.org> <87pmattzjw.fsf@redhat.com> <7970ac03-1123-d5f6-7b17-808832d43be6@simark.ca> <9a85e2fe-078a-e2ee-7e49-53fe0ceef492@arm.com> <87y1pgaib6.fsf@linaro.org> Content-Language: en-US From: Luis Machado In-Reply-To: <87y1pgaib6.fsf@linaro.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LO2P265CA0313.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a4::13) To VI1PR08MB3919.eurprd08.prod.outlook.com (2603:10a6:803:c4::31) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: VI1PR08MB3919:EE_|AS8PR08MB7885:EE_|AM7EUR03FT030:EE_|AS2PR08MB9593:EE_ X-MS-Office365-Filtering-Correlation-Id: 6a999400-2ad0-405e-774e-08db05d57985 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: KoXIXrbl25+neqffykzIHBFVhOIazqYMMG9ZheE8dM5shyGmZdRXsbC7zimL22EpSGAAVJRXABERqhMvqIiNL1l8n2P3mg2EqZ0ewQLdkE9VNsrH2IFhBAEzPwU3kFU9/QoEmwKHZufajiYYYAUhqvWGcNMKQakvmX9E7npBy+EUYTchVvM8rSng9XbUXrsbfYA8VUi0lkK8uuo9NvU5AD+V92FCFGEQhHJW0tTXjmZwSmjeps3+hOk8Wemo6JSZ9667vG4ukhL6g3/GsBvoFgFZj+fyVfNekU0YT5DURvAa8PGUjXEMYlHcwXgW2QJkkznN0ztAlx9m9m+j90viIIv3sk4et9JC1y0sCHKAfN9/RqmCy8uzjUpsw9uh8oMGHZgZ6RftukHptn7yKz3JoCKh0hoZiaAw4Vd0Z4GxYau2q7eSNs+ThFphEIymiXP9sEeg1XaEirBT6DRII4O7jXQXNVr7glI0Rn+A8L/HMEendZRm1FlqbZCGNJfsf/t7d3SdMBFGF3Tq4rdidx/jpO9IElbN/ss/ZB5gYfxDqcBghyHYDr+zmccPpEgsYq+S8T+7+n3W388o/9jh+uc4iNlUQ4QnyHYoj2NbGzemll1A4vC5TRHdLzNmGzrhVUeeo9KTbU6z3qULXde72iBodDIL6wM1bHF0TVwCnr8OO3j89Zh1mwU2fs+LR9y0mSTPyRCSUiM+wQ1HvzxZUjrho11wL3CXxt5gTNYjvQoz93k= 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:(13230025)(4636009)(346002)(376002)(396003)(136003)(39860400002)(366004)(451199018)(41300700001)(38100700002)(6512007)(44832011)(8936002)(26005)(83380400001)(66556008)(5660300002)(6486002)(86362001)(186003)(8676002)(66946007)(6916009)(31696002)(54906003)(478600001)(66476007)(316002)(36756003)(4326008)(2616005)(6666004)(6506007)(53546011)(31686004)(2906002)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB7885 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: AM7EUR03FT030.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 74dc7a07-4756-4f5b-d82f-08db05d571e6 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CTbchz1y9+fbSHTrtfDYNQacQtqHcATtYCpUbMpseKs3d17Ir8aRSQabkByGIfhk3PHmvcmm02JTFXpC1SeZ94Bmq3I8phWk8HNtqsJPBdmxRkkr/IdKkr7zYZHg/1xva+KTEgstUU1JUhj7fXq9bAsHlP98/4jsfrKbJL/8WenFvky5PqYXmNVC+sDDuhTc5PkCeFEJ8AGQbMQNXcJ66NaqvASwWT+TBfPKXn/xJntWBeWDCqgAAR6Xc7X1uJMFa+vXRKdNi5mSK1yz8aj/q22JoUM/QuN3NDtFOPe25pOPP6lm+zOLlqoOafUrvsRh3JsJSOfCTJsjmxdV5qy1gwl/iMsxVIJb35SalXasS17s2AcwE3LmRWwAlOwLJJvwsx/BktZPKoPbZ+h7NZdhJFFiNkQjVYnolm6UiqYN3+eXxnPWizdaLoSw5AkDz20894JyozBjYvB6Du1SKihxGy4ubMJGtiHu7UcVMiUPnGTpiCtZf8Q73D78TFb6/oU8/FcRH6nhbnUw/K0gYfM3K2CDwwyhRVRhdpHmD8nbf8gI9NW7Ca3bThBPoT47Jf3TYdSGvhrVJN671LoMFet78DfPS0MMlO7aAUz6Z2d6u8KWYCWAa32bO5Qt1VBKeUXFi0oxHUH/3yjzS5Vy14/JKrBfec/84kWlGcIrHNUMTNz+N1/p/H9RlD1838M8aBr+QvQAUw2AW7uEOK6cFrW/CO0pxOG+KCzrzpjB13V8cS8= 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:(13230025)(4636009)(376002)(396003)(39860400002)(136003)(346002)(451199018)(46966006)(40470700004)(36840700001)(316002)(8936002)(47076005)(54906003)(41300700001)(5660300002)(40480700001)(336012)(2906002)(36756003)(44832011)(82740400003)(70586007)(83380400001)(70206006)(6862004)(36860700001)(81166007)(40460700003)(4326008)(6486002)(8676002)(2616005)(86362001)(356005)(82310400005)(53546011)(6666004)(478600001)(6506007)(26005)(6512007)(31686004)(31696002)(186003)(43740500002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2023 10:57:42.7238 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6a999400-2ad0-405e-774e-08db05d57985 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: AM7EUR03FT030.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR08MB9593 X-Spam-Status: No, score=-12.1 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: On 2/2/23 02:54, Thiago Jung Bauermann wrote: > > Luis Machado writes: > >> On 2/1/23 16:21, Simon Marchi wrote: >>> >>>>> diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h >>>>> index 221de85aa2ee..b52eb23cc444 100644 >>>>> --- a/gdbserver/linux-low.h >>>>> +++ b/gdbserver/linux-low.h >>>>> @@ -604,6 +604,12 @@ class linux_process_target : public process_stratum_target >>>>> /* Architecture-specific setup for the current thread. */ >>>>> virtual void low_arch_setup () = 0; >>>>> + /* Allows arch-specific code to set the thread's target description when the >>>>> + inferior stops. Returns nullptr if no thread-specific target description >>>>> + is necessary. */ >>>>> + virtual const struct target_desc * >>>>> + get_thread_tdesc (const thread_info *thread); >>>> >>>> I think the comment for this function is not correct. The function does >>>> not SET the thread's target description, but just GETS a target >>>> description suitable for `thread`. It's the caller's job to do the >>>> setting. >>> This comment also gave me pause. How does a getter set something. I >>> then understood that it allowed the arch-specific code to provide a >>> thread-specific tdesc. I would suggest just: >> >> FWIW, I read it as "the functions *allows* arch-specific code to set". >> So it doesn't set on its own, but it does allow something else to do >> it. > > Yes, that's what was in my mind when I wrote the comment. But I agree > it's unclear, and I adopted Simon's suggested version. > >>> The other thought I had while re-reading the patch is why do we need to >>> return and store nullptr if the thread target description is the same as >>> the main one for the process. get_thread_tdesc could just return >>> process_info->tdesc if we don't need a separate tdesc, and we would >>> store that same pointer in thread_info->tdesc. > > We don't need to return and store nullptr if the thread target > description is the same as the main one for the process. Things will > work fine if we do as you suggest. IIRC my private branch worked liked > that for a while, before I changed it to the current version. > > I changed it because I thought it was a clearer mental model if > thread_info->tdesc is nullptr when there's not thread-specific target > description. I can make the get_thread_tdesc method always return a > valid target description if you think it's better that way. > >>> And get_thread_tdesc would just return that (in fact, >>> get_thread_tdesc might not be necessary then). Perhaps it makes some >>> things more complicated down the road, but I can't think of anything. > > Sorry, I don't understand this part. get_thread_tdesc is necessary > because it's the hook that allows arch-specific code to provide a target > description for the thread. I don't see how it can become unnecessary. > > Perhaps you mean the get_thread_target_desc function? Sorry about the > names being so similar, I spent some time trying to think of a better > name for either the method or the function but failed. > > In any case, it wouldn't be possible to make get_thread_target_desc just > return thread_info->tdesc because at least the way these patches are > currently written, when the inferior starts or a new thread of the > inferior is spawned thread_info->tdesc is nullptr. gdbserver will only > call get_thread_tdesc after the first stop (in get_thread_regcache, in > the process of obtaining the pc register), so we will need to cope with > that situation. > >> Sounds reasonable. >> >> Moving towards thread-specific target descriptions/gdbarch would be a positive thing given >> the SVE precedent. The process-wide target description/gdbarch no >> longer reflects the correct settings for each thread on AArch64's with SVE support. > > In the first version of these patches I removed the process-wide target > description and moved it to thread_info, but it was a big patch that > touched many targets. I can bring it back if you think it's worth it No need. As Simon suggested, we can do this incrementally. I don't think we should hold off on this series' particular improvements so we can get the more general case sorted.