Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
To: Simon Marchi <simark@simark.ca>
Cc: Markus Metzger <markus.t.metzger@intel.com>,  gdb-patches@sourceware.org
Subject: Re: [PATCH 2/2] gdb, remote: fix set_thread () in start_remote ()
Date: Sun, 17 Aug 2025 22:43:01 -0300	[thread overview]
Message-ID: <87a53xe76i.fsf@linaro.org> (raw)
In-Reply-To: <d674ad43-1dda-41b9-86e8-bcad42664fd8@simark.ca> (Simon Marchi's message of "Fri, 15 Aug 2025 01:33:31 -0400")

Simon Marchi <simark@simark.ca> writes:

> On 2025-08-14 20:29, Thiago Jung Bauermann wrote:
>> Simon Marchi <simark@simark.ca> writes:
>> 
>>> On 8/14/25 12:29 AM, Thiago Jung Bauermann wrote:
>>>> Markus Metzger <markus.t.metzger@intel.com> writes:
>>>>> -      set_continue_thread (minus_one_ptid);
>>>>> +      set_general_thread (any_thread_ptid);
>>>>>  
>>>>>        if (thread_count (this) == 0)
>>>>>  	{
>>>>
>>>> Also, your explanation implies that the doc comment in
>>>> remote_target::set_thread isn't quite right. What about changing it to
>>>> something along the following lines?
>>>>
>>>> -/* If PTID is MAGIC_NULL_PTID, don't set any thread.  If PTID is
>>>> -   MINUS_ONE_PTID, set the thread to -1, so the stub returns the
>>>> -   thread.  If GEN is set, set the general thread, if not, then set
>>>> -   the step/continue thread.  */
>>>> +/* If PTID is MAGIC_NULL_PTID or ANY_THREAD_PTID, set the thread to 0.
>>>> +   If PTID is MINUS_ONE_PTID, set the thread to -1.  If GEN is set, set
>>>> +   the general thread, if not, then set the step/continue thread.  If
>>>> +   the thread is 0 or -1 and GEN is set, the stub returns the thread in
>>>> +   the qC packet reply.  */
>>>
>>> The parts "set the thread to 0" and "set the thread to -1" seem not very
>>> useful to me.  What does that mean concretely?  It would be more useful
>>> to explain what that instruct the remote target to do.
>>>
>>> My understanding is that passing either MAGIC_NULL_PTID or
>>> ANY_THREAD_PTID will result in sending `Hg0` or `Hc0`.  Passing
>>> MINUS_ONE_PTID will result in sending `Hg-1` or `Hc-1`.
>>>
>>> On the other side, all of these will result in variable THREAD_ID being
>>> set to null_ptid.  For Hg, we'll arbitrarily pick the first thread.  For
>>> Hc, we'll set cs.cont_thread to null_ptid.
>>>
>>> Does that sound right?
>> 
>> For gdbserver, yes. My main doubt is whether we can assume other stubs
>> "out there" behave the same way or do they treat Hg0 and Hg-1
>> differently? The comment and code in remote_target::set_thread assume
>> the latter, so is that a bug?
>
> About the other stubs: I can't really help you there, I think the answer
> is that we'll never really know.
>
> Can you clarify what you think might be a bug?

I'm a bit concerned that GDB's remote_target::set_thread considers Hg-1
and Hg0 to be different things (doesn't say how they are different
though) while gdbserver's process_serial_event handling of the H packet
treats them as synonyms. I think that's strange, and was wondering if
anyone knew why. Maybe they just diverged without any practical
consequence and we can just bring them back to sync. Or maybe gdbserver
changed its behaviour but there are stubs out there that didn't.

This patches changes GDB from sending Hc-1 to Hg0. For gdbserver, the
change from -1 to 0 is meaningless. My question is whether we can assume
it will be meaningless to other stubs as well. But I agree that we'll
never really know, and if we just keep all the RSP warts forever it will
be hard to maintain and evolve it.

All this was just a long way of saying that I wanted to add my
Reviewed-by to this patch but I don't feel confident enough to do it.

-- 
Thiago

  reply	other threads:[~2025-08-18  1:43 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-05  7:19 [PATCH 1/2] gdbserver, read_ptid: handle '0' and '-1' thread ids 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 [this message]
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
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=87a53xe76i.fsf@linaro.org \
    --to=thiago.bauermann@linaro.org \
    --cc=gdb-patches@sourceware.org \
    --cc=markus.t.metzger@intel.com \
    --cc=simark@simark.ca \
    /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