From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by sourceware.org (Postfix) with ESMTPS id 6194B3858C54 for ; Wed, 26 Apr 2023 06:36:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6194B3858C54 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1682490968; x=1714026968; h=from:to:subject:date:message-id:references:in-reply-to: mime-version:content-transfer-encoding; bh=XSdJoiDfPBwoUUVXQthOXmLSgqbchIJcKsJhshaMsDI=; b=h1G3U7c2hb3aqnon7VD5cWQ0IbYFqHPK7U6hkXUsmJSjiq4IxXaNO7MH S+Q0GFybyekB+nZSV0NbN285yIxUB0h/QBe0rLD7S4WsgELpVK2AfSba9 DnJFoPLu1jZDd0HOJOI43zw66572hfY3uvCtJ3HmBRahWv7mJ/rUkTU77 rMEsb79xvV1lRiDLDfP0/2FSAsQMee7kDnCsBBZsezrsb2WY2/+Bt23Hk Wr2zcwkT9FMz1zsnUFGuN87m1BmNzIYjaUAphktMRrIpQYU+GSsgg6aPq 8d5fV1locMVtXDv5gCNSo8vzOEYRfS0lCcXIH6rtzHiQ4Ff/dXtF0Iyy+ g==; X-IronPort-AV: E=McAfee;i="6600,9927,10691"; a="345770227" X-IronPort-AV: E=Sophos;i="5.99,227,1677571200"; d="scan'208";a="345770227" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Apr 2023 23:36:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10691"; a="696491269" X-IronPort-AV: E=Sophos;i="5.99,227,1677571200"; d="scan'208";a="696491269" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by fmsmga007.fm.intel.com with ESMTP; 25 Apr 2023 23:36:07 -0700 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Tue, 25 Apr 2023 23:36:06 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Tue, 25 Apr 2023 23:36:06 -0700 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23 via Frontend Transport; Tue, 25 Apr 2023 23:36:06 -0700 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (104.47.56.171) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.23; Tue, 25 Apr 2023 23:36:06 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nT4gwRlydfrmm+FZHdj7eqdfWCfZZEiyUsGSX6YDtQzMgWq8GIlduc4wLz9JmATH9ra6ZuAvqTCriTR93+gQr9tVsmvGZeYkTjkisIYdozHvU7IPSQdr++m3M2TUtLLXeW1TyAwm20uQPDV0iE0HOdvHlfV0zDmSIRKHkw2XHlfcp5qsaqaQlX4GFEUlt0PY2H0S5GCIICSefAA6zxcq9BPmX4RZS5ceT7Nw2f/px4sry40JyIBjgxtUORL2GioU7sf1kmkDe1xEHFlny9o+fISSpjqMaGixR4zHYsqTWNStVwhC1BsKfdP65de1qhkNr01YNkrkgDqSHnwft2EyLQ== 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=xW17Llgt5W6aolvVw39qbbbJixYMnwniPAY5m3pWZ2w=; b=Mj0liBiLWA/hPpxhYYDRbCaQmKFSDr3vdoP7tKhX2P1Sy3iwgTJdabzqg3qyFSVkLdQ9z/mEzNIbs/zCm6D9Zc0OXs0+TgTsff9VlgJgBzDbBn9YWwe5xtgwMCgHRYhLg/34uTNaM+iM2WMWj/WGHG9rP12Ve+U4EgxO/0Wyx9crJdrt9kdcMFUKGv9huzMFQnaqWnqAPnI+kqYpaxdIstL8w/vhiF9sYP/Lu+8PCCj54eL3weRhcdQ5KtT8Xjo5KuEcW+chtiib3/LClGuTO9mbWA4LepsigQEAFS+4iJoDhpcr7aQpOfPnjbwx+RIEVyi2XxjcPkl0gKrvZlUMnQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from DM4PR11MB7303.namprd11.prod.outlook.com (2603:10b6:8:108::21) by PH7PR11MB6857.namprd11.prod.outlook.com (2603:10b6:510:1ed::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Wed, 26 Apr 2023 06:35:59 +0000 Received: from DM4PR11MB7303.namprd11.prod.outlook.com ([fe80::830b:dc92:e628:ab8c]) by DM4PR11MB7303.namprd11.prod.outlook.com ([fe80::830b:dc92:e628:ab8c%2]) with mapi id 15.20.6340.021; Wed, 26 Apr 2023 06:35:58 +0000 From: "Aktemur, Tankut Baris" To: Andrew Burgess , Pedro Alves , "gdb-patches@sourceware.org" Subject: RE: [PATCH 2/2] gdbserver: track current process as well as current thread Thread-Topic: [PATCH 2/2] gdbserver: track current process as well as current thread Thread-Index: AQHZd33wCsp7lr1F7EiU08OZaT3L+q89H65Q Date: Wed, 26 Apr 2023 06:35:58 +0000 Message-ID: References: <20220419224739.3029868-1-pedro@palves.net> <20220419224739.3029868-3-pedro@palves.net> <87v8hkawun.fsf@redhat.com> In-Reply-To: <87v8hkawun.fsf@redhat.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: DM4PR11MB7303:EE_|PH7PR11MB6857:EE_ x-ms-office365-filtering-correlation-id: e3437eb8-8252-4981-8317-08db46207ebb x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: faSmiC+jSABi98oGejBDRYiNEtBvIuH1JvfKyA/6CxvPWXvoeJrObPgWg/xLz6GqJgDL+TmKWhBeIWLaft8OpOwyB/iQHeHP3xr+EftTq1ItD1wyLNBS5X11PbgTtcy7zXGqRip9QXKDoeU8GipwZa/wZTQ0tfuNj2FR8tSjfWHcTTdZ7wN4Fqjx9+vBVmfiDvU/O5qEG5g0326NmM7+3eJUKVXlR/FMykXaQdnrAkxqnobGoDAWBSW4mbgSADakQmUoidaGkLUB281xFeXXpCKkVJ9ae6+oHB2dC56ODiKIu8NWMdLcskTTjDJ2w6lSIIYfXz01F/dryO1mgV983HEMJ92ykypp3f9BKK+1DaBEYYNHMqLVyXyl7vNuftHWZmtcIlLkDdBcPxusP2R7hGKN03er21UvNO8WCmUsYdXYswE79/p8t8NZ2/CppimcGIMFhsQnByWQwEqosiE1+RuCa4KbL/jRj+SRCebqatRc3x7fcl5tAEXJRtl+COtySP6KkHjSpLhz7mNIKp+NGYBpg0O2aNhvxV/bPJUd/8SNKNt5CRtwxFwrZVb40Ry/xU527B3CoZahyHrizO5OvI6FLD1xmNIAVuPFIKND9B8= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM4PR11MB7303.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(346002)(376002)(136003)(39860400002)(396003)(366004)(451199021)(8676002)(66556008)(66446008)(66476007)(64756008)(8936002)(76116006)(38100700002)(122000001)(66946007)(478600001)(86362001)(84970400001)(2906002)(41300700001)(33656002)(316002)(52536014)(110136005)(5660300002)(71200400001)(7696005)(38070700005)(53546011)(9686003)(26005)(6506007)(186003)(82960400001)(55016003)(83380400001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?AiNj77TnbaJtuyK9WHMahO3ecUsDFJK1pJCDHBYjS+X5A9DUAwoIRudJetEk?= =?us-ascii?Q?qYC5sClRlAHWh11GlSJMl/0AzXDf9M+2xz4mDvVd9LpMxkPimDvzL/rdpo0O?= =?us-ascii?Q?dzlcu/cVK/woOuw66Fix4X9jtt40pw1TSeVf8/j44ksur1IUVv4gvDK1AZG1?= =?us-ascii?Q?2hPz6uK06IEGil1GVKDMeXiVud4OgjvjNw5t8J7jELXX+aIUiChyDZIOfKRr?= =?us-ascii?Q?/Bz1fuYSkg/1SWHMtw0nwrvh0MUiiCu7Mt28Oh+d8eEqk+q7Z1Lm/S+cdjgd?= =?us-ascii?Q?Dr+p3/BEEPstDyTwZpq6uB/pxBHtTepO4U0/sLXKRX2ZBbnhIfo3gqkYHuVz?= =?us-ascii?Q?9uDWAdAQdGrE+ewhyQ4KtAcdUKzLkrmEk8Fc8f47PcV/ScnBK1pF4kEr6bpW?= =?us-ascii?Q?/uqc8P1m42MT85HelsL3hHrvmyWmkbBPuyv29LHBZ0gZypk/xxi9jFF0Ex0j?= =?us-ascii?Q?oYIfHn8/nakOnXJ0TfJLip33g8Ta9dlhECmq1h70O9ratW01inhK1BxlCG7S?= =?us-ascii?Q?L/SSbHS7PlVSW2cPKWGkWVCBgjyK2tKx14czg/PujbzG8BPwXMf6z/w27Yb/?= =?us-ascii?Q?iXaFhrztAHFypTDH4nEqXO0KWRNvxMq5sb0gFVs/IOlCA2xWfg2AqMPuihk+?= =?us-ascii?Q?QYT5XFLU3GOHjsJ4cIyK+tn800uikVqUSs8CQ0pGQhBzW5PrJjhdSHoXhovd?= =?us-ascii?Q?45+m7bY5vf7eenbeupyjv8vs/Ajde6/bzE88A/N4RiQU4SJLOdArFbGfQTu6?= =?us-ascii?Q?K37FxtVMNM2TY4HvcaazyFhzJfY4ze3NfZXdI0L41mYw8NiOEke0dwQTptJb?= =?us-ascii?Q?VsqYBYoaGYUKvjP6AjmN9+8dFJC0MmXdbGe6mIZNhWTwl48nqn74zU/HHFJ8?= =?us-ascii?Q?nWaYRFNs8IKT58f51WieO31mCEeWfU3ehDCDSJpIkwgOgQEPa11Ou7up5MoB?= =?us-ascii?Q?cgKu2tXzXnB6H66Owv0Q8Y25APULxLBWzUuU+uxYUUp/Z7O9t517qqkkmwM1?= =?us-ascii?Q?qENdqd9VQ7JY8tJ8ZLueTkp5e4NfOQdPdAlttIEkR9n+TWZh6M3oIOewgvfQ?= =?us-ascii?Q?Xfwp1eCppOIYQVdWhQC5E5h+stWgMBtui5Uoc4g1rVYkw47HK+EFHEKPxX3w?= =?us-ascii?Q?SXaL5hCGau++UZcjYOjWE0p3ZOWzORDaS2qRH3OY57TW69nARsXnRI735Puw?= =?us-ascii?Q?VWhLJW308EBNb1bsaeChUB3DMY5rAPj4AxzJ9W+OGidqQ9Bevc2mKs8wpuOW?= =?us-ascii?Q?IbV7gC1erk+CyAuE7+UGnveZSY7sAJ82gLL02yLd6XwZUA2CWSEGl0QHX5hY?= =?us-ascii?Q?+ppgUoGvWRnHsYrQz46KWzfQ2pHGq2ZxKRHlcpEXu5Gj8vEclTatoWxV0u4j?= =?us-ascii?Q?+nLpDTDJ8H8cXUGssM0bno0E/0IKZs4a9W60/eZztE/YNuJz7ivdzwuEOYea?= =?us-ascii?Q?8Lb3ZSq9qukKYFYpoGz+crBMjkO5VEn/ZqSzMntJqe1ZjKYFThPsv/Wae8e3?= =?us-ascii?Q?r5iS2TDy24NTMafkiZeDCGWWWJdQDsfm0jn9kaPU4VZJMYTkZAYR0jGR9ZB1?= =?us-ascii?Q?dZe1JDLrVzzNVOnxFAFJRRdZdROSnGtwnot+JvJF9a4KpI4D/DbUyV6CEZpq?= =?us-ascii?Q?og=3D=3D?= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB7303.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: e3437eb8-8252-4981-8317-08db46207ebb X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Apr 2023 06:35:58.1837 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: WNDLPUMkn45bp1PtrcfuvL2xMss8wSZ5ZlnoeB5SVNB1nf41CfM1VtVKdfeHlIODH42tsFqLdBHCAx9OYpGLaoHK65wnOyGLQj9PwaRjfkU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR11MB6857 X-OriginatorOrg: intel.com Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE 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 Tuesday, April 25, 2023 3:57 PM, Andrew Burgess wrote: > Pedro Alves writes: > = > > The recent commit 421490af33bf ("gdbserver/linux: Access memory even > > if threads are running") caused a regression in > > gdb.threads/access-mem-running-thread-exit.exp with gdbserver, which I > > somehow missed. Like so: > > > > (gdb) print global_var > > Cannot access memory at address 0x555555558010 > > (gdb) FAIL: gdb.threads/access-mem-running-thread-exit.exp: non-stop: = access mem (print > global_var after writing, inf=3D2, iter=3D1) > > > > The problem starts with GDB telling GDBserver to select a thread, via > > the Hg packet, which GDBserver complies with, then that thread exits, > > and GDB, without knowing the thread is gone, tries to write to memory, > > through the context of the previously selected Hg thread. > > > > GDBserver's GDB-facing memory access routines, gdb_read_memory and > > gdb_write_memory, call set_desired_thread to make GDBserver re-select > > the thread that GDB has selected with the Hg packet. Since the thread > > is gone, set_desired_thread returns false, and the memory access > > fails. > > > > Now, to access memory, it doesn't really matter which thread is > > selected. All we should need is the target process. Even if the > > thread that GDB previously selected is gone, and GDB does not yet know > > about that exit, it shouldn't matter, GDBserver should still know > > which process that thread belonged to. > > > > Fix this by making GDBserver track the current process separately, > > like GDB also does. Add a new set_desired_process routine that is > > similar to set_desired_thread, but just sets the current process, > > leaving the current thread as NULL. Use it in the GDB-facing memory > > read and write routines, to avoid failing if the selected thread is > > gone, but the process is still around. > > > > Change-Id: I4ff97cb6f42558efbed224b30d5c71f6112d44cd > > --- > > gdbserver/gdbthread.h | 1 + > > gdbserver/inferiors.cc | 26 +++++++++++++++++++------ > > gdbserver/server.cc | 4 ++-- > > gdbserver/target.cc | 44 ++++++++++++++++++++++++++++++++++++++++-- > > gdbserver/target.h | 15 +++++++++++++- > > 5 files changed, 79 insertions(+), 11 deletions(-) > > > > diff --git a/gdbserver/gdbthread.h b/gdbserver/gdbthread.h > > index 10ae1cb7c87..8b897e73d33 100644 > > --- a/gdbserver/gdbthread.h > > +++ b/gdbserver/gdbthread.h > > @@ -252,6 +252,7 @@ class scoped_restore_current_thread > > > > private: > > bool m_dont_restore =3D false; > > + process_info *m_process; > > thread_info *m_thread; > > }; > > > > diff --git a/gdbserver/inferiors.cc b/gdbserver/inferiors.cc > > index 678d93c77a1..3d0a8b0e716 100644 > > --- a/gdbserver/inferiors.cc > > +++ b/gdbserver/inferiors.cc > > @@ -26,6 +26,11 @@ > > std::list all_processes; > > std::list all_threads; > > > > +/* The current process. */ > > +static process_info *current_process_; > > + > > +/* The current thread. This is either a thread of CURRENT_PROCESS, or > > + NULL. */ > > struct thread_info *current_thread; > > > > /* The current working directory used to start the inferior. > > @@ -130,6 +135,7 @@ clear_inferiors (void) > > clear_dlls (); > > > > switch_to_thread (nullptr); > > + current_process_ =3D nullptr; > > } > > > > struct process_info * > > @@ -153,6 +159,8 @@ remove_process (struct process_info *process) > > free_all_breakpoints (process); > > gdb_assert (find_thread_process (process) =3D=3D NULL); > > all_processes.remove (process); > > + if (current_process () =3D=3D process) > > + switch_to_process (nullptr); > > delete process; > > } > > > > @@ -205,8 +213,7 @@ get_thread_process (const struct thread_info *threa= d) > > struct process_info * > > current_process (void) > > { > > - gdb_assert (current_thread !=3D NULL); > > - return get_thread_process (current_thread); > > + return current_process_; > = > A bit late I know, but I wonder if the assert, or something similar, > should have been retained here? > = > The comment on this function currently (though Baris has a patch > proposed to change this), says this function should only be called in a > context where the result will not be nullptr. Given that, not of the > (many) existing uses check the return value of this function against > nullptr. > = > Happy to roll a patch to add the assert back, just wondered if there was > a reason for its removal. > = > Thanks, > Andrew Hi Andrew, I think the current process can in fact be null in some brief periods. For instance, in 'handle_detach' there is if (extended_protocol || target_running ()) { /* There is still at least one inferior remaining or we are in extended mode, so don't terminate gdbserver, and instead treat this like a normal program exit. */ cs.last_status.set_exited (0); cs.last_ptid =3D ptid_t (pid); switch_to_thread (nullptr); } So, if the current process exits, gdbserver reports the event to GDB and sets the current thread to nullptr, which also sets the current process to nullptr. I believe an invariant is this: (current_thread =3D=3D nullptr) || (current_process () =3D=3D get_thread_= process (current_thread)) Thanks -Baris > > } > > > > /* See gdbsupport/common-gdbthread.h. */ > > @@ -223,6 +230,10 @@ switch_to_thread (process_stratum_target *ops, pti= d_t ptid) > > void > > switch_to_thread (thread_info *thread) > > { > > + if (thread !=3D nullptr) > > + current_process_ =3D get_thread_process (thread); > > + else > > + current_process_ =3D nullptr; > > current_thread =3D thread; > > } > > > > @@ -231,9 +242,8 @@ switch_to_thread (thread_info *thread) > > void > > switch_to_process (process_info *proc) > > { > > - int pid =3D pid_of (proc); > > - > > - switch_to_thread (find_any_thread_of_pid (pid)); > > + current_process_ =3D proc; > > + current_thread =3D nullptr; > > } > > > > /* See gdbsupport/common-inferior.h. */ > > @@ -254,6 +264,7 @@ set_inferior_cwd (std::string cwd) > > > > scoped_restore_current_thread::scoped_restore_current_thread () > > { > > + m_process =3D current_process_; > > m_thread =3D current_thread; > > } > > > > @@ -262,5 +273,8 @@ scoped_restore_current_thread::~scoped_restore_curr= ent_thread () > > if (m_dont_restore) > > return; > > > > - switch_to_thread (m_thread); > > + if (m_thread !=3D nullptr) > > + switch_to_thread (m_thread); > > + else > > + switch_to_process (m_process); > > } > > diff --git a/gdbserver/server.cc b/gdbserver/server.cc > > index 33c42714e72..f9c02a9c6da 100644 > > --- a/gdbserver/server.cc > > +++ b/gdbserver/server.cc > > @@ -1067,7 +1067,7 @@ gdb_read_memory (CORE_ADDR memaddr, unsigned char= *myaddr, int len) > > /* (assume no half-trace half-real blocks for now) */ > > } > > > > - if (set_desired_thread ()) > > + if (set_desired_process ()) > > res =3D read_inferior_memory (memaddr, myaddr, len); > > else > > res =3D 1; > > @@ -1088,7 +1088,7 @@ gdb_write_memory (CORE_ADDR memaddr, const unsign= ed char *myaddr, > int len) > > { > > int ret; > > > > - if (set_desired_thread ()) > > + if (set_desired_process ()) > > ret =3D target_write_memory (memaddr, myaddr, len); > > else > > ret =3D EIO; > > diff --git a/gdbserver/target.cc b/gdbserver/target.cc > > index 883242377c0..adcfe6e7bcc 100644 > > --- a/gdbserver/target.cc > > +++ b/gdbserver/target.cc > > @@ -29,16 +29,56 @@ > > > > process_stratum_target *the_target; > > > > -int > > +/* See target.h. */ > > + > > +bool > > set_desired_thread () > > { > > client_state &cs =3D get_client_state (); > > thread_info *found =3D find_thread_ptid (cs.general_thread); > > > > - switch_to_thread (found); > > + if (found =3D=3D nullptr) > > + { > > + process_info *proc =3D find_process_pid (cs.general_thread.pid (= )); > > + if (proc =3D=3D nullptr) > > + { > > + threads_debug_printf > > + ("did not find thread nor process for general_thread %s", > > + cs.general_thread.to_string ().c_str ()); > > + } > > + else > > + { > > + threads_debug_printf > > + ("did not find thread for general_thread %s, but found process", > > + cs.general_thread.to_string ().c_str ()); > > + } > > + switch_to_process (proc); > > + } > > + else > > + switch_to_thread (found); > > + > > return (current_thread !=3D NULL); > > } > > > > +/* See target.h. */ > > + > > +bool > > +set_desired_process () > > +{ > > + client_state &cs =3D get_client_state (); > > + > > + process_info *proc =3D find_process_pid (cs.general_thread.pid ()); > > + if (proc =3D=3D nullptr) > > + { > > + threads_debug_printf > > + ("did not find process for general_thread %s", > > + cs.general_thread.to_string ().c_str ()); > > + } > > + switch_to_process (proc); > > + > > + return proc !=3D nullptr; > > +} > > + > > int > > read_inferior_memory (CORE_ADDR memaddr, unsigned char *myaddr, int le= n) > > { > > diff --git a/gdbserver/target.h b/gdbserver/target.h > > index f3172e2ed7e..6c536a30778 100644 > > --- a/gdbserver/target.h > > +++ b/gdbserver/target.h > > @@ -699,7 +699,20 @@ target_thread_pending_child (thread_info *thread) > > > > int read_inferior_memory (CORE_ADDR memaddr, unsigned char *myaddr, in= t len); > > > > -int set_desired_thread (); > > +/* Set GDBserver's current thread to the thread the client requested > > + via Hg. Also switches the current process to the requested > > + process. If the requested thread is not found in the thread list, > > + then the current thread is set to NULL. Likewise, if the requested > > + process is not found in the process list, then the current process > > + is set to NULL. Returns true if the requested thread was found, > > + false otherwise. */ > > + > > +bool set_desired_thread (); > > + > > +/* Set GDBserver's current process to the process the client requested > > + via Hg. The current thread is set to NULL. */ > > + > > +bool set_desired_process (); > > > > std::string target_pid_to_str (ptid_t); > > > > -- > > 2.26.2 Intel Deutschland GmbH Registered Address: Am Campeon 10, 85579 Neubiberg, Germany Tel: +49 89 99 8853-0, www.intel.de Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva = Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich Commercial Register: Amtsgericht Muenchen HRB 186928