Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: Thiago Jung Bauermann <thiago.bauermann@linaro.org>,
	Markus Metzger <markus.t.metzger@intel.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 1/2] gdbserver, read_ptid: handle '0' and '-1' thread ids
Date: Thu, 14 Aug 2025 16:40:20 -0400	[thread overview]
Message-ID: <4bc68b3a-d8a5-45b1-aa94-0b6af488d8bc@simark.ca> (raw)
In-Reply-To: <87wm76zi98.fsf@linaro.org>

On 8/13/25 11:36 PM, Thiago Jung Bauermann wrote:
> Hello Markus,
> 
> Markus Metzger <markus.t.metzger@intel.com> writes:
> 
>> The special thread id '-1' means 'all threads'.
>> The special thread id '0' means 'any thread'.
>>
>> Read_ptid () currently returns
>>
>>     <current pid>.-1.0
>>
>> and
>>
>>     <current pid>.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  <thiago.bauermann@linaro.org>
>> ---
>>  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

  reply	other threads:[~2025-08-14 20:40 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-05  7:19 Markus Metzger
2025-08-05  7:19 ` [PATCH 2/2] gdb, remote: fix set_thread () in start_remote () Markus Metzger
2025-08-14  4:29   ` Thiago Jung Bauermann
2025-08-14 22:28     ` Simon Marchi
2025-08-15  0:29       ` Thiago Jung Bauermann
2025-08-15  5:33         ` Simon Marchi
2025-08-18  1:43           ` Thiago Jung Bauermann
2025-09-22 13:29       ` Metzger, Markus T
2025-08-14  3:36 ` [PATCH 1/2] gdbserver, read_ptid: handle '0' and '-1' thread ids Thiago Jung Bauermann
2025-08-14 20:40   ` Simon Marchi [this message]
2025-09-22 13:29     ` Metzger, Markus T
2025-09-23 18:26       ` Tom Tromey
2025-09-24  8:04         ` Metzger, Markus T
2025-09-26  6:43           ` Metzger, Markus T

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4bc68b3a-d8a5-45b1-aa94-0b6af488d8bc@simark.ca \
    --to=simark@simark.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=markus.t.metzger@intel.com \
    --cc=thiago.bauermann@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox