From: Pedro Alves <pedro@palves.net>
To: Simon Marchi <simon.marchi@polymtl.ca>, 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 19:04:52 +0100 [thread overview]
Message-ID: <d3a53ae6-a9bd-4732-9a3e-3c9701603c6f@palves.net> (raw)
In-Reply-To: <b7a42372-ebec-430e-ba72-32b14d8788f5@polymtl.ca>
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?
next prev parent reply other threads:[~2026-06-26 18:05 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 [this message]
2026-06-26 18:06 ` Simon Marchi
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=d3a53ae6-a9bd-4732-9a3e-3c9701603c6f@palves.net \
--to=pedro@palves.net \
--cc=gdb-patches@sourceware.org \
--cc=simon.marchi@polymtl.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