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: Thu, 14 Aug 2025 21:29:03 -0300 [thread overview]
Message-ID: <877bz5zauo.fsf@linaro.org> (raw)
In-Reply-To: <dd3eea0e-d083-4af8-8185-87c61632224d@simark.ca> (Simon Marchi's message of "Thu, 14 Aug 2025 18:28:12 -0400")
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?
--
Thiago
next prev parent reply other threads:[~2025-08-15 0:30 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 [this message]
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
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=877bz5zauo.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