From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2088.outbound.protection.outlook.com [40.107.20.88]) by sourceware.org (Postfix) with ESMTPS id CA54F3858CDA for ; Wed, 1 Feb 2023 09:05:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CA54F3858CDA 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=0vHb1TE1trh2J6iUQzugeTqliZvddZ42hm7aLmYv0/Q=; b=YBAl+JL6KSX9dXplP2EZuvn2BzlxCyYdFNXJrjwaMnMf2dC+Qcxptk2oaOPJuNc0XXKmqLnBR6WcsypIPWdCIaAMJT0gjxeMZ0MuUQ8n2bugGwa9uQ2InuOmD0h+ALQiI52VzUpLJ+SHE8MEI5BA3FB9jJEdqb2Op05GzsfEV7g= Received: from DUZPR01CA0043.eurprd01.prod.exchangelabs.com (2603:10a6:10:468::6) by AM7PR08MB5527.eurprd08.prod.outlook.com (2603:10a6:20b:de::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.33; Wed, 1 Feb 2023 09:05:25 +0000 Received: from DBAEUR03FT008.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:468:cafe::47) by DUZPR01CA0043.outlook.office365.com (2603:10a6:10:468::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38 via Frontend Transport; Wed, 1 Feb 2023 09:05:25 +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 DBAEUR03FT008.mail.protection.outlook.com (100.127.142.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.25 via Frontend Transport; Wed, 1 Feb 2023 09:05:25 +0000 Received: ("Tessian outbound 3ad958cd7492:v132"); Wed, 01 Feb 2023 09:05:25 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 82e72727b0d3db85 X-CR-MTA-TID: 64aa7808 Received: from 974bd10b0dab.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 3230B6BB-02B8-414B-A833-ACC44673AB4F.1; Wed, 01 Feb 2023 09:05:18 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 974bd10b0dab.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 01 Feb 2023 09:05:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kRH2GP5Ne093rRGy+ZEsaN3/lRJUz821S70WmdcB+oxRvmVhr3NCfd2XTJGOfAAY9UQ5/n94Zw1h5WaQllDy1pRva7uGg/sSHfHQye9bZmxzcOjzTf8xvrvhleFDvh02lGINRejvXhmouJWxg38Q8w3VUiF/K9dT1kX3SgfCxZpDKd3lE0QCipKwwiMPXK4z8TJClJ/yzT+0CROiS79Z+m4aj+MNbNuoToboJbhzlaaNQ6vFkFxtV3boyNpRyqxqeBSQiZFPEa/j/bg/wd7ZS1Z4RYtV7EIEceiDApCwxaKYiV8j8QhKHMZkFEB/Jn2uNVNueWslDpkPH9/ut/0tbA== 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=0vHb1TE1trh2J6iUQzugeTqliZvddZ42hm7aLmYv0/Q=; b=mBtqhmmkFURfzbuBCx6yaCtFnTtbr/uO4mAi0WBC3yxbfSJ2OWqxe1Pm6JzNIxkHqLMXQtCK6mq8AyKf0Fpa1Xoir1Xvw/xIJRXT99VzD0TWI7mAhgiC+vdiE96C/t4djuWPus6Kci5c9cS3XtT94jN6sZEM5iCujxC6p1A2Xp6aRA1kQCRcLdmlI4TGr7Zm0zFhkzAmXYYgmAwE09BSFT9m5a7eBajUK09EztAwduGbk6pNezx5G/eGUZSFsi5gZp6MwDt6EQsMSqRQ5Ruix2CYIK9BOlqCq9X+66xz5JpN0+Lc1VL9ue63uy+s2pgb3TR/vVw1jT7pMrGLiAaXlg== 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=0vHb1TE1trh2J6iUQzugeTqliZvddZ42hm7aLmYv0/Q=; b=YBAl+JL6KSX9dXplP2EZuvn2BzlxCyYdFNXJrjwaMnMf2dC+Qcxptk2oaOPJuNc0XXKmqLnBR6WcsypIPWdCIaAMJT0gjxeMZ0MuUQ8n2bugGwa9uQ2InuOmD0h+ALQiI52VzUpLJ+SHE8MEI5BA3FB9jJEdqb2Op05GzsfEV7g= 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 AS8PR08MB6214.eurprd08.prod.outlook.com (2603:10a6:20b:29f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.22; Wed, 1 Feb 2023 09:05:15 +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.6043.036; Wed, 1 Feb 2023 09:05:14 +0000 Message-ID: Date: Wed, 1 Feb 2023 09:05:06 +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: Thiago Jung Bauermann , gdb-patches@sourceware.org References: <20230130044518.3322695-1-thiago.bauermann@linaro.org> <20230130044518.3322695-5-thiago.bauermann@linaro.org> From: Luis Machado In-Reply-To: <20230130044518.3322695-5-thiago.bauermann@linaro.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: SN7PR04CA0024.namprd04.prod.outlook.com (2603:10b6:806:f2::29) To VI1PR08MB3919.eurprd08.prod.outlook.com (2603:10a6:803:c4::31) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: VI1PR08MB3919:EE_|AS8PR08MB6214:EE_|DBAEUR03FT008:EE_|AM7PR08MB5527:EE_ X-MS-Office365-Filtering-Correlation-Id: a66db82b-f669-4529-553a-08db043374ed 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: gCdkJp59pDF01qGhjWtqGVM5ZMz9Uj1bVM5WBbz2ntT7HkoYNpmXsmnnDryyKTdFqotfpJe+2BpQu1YdNRP3B/4p2SL3UhK6mwzH4kdJH4ZcCYOVRmON9E7HD8GQ3WhpnGtzWtv4TC1ODnDjMNehwZ9MdhxHltmd+6mJaBVFQwyKqWnjUE85abug7gi/KsuKWUNcxTdX9iEnUmYVwlMR2/kfJyMEnc/E06z705xiE+DLrf9tov++27OL5tu55oj2H8ldKayh4CP+BPzrHqi7VTaugqLCCqZv8qR2obsKZcqBTo2uXSdC/NltciQQuK/ahGf1urzx/PAaLNH7UoXSEpTXEPBcuccJwhPjfFLtMUvOQ0yopt3qSpH7JUukPJsVb86Bh14qBNWo6XfqvWcHCRV4/MasFnhadHBSu6+a7BferD0bM1a6TGdUfh7uF2PJjqDgcbexEbiJJKZF2aLNxt23u2WIhsWtBlwwzSV1rjlEuTHj7qDEvLGmljkvnlshP6lSnWkicrBgIHmljO8wNsWg6j/WjsCGWFdlSbv8tmmx85BWFMg4nGc/XuextOMJ7fio5txAuUryBVlK7RzDJ34nA1B8SlA1ZUyycPTaDnm3ZZcPv4QGS11J9RakD5lj20aTFSllgyPSeH7SbcVH/i1dlLsVudiF0JDS1RtGgfWlodQqxCukgfTyH2K6ZQFt6G17e7I8d3t6I2BAfvJ8c/BkqPq5jmwL5zCXkwHz1+U= 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)(136003)(376002)(396003)(366004)(39860400002)(451199018)(86362001)(36756003)(31696002)(38100700002)(66946007)(66476007)(66556008)(41300700001)(8936002)(8676002)(316002)(44832011)(2906002)(83380400001)(2616005)(478600001)(5660300002)(6486002)(186003)(26005)(53546011)(6512007)(6506007)(6666004)(31686004)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6214 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: DBAEUR03FT008.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 4c742ccd-f9f3-4f76-22cd-08db04336e0b X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3DPiB5g1jfigJ56FzbeQroUnV9eTZDlBXXAA3H0yTb41ZyoJVEXBpnepPpwsAVQdgsBQDfmoMjf4kEtGOKwVPIoHH2GlTkyGHGgOwBMyAxx35S/XvREetg7deYCfELr7/KGj4E7zTaqTNy54FYAWBdck71dEqfA7UlTaz3GzJkZcmDgUW9IuneiX4VcMkIONpBgzI4zFjnCvZbUZHACK/e7JQaYZDRrZ0Oiuykg9A4shGhccssM5jICaYd57razOLKBdKSUgncJNpXkdCnVLKkLUz84IVzo2l1ZWyzCknC3WShdStiDbUkyM1uYHFoSMA/nyVE6y9RI4LdkYqRv3QwBz3GdLTlySyxSOg9+jxA5Gnrbvgflxr22dNfwPEBAXRTW7S2/Y62MlkuDKJsfEMcI9RaxQlD72akgkfrCCRiNrliPJA76Yn5VHItC2sMr45mE/LQVxYxIsat5bBkRaYwB5yjwZYNg7xvOXpj7lBWrjfoKfadYikJ1P5TjLkJ7PXSF5wgh2ol5UbRO9kSVGIPq7MOBpdvpRaIOOKDh+a0QvVrF1F/uxAYhvPA/rpX5QTRmmun7Eh8PaDCycuVE7oyy7zj+Oonwhqm/4MhGruJePAEF/bx9Yrcg0ik5hP2RCmiXz3LzCN//AEIJsnyBS5XsbVyy7Nmg8bHJU1kz8sf2u5JdV9r4NbU53/+acSqiCo7Loo4e26D0wvlpZR3ejy64Y3HjzWKIfWtWhBItSrlY= 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)(396003)(136003)(39860400002)(346002)(376002)(451199018)(36840700001)(40470700004)(46966006)(83380400001)(36756003)(81166007)(86362001)(31696002)(40460700003)(36860700001)(82740400003)(40480700001)(82310400005)(31686004)(44832011)(5660300002)(356005)(2906002)(8676002)(8936002)(70206006)(316002)(70586007)(41300700001)(26005)(6512007)(186003)(2616005)(336012)(47076005)(478600001)(6486002)(6506007)(6666004)(53546011)(43740500002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Feb 2023 09:05:25.4455 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a66db82b-f669-4529-553a-08db043374ed 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: DBAEUR03FT008.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5527 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 1/30/23 04:45, Thiago Jung Bauermann wrote: > This change prepares gdbserver to support remotely debugging programs in > aarch64-linux where different threads have different SVE vector lengths. > It allows gdbserver to support different inferior threads having different > target descriptions. > > To that end, a tdesc field is added to struct thread_info. If it's > nullptr (the default) it means that the thread uses the target description > stored in struct process_info and thus gdbserver behaviour is unchanged. > The get_thread_tdesc method is added to the linux_process_target class to > allow aarch64-linux code to probe the inferior's vq register and provide a > thread-specific target description reflecting the new vector length. > > After this change, all targets except SVE-supporting aarch64-linux will > still use per-process target descriptions. > > Reviewed-by: Luis Machado > --- > gdbserver/gdbthread.h | 4 ++++ > gdbserver/linux-aarch64-low.cc | 31 +++++++++++++++++++++++++++++++ > gdbserver/linux-low.cc | 17 +++++++++++++++++ > gdbserver/linux-low.h | 6 ++++++ > gdbserver/regcache.cc | 10 ++++++---- > gdbserver/regcache.h | 4 ++++ > gdbserver/tdesc.cc | 13 ++++++++++++- > gdbserver/tdesc.h | 5 +++++ > 8 files changed, 85 insertions(+), 5 deletions(-) > > diff --git a/gdbserver/gdbthread.h b/gdbserver/gdbthread.h > index 493e1dbf6cb6..5b5ba6f8e521 100644 > --- a/gdbserver/gdbthread.h > +++ b/gdbserver/gdbthread.h > @@ -80,6 +80,10 @@ struct thread_info > > /* Branch trace target information for this thread. */ > struct btrace_target_info *btrace = nullptr; > + > + /* Target description for this thread. Only present if it's different > + from the one in process_info. */ > + const struct target_desc *tdesc = nullptr; > }; > > extern std::list all_threads; > diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc > index 92c621e5548c..69765ee90db3 100644 > --- a/gdbserver/linux-aarch64-low.cc > +++ b/gdbserver/linux-aarch64-low.cc > @@ -99,6 +99,9 @@ protected: > > void low_arch_setup () override; > > + const struct target_desc * > + get_thread_tdesc (const thread_info *thread) override; > + > bool low_cannot_fetch_register (int regno) override; > > bool low_cannot_store_register (int regno) override; > @@ -184,6 +187,9 @@ struct arch_process_info > same for each thread, it is reasonable for the data to live here. > */ > struct aarch64_debug_reg_state debug_reg_state; > + > + /* Whether this process has the Scalable Vector Extension available. */ > + bool has_sve; > }; > > /* Return true if the size of register 0 is 8 byte. */ > @@ -869,6 +875,9 @@ aarch64_target::low_arch_setup () > > current_process ()->tdesc = aarch64_linux_read_description (features); > > + if (features.vq > 0) > + current_process ()->priv->arch_private->has_sve = true; > + > /* Adjust the register sets we should use for this particular set of > features. */ > aarch64_adjust_register_sets (features); > @@ -879,6 +888,28 @@ aarch64_target::low_arch_setup () > aarch64_linux_get_debug_reg_capacity (lwpid_of (current_thread)); > } > > +/* Implementation of linux target ops method "get_thread_tdesc". */ > + > +const struct target_desc * > +aarch64_target::get_thread_tdesc (const thread_info *thread) > +{ > + const struct process_info *process = get_thread_process (thread); > + > + /* Only inferiors with SVE need a thread-specific target description. */ > + if (!process->priv->arch_private->has_sve) > + return nullptr; > + > + const struct aarch64_features features = aarch64_get_arch_features (thread); > + const struct target_desc *tdesc = aarch64_linux_read_description (features); > + > + /* If the target description we just found is the same as the process-wide > + one, there's no need to set a thread-specific one. */ > + if (tdesc == process->tdesc) > + return nullptr; > + > + return tdesc; > +} > + > /* Implementation of linux target ops method "get_regs_info". */ > > const regs_info * > diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc > index 5cd22824e470..47916009ebaf 100644 > --- a/gdbserver/linux-low.cc > +++ b/gdbserver/linux-low.cc > @@ -483,6 +483,12 @@ linux_process_target::arch_setup_thread (thread_info *thread) > low_arch_setup (); > } > > +const struct target_desc * > +linux_process_target::get_thread_tdesc (const thread_info *thread) > +{ > + return nullptr; > +} > + > int > linux_process_target::handle_extended_wait (lwp_info **orig_event_lwp, > int wstat) > @@ -2348,6 +2354,17 @@ linux_process_target::filter_event (int lwpid, int wstat) > return; > } > } > + else > + { > + /* Give the arch code an opportunity to set the thread's target > + description. */ > + const struct target_desc *new_tdesc = get_thread_tdesc (thread); > + if (new_tdesc != thread->tdesc) > + { > + free_register_cache_thread (thread); > + thread->tdesc = new_tdesc; > + } > + } > } > > if (WIFSTOPPED (wstat) && child->must_set_ptrace_flags) > 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); > + > /* Return false if we can fetch/store the register, true if we cannot > fetch/store the register. */ > virtual bool low_cannot_fetch_register (int regno) = 0; > diff --git a/gdbserver/regcache.cc b/gdbserver/regcache.cc > index 7b896a19767d..fb60e2c9c399 100644 > --- a/gdbserver/regcache.cc > +++ b/gdbserver/regcache.cc > @@ -39,11 +39,11 @@ get_thread_regcache (struct thread_info *thread, int fetch) > have. */ > if (regcache == NULL) > { > - struct process_info *proc = get_thread_process (thread); > + const target_desc *tdesc = get_thread_target_desc (thread); > > - gdb_assert (proc->tdesc != NULL); > + gdb_assert (tdesc != nullptr); > > - regcache = new_register_cache (proc->tdesc); > + regcache = new_register_cache (tdesc); > set_thread_regcache_data (thread, regcache); > } > > @@ -270,7 +270,9 @@ find_regno (const struct target_desc *tdesc, const char *name) > internal_error ("Unknown register %s requested", name); > } > > -static void > +/* See regcache.h. */ > + > +void > free_register_cache_thread (struct thread_info *thread) > { > struct regcache *regcache = thread_regcache_data (thread); > diff --git a/gdbserver/regcache.h b/gdbserver/regcache.h > index 7248bcf5808a..4beea0139cd6 100644 > --- a/gdbserver/regcache.h > +++ b/gdbserver/regcache.h > @@ -79,6 +79,10 @@ void free_register_cache (struct regcache *regcache); > > void regcache_invalidate_thread (struct thread_info *); > > +/* Invalidate and release the register cache of the given THREAD. */ > + > +void free_register_cache_thread (struct thread_info *thread); > + > /* Invalidate cached registers for all threads of the given process. */ > > void regcache_invalidate_pid (int pid); > diff --git a/gdbserver/tdesc.cc b/gdbserver/tdesc.cc > index 2c7257c458f4..e3339dde4d6c 100644 > --- a/gdbserver/tdesc.cc > +++ b/gdbserver/tdesc.cc > @@ -123,13 +123,24 @@ copy_target_description (struct target_desc *dest, > dest->xmltarget = src->xmltarget; > } > > +/* See tdesc.h. */ > + > +const struct target_desc * > +get_thread_target_desc (const struct thread_info *thread) > +{ > + if (thread->tdesc != nullptr) > + return thread->tdesc; > + > + return get_thread_process (thread)->tdesc; > +} > + > const struct target_desc * > current_target_desc (void) > { > if (current_thread == NULL) > return &default_description; > > - return current_process ()->tdesc; > + return get_thread_target_desc (current_thread); > } > > /* An empty structure. */ > diff --git a/gdbserver/tdesc.h b/gdbserver/tdesc.h > index 7fe7d0d8eb30..71cc5b51c84e 100644 > --- a/gdbserver/tdesc.h > +++ b/gdbserver/tdesc.h > @@ -88,6 +88,11 @@ void copy_target_description (struct target_desc *dest, > void init_target_desc (struct target_desc *tdesc, > const char **expedite_regs); > > +/* Return the target description corresponding to the given THREAD. */ > + > +const struct target_desc * > + get_thread_target_desc (const struct thread_info *thread); > + > /* Return the current inferior's target description. Never returns > NULL. */ > I don't have any comments on this code. It looks good to me.