Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@polymtl.ca>
To: Pedro Alves <pedro@palves.net>, gdb-patches@sourceware.org
Subject: Re: [PATCH] gdbserver/linux-low: carry over stop_expected flag after exec (avoid spurious SIGSTOPs)
Date: Fri, 26 Jun 2026 14:06:25 -0400	[thread overview]
Message-ID: <c7d1af4f-c340-4e6d-ae37-e4e863664914@polymtl.ca> (raw)
In-Reply-To: <d3a53ae6-a9bd-4732-9a3e-3c9701603c6f@palves.net>



On 2026-06-26 14:04, Pedro Alves wrote:
> On 2026-06-26 19:00, Simon Marchi wrote:
>> On 2026-06-26 13:35, Pedro Alves wrote:
>>>> +      unsigned long execing_tid = event_ptid.lwp ();
>>>> +      if (ptrace (PTRACE_GETEVENTMSG, event_ptid.lwp (), (PTRACE_TYPE_ARG3) 0,
>>>> +		  &execing_tid) != 0)
>>>> +	execing_tid = event_ptid.lwp ();
>>>
>>> This gave me pause -- this is setting execing_tid to the event lwp if ptrace fails.
>>> But execing_tid is already initialized to the event lwp.  I think it'd be clearer not
>>> to initialize it, like:
>>>
>>>       unsigned long execing_tid;
>>>       if (ptrace (PTRACE_GETEVENTMSG, event_ptid.lwp (), (PTRACE_TYPE_ARG3) 0,
>>> 		  &execing_tid) != 0)
>>> 	execing_tid = event_ptid.lwp ();
>>
>> Well, the question then is: what if the ptrace call fails?  It probably
>> never fails, but we still have to think about it.  execing_tid would be
>> used uninitialized.  I see three options:
> 
> I'm confused with the question.  In the snippet I proposed, if ptrace fails,
> then we set execing_tid:
> 
>       unsigned long execing_tid;
>       if (ptrace (PTRACE_GETEVENTMSG, event_ptid.lwp (), (PTRACE_TYPE_ARG3) 0,
> 		  &execing_tid) != 0)
> 	execing_tid = event_ptid.lwp ();  <<< ptrace failed.
> 
> So this behaves exactly like your original code, just without the redundant
> initialization.
> 
> Am I missing something?

No, I did miss that assignment.

I will add a comment to say that we fall back to the leader if ptrace
fails, not ideal but should be correct most of the time.

Simon

      reply	other threads:[~2026-06-26 18:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-26 14:32 simon.marchi
2026-06-26 17:35 ` Pedro Alves
2026-06-26 18:00   ` Simon Marchi
2026-06-26 18:04     ` Pedro Alves
2026-06-26 18:06       ` Simon Marchi [this message]

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=c7d1af4f-c340-4e6d-ae37-e4e863664914@polymtl.ca \
    --to=simon.marchi@polymtl.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=pedro@palves.net \
    /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