From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id JTLZLdtJnmjJkQMAWB0awg (envelope-from ) for ; Thu, 14 Aug 2025 16:40:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1755204059; bh=oD4LkDT+BdUiz78kNwJRyRdZGQDJcBeWh51Mcq0FoNE=; h=Date:Subject:To:Cc:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=uyPpZviqS36XnSihjWefaG0DsYEQJEzaXnUPoK0PDPrxt8Cggv9yR0k3VxGuW7Yrg ziIaFnYAZ/rnBRUa/G6UI6YgPSk8mHUIL/04DuJdoxIOCwoaN/NduVwTVt0/kFlYUE 1XwqLO/O+M05kqpqWvWvKMA9HtSacsAI53IHGNao= Received: by simark.ca (Postfix, from userid 112) id A2AD61E0B3; Thu, 14 Aug 2025 16:40:59 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=HneAcjnk; dkim-atps=neutral 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 CD5951E08D for ; Thu, 14 Aug 2025 16:40:58 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 699D13858C53 for ; Thu, 14 Aug 2025 20:40:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 699D13858C53 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=HneAcjnk Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 53FBA3858D20 for ; Thu, 14 Aug 2025 20:40:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 53FBA3858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 53FBA3858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1755204021; cv=none; b=Ooz40HxIDkySIGscinz7++o7ch8aQnm/ZmQZGq+pwQj0pB+DLna0iDq6T/cXmPqBl1LslvCu3BErs2d+Z7/lr9lSwVOvzDDKpqPA7TH9fpsIpX5YoFHsRpx1RgydMW6/jBrCoI76lOMuvHaO8DBJs1nspUvI61ymqSBGU5BhGqE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1755204021; c=relaxed/simple; bh=oD4LkDT+BdUiz78kNwJRyRdZGQDJcBeWh51Mcq0FoNE=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=jwS0x0UMM9bfg4to3sufaCjtMnDSItg05We410PQupNVGV/dqZLISyWpm2k+E4G1xNsZmstGiS8Q9BV05s9OLwJWFUYnMxXmUQUYwyFVS+xhJ9aFd2pQDvV8PiUMBmbyx8SyBOrlkYSerNfEZmdNNmSWVTq1ZMvUAslUhDalX3g= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 53FBA3858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1755204020; bh=oD4LkDT+BdUiz78kNwJRyRdZGQDJcBeWh51Mcq0FoNE=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=HneAcjnkn8Dse8cFW9eAMiVjStFTjUkDrmaPRHIw0mAKWmiQ+euDjNnpsmQ40MZjh 5S/ke7+3e4QQCDiUI613pCq4OUE4AO+sLK4WXWJKe3u85fCAR2d9WMMN5EE4n2uaOB i8JPSiL1Rh8C75JjL/VoIj/HXWFzTQGEHxyhJjXk= Received: by simark.ca (Postfix) id E04751E08D; Thu, 14 Aug 2025 16:40:20 -0400 (EDT) Message-ID: <4bc68b3a-d8a5-45b1-aa94-0b6af488d8bc@simark.ca> Date: Thu, 14 Aug 2025 16:40:20 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/2] gdbserver, read_ptid: handle '0' and '-1' thread ids To: Thiago Jung Bauermann , Markus Metzger Cc: gdb-patches@sourceware.org References: <20250805071914.3832823-1-markus.t.metzger@intel.com> <87wm76zi98.fsf@linaro.org> Content-Language: fr From: Simon Marchi In-Reply-To: <87wm76zi98.fsf@linaro.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org On 8/13/25 11:36 PM, Thiago Jung Bauermann wrote: > Hello Markus, > > Markus Metzger writes: > >> The special thread id '-1' means 'all threads'. >> The special thread id '0' means 'any thread'. >> >> Read_ptid () currently returns >> >> .-1.0 >> >> and >> >> .0.0 >> >> respectively. >> >> Change that to minus_one_ptid for '-1' and to null_ptid for '0'. I can see that there are read_ptid functions both on GDB and GDBserver-side. We can see that they are similar, but they have diverged a bit (and they will diverge even more with this patch). IWBN if possible to have just one shared implementation. One part that differs between the implementations is where we get the default pid value. That value would have to be passed in as a parameter. The nice side-effect of that is that it make it easy to unit test this function, which we don't do right now. >> >> CC: Thiago Jung Bauermann >> --- >> gdbserver/remote-utils.cc | 20 ++++++++++++++++++++ >> 1 file changed, 20 insertions(+) > > Nice improvement. Just a minor comment. > >> diff --git a/gdbserver/remote-utils.cc b/gdbserver/remote-utils.cc >> index 15f073dd6be..9562cc2e1fb 100644 >> --- a/gdbserver/remote-utils.cc >> +++ b/gdbserver/remote-utils.cc >> @@ -566,6 +566,26 @@ read_ptid (const char *buf, const char **obuf) >> const char *p = buf; >> const char *pp; >> >> + /* Handle special thread ids. */ >> + if (*p == '0') > > I think this should also check the character after '0': Agreed. I think it would be valid to pass `0A`, to represent tid 10. Can we instead let the code go through hex_or_minus_one below and handle "tid == 0" there? Simon