From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2053.outbound.protection.outlook.com [40.107.247.53]) by sourceware.org (Postfix) with ESMTPS id AC92B3858D20 for ; Fri, 3 Feb 2023 11:11:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AC92B3858D20 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=tSALSsRhZoYLXusGHJ7zdzJXRffgWPa+dA787tT7Y78=; b=2cVYQPYQyeK4y9yh+Xkoe0hSqtBwQrNLDUAkL5QgQ5+IXNpgnHoODAqPknrLFmBOtJar9voFgixUwPoo5bDM6i4z8/9N+aGQia+679J39eubbq/3XAy8Ib3Jmq1W10MrDkVkL4NJgMxF7L/VHml5cWkX5zdf2DN5FME/2t7+gqA= Received: from DUZPR01CA0150.eurprd01.prod.exchangelabs.com (2603:10a6:10:4bd::7) by AS4PR08MB7554.eurprd08.prod.outlook.com (2603:10a6:20b:4fc::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.27; Fri, 3 Feb 2023 11:11:55 +0000 Received: from DBAEUR03FT037.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:4bd:cafe::72) by DUZPR01CA0150.outlook.office365.com (2603:10a6:10:4bd::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.31 via Frontend Transport; Fri, 3 Feb 2023 11:11:55 +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 DBAEUR03FT037.mail.protection.outlook.com (100.127.142.208) 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 11:11:55 +0000 Received: ("Tessian outbound 6e565e48ed4a:v132"); Fri, 03 Feb 2023 11:11:55 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: e72a85a4caff6fbc X-CR-MTA-TID: 64aa7808 Received: from 4de0c981b938.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 3C481F45-1915-4E45-ADE1-BC1B7B097B7F.1; Fri, 03 Feb 2023 11:11:48 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 4de0c981b938.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 03 Feb 2023 11:11:48 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MnBqZp2wmCKowkRhh11fKoQoUZnGAAHsxB/i1Sc3RbU4pR0ynefODfvMtmQje5OpDV1UCKp0L4N4l6lyRCcqwB2csRWrZDNyz6UoZvJVvEdnQm4yhEoFBkGGQXn2S7UBlQwtgFLgqacENeiFXxzLu4saaK5SNB3XKFsng0AFw8iqk9IrCmRKa7hz0t3yuJqlSacIx4h6REItA0pj86sbd6AE2na53/P6pFVa4zihAj8BVJ/N5/bF5gJXiPug1mLiNXZPdzOVHb3JXEWhiHLiisilJztVAkaQfrWn8oWhYlCh13owBYmQ7Xj5C8ZDYPSKavwb2rORRl1/IBTqcLfbPA== 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=tSALSsRhZoYLXusGHJ7zdzJXRffgWPa+dA787tT7Y78=; b=JjJHeAW3a4egGUAZTu9St+KCI1VTd9POQCilSzL6IZJtZu1X4h90Zj13DKj6QAiIKNDzJBqlPj+jujXkYlY7T9DQZoaJynURPFR8rz+2rJQEI9mLVJHx5eS3xdDD4jXylgVMSbrP00LOv0CVFx0mM/+o10koXhsUH9F0sAhI8klJ22I9z4pzoM2Zd08+5UYe7zbxUn7+Qf6tvzarfckU2ecNupBm4xDc9heIy+3soSEgzQxgWAX0CVhsbbwMWgdeRCiQiCjxrornAJ8TydQorGwwUITGhFC0q9n2peHlOEQ+fTahDlLKXxk9+IUSH+rz4nfUJ7UBUtAve9/fRaD/LQ== 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=tSALSsRhZoYLXusGHJ7zdzJXRffgWPa+dA787tT7Y78=; b=2cVYQPYQyeK4y9yh+Xkoe0hSqtBwQrNLDUAkL5QgQ5+IXNpgnHoODAqPknrLFmBOtJar9voFgixUwPoo5bDM6i4z8/9N+aGQia+679J39eubbq/3XAy8Ib3Jmq1W10MrDkVkL4NJgMxF7L/VHml5cWkX5zdf2DN5FME/2t7+gqA= 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 AS1PR08MB7402.eurprd08.prod.outlook.com (2603:10a6:20b:4c6::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.25; Fri, 3 Feb 2023 11:11:47 +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 11:11:46 +0000 Message-ID: <9d30751a-589b-eb95-09b1-61d083ad9730@arm.com> Date: Fri, 3 Feb 2023 11:11:44 +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 Content-Language: en-US To: Simon Marchi , Thiago Jung Bauermann Cc: 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> From: Luis Machado In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LO4P123CA0451.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1aa::6) To VI1PR08MB3919.eurprd08.prod.outlook.com (2603:10a6:803:c4::31) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: VI1PR08MB3919:EE_|AS1PR08MB7402:EE_|DBAEUR03FT037:EE_|AS4PR08MB7554:EE_ X-MS-Office365-Filtering-Correlation-Id: c540dab6-4a19-440f-4c71-08db05d775d2 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: AKQGfyfvH85wL/dzCHC8khcC91g0Nwp4SnbK4O7Eu94XgPXUVPqi5X1x0hpU3m5qNa+WtFQb8RA/XysZEk/FNXqy18cFjWv5lWobIWtkJyoEdpLpBh4TauTvTlCC1/mJvuWQIfJSSSTAz5Hk7RP2T9bcHc5SSfW3Wgi+3qkCMav9Pl7u8OM7eSVyQw2wcNYz/sqpPrvKtJsqHA0KMIW0fxGUzRIAmJBeRbwl14Lv9IynOVY6AF4G3N+NQzgGLCUqBWkudsNSXM9QtaVmU3y2wZPpyVMbSwJ4HD4y/BL0WX3ACw4o4/rFiRhVE0Fs+yvRNum/eyKCqulr2wf4bePYziq6MbJbDEpeCyc1I9RND7YcTFnOElRdB1V2hPiqFvY7XiUqMtvhcZTXWvh/HRVUv3AUHWBvSREHcRvKCBTati3z7+WMPwJ03PLiCWNwY1MXuIrAuXmO6gYzuEQxFrnXWocVdeBtXqUgCq4ewLhgJy9sL6+UJfSfZjvxyBP5/gVq5rrnrcYdEzW+HbJ7BXcv5lP42BAoDmJ5HutssZdBh/PZsj4v/nLpLFe7GG3Rso5f9qgnwjgr/2X8GPhWqYEoWWMPtPhW0+v3UjAQl8+jEqwWVO3K/djmh2W2uR+kb8eivc869Ek2gbaiz34va5zAk5LenxXtQCloMOO19/M/ci/17HpTDUsoNQNVlUjPviUvuBBed+eWwHOqeb6pYGKebnbtWjY008k1osvLvq71jbo= 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)(366004)(396003)(39860400002)(136003)(376002)(346002)(451199018)(2616005)(44832011)(31686004)(6512007)(186003)(26005)(6506007)(4326008)(53546011)(5660300002)(83380400001)(8936002)(6486002)(54906003)(110136005)(478600001)(41300700001)(2906002)(38100700002)(86362001)(316002)(36756003)(66556008)(8676002)(66946007)(66476007)(31696002)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS1PR08MB7402 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: DBAEUR03FT037.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: ca59fa4e-3cd7-4985-4c04-08db05d76fd1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rbOWP93UjO7yfxbnBfJyay9SSBZWIHB7Gd+GVpShnwuH+clMc785EE5eSTkGj6cIlIhvFGMgJ6QNGeoAOZa915x48oJfXTamJMyVMLYRRVX/mzUcLG/LXFhaP1OA6xleUBR6IAHznqg48ympjV23BgbGgkV9tsbSu4Uh9R36H+UWenZR46FpRCf8wF9i4QGOKWGEIAvHF6ulaV+XzGPTbnrEGO4gisGifQFfWeqGO52ShN5qtbtMmSY6txIjbLRrAYfFeTJUR/q1BzyNcjx5sysUCG9FbsgID4cO1mSYRNlXL+gQC37SHbiDtvTm2IpBIWxwqyS8BD32GqGuHBKTV7Go4vu2+OhRx5qpeaKWwp9qu8LsUCfbS4eWNmI9waV/VUZZah6tbgIcgKvAK4Qw7GmKsBCILqwteq4AE15VGBiZECZvfdg8+KH5OtcYpbi/EDdkM2YxCvwTias/1WTHQa4g3VFE4oawdFBRHxp4WKhBQKIg0YcWHWNHvCg9wDO3aDO8wadHxeBlmgkkgSTHN+ULpsWtl5nMlLqgI1+IjffJoG38cebnLZdUpCTDpV2Qa5w8lwVBKdvnFRxfh0CcNkgDdlKvyHRFx8EV/A/84a+hT5Ulvdvy75TIxyXUQEfFys7SRaahChmRa7Ru5fUWPXgfUbb1aTcwH8IucXZzTRYnlT1NMdi+2qQfj4DBVV4fu/0saitzens71sTYJbq+lec2mcReOciC/CDKbRoDH8w= 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)(39860400002)(136003)(396003)(376002)(346002)(451199018)(46966006)(40470700004)(36840700001)(44832011)(54906003)(2616005)(86362001)(83380400001)(40460700003)(70206006)(70586007)(36756003)(81166007)(31696002)(82740400003)(4326008)(336012)(41300700001)(5660300002)(53546011)(6506007)(316002)(8676002)(40480700001)(31686004)(8936002)(26005)(6512007)(47076005)(186003)(478600001)(6486002)(356005)(110136005)(82310400005)(36860700001)(2906002)(43740500002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2023 11:11:55.5724 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c540dab6-4a19-440f-4c71-08db05d775d2 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: DBAEUR03FT037.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR08MB7554 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 03:47, Simon Marchi wrote: > > > On 2/1/23 21: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. > > Either way works. > >>>> 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. > > Err yeah, I meant the free function that returns the process' tdesc if > the thread doesn't have one. > >> 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. > > Ok. Would it work if a new thread initially inherited the tdesc from > its process? > It should be fine because the first time we fetch a process target description, it is eventually obtained from the first and only thread. So the SVE vector length should be correct. Any subsequent attempts to use the process' target description (the first one we obtained), after further stops, may end up using an incorrect description. I think this is handled correctly by the target architecture target hook though. But there are other places where this is potentially incorrect. For example... - When using gcore to dump a core file, GDB only dumps a single target description. While this might be correct for a target with a fixed target description or a AArch64 target that doesn't support SVE, it likely won't be correctly for one AArch64 target supporting SVE if its threads changed vector length mid-execution. Either we emit target description notes by thread, or we don't emit a target description note for those cases. - When loading the above/older gcore core files back, GDB will use a potentially incorrect target description. If we decide to emit per-thread target descriptions, it should be fine. Otherwise we may need to have a "thread architecture" hook for core files as well. - The remote has no concept of a thread architecture (Thiago is addressing this with this patch series). - AArch64 frames may have slightly different vg values, which means their gdbarches are different as well. Given the differences between two gdbarches are small, we mostly get away with it. But if there are further differences (different hooks, for example), I fear we may run into a situation where we use an incorrect gdbarch to call a particular hook. >>> 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. > > At least for the register description, if we decide it's now a > per-thread thing, what does it mean to have a process-wide description > anyway? I think it would make sense to get rid of it, that could help For AArch64 SVE, process-wide target descriptions mean it is the initial state. But it can't be trusted for further stops/events, in which case we need to trust the thread architecture hook. > confirm our model works (and it would remove the chance of using the > wrong tdesc by mistake for a thread that has its own tdesc). It's > probably something that can be done incrementally though. > > Simon