From: Simon Marchi <simon.marchi@polymtl.ca>
To: Pedro Alves <pedro@palves.net>,
Simon Marchi <simon.marchi@efficios.com>,
gdb-patches@sourceware.org
Subject: Re: [PATCH 1/3] gdbserver: hide fork child threads from GDB
Date: Mon, 29 Nov 2021 07:46:38 -0500 [thread overview]
Message-ID: <682fd2be-73e6-3372-5b03-a9e94a04f101@polymtl.ca> (raw)
In-Reply-To: <1e343901-2199-1034-2c05-be8668e2c8a5@palves.net>
On 2021-11-26 17:51, Pedro Alves wrote:
> On 2021-11-24 20:04, Simon Marchi via Gdb-patches wrote:
>
>> I split the field in two (fork_parent / fork_child), I think it's
>> clearer this way, easier to follow which thread is the parent and which
>> is the child, and helps ensure things are consistent. That simplifies
>> things a bit in linux_set_resume_request.
>
> This had been conscientiously done that way to avoid storing redundant
> information. You could have the same thing with a single field + the
> waitstatus, wrapped in fork_child()/fork_parent() methods. But I'm fine with
> with that you have. I do see a different reason for taking the two-fields approach
> though -- you don't have access to the pending waitstatus in common code.
> That would be a better rationale, IMO. OTOH, I think we will end up needing
> access to the pending waitstatus anyhow. See below, and the review to patch #3.
>
>> Currently, when
>> lwp->fork_relative is set, we have to deduce whether this is a parent or
>> child using the pending event. With separate fork_parent and fork_child
>> fields, it becomes more obvious. If the thread has a fork parent, then
>> it means it's a fork child, and vice-versa.
>
> With clone events, in some spots I'll need to be able to know whether
> fork_child being set means the thread is stopped for a fork/vfork or a
> clone event. Most of the code related to fork_parent/fork_child is the
> same for forks and for clones, but not all.
>
> Wonder whether we should instead have some:
>
> thread_info *target_pending_child (thread_info *parent);
> thread_info *target_pending_child_parent (thread_info *child);
> target_waitkind target_pending_child_kind (thread_info *parent);
>
> target methods instead of moving the fields. I haven't thought this
> fully through, though.
At first I wasn't sure, I was thinking that having the fields directly
in thread_info would help avoid duplication, in case another OS (e.g.
NetBSD) decided to implement the same thing. But not really: even if
the fields are in thread_info, the bulk of the work (updating these
fields) is done by the target. Since the state is managed by the
target, target methods make sense.
I will add a "target_thread_pending_parent" in this patch, a
"target_thread_pending_child" in patch 3, and in your series you can add
a way to get the kind. Either a new method, or I was thinking of an
output parameter on target_thread_pending_child. Sounds good?
Simon
next prev parent reply other threads:[~2021-11-29 12:46 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-29 20:33 [PATCH 1/2] " Simon Marchi
2021-10-29 20:33 ` [PATCH 2/2] gdb, gdbserver: detach fork child when detaching from fork parent Simon Marchi
2021-11-12 20:54 ` [PATCH 1/2] gdbserver: hide fork child threads from GDB (ping) Simon Marchi
2021-11-24 20:04 ` [PATCH 0/3] Fix handling of pending fork events Simon Marchi
2021-11-24 20:04 ` [PATCH 1/3] gdbserver: hide fork child threads from GDB Simon Marchi
2021-11-26 22:51 ` Pedro Alves
2021-11-29 12:46 ` Simon Marchi [this message]
2021-11-29 15:37 ` Pedro Alves
2021-11-24 20:04 ` [PATCH 2/3] gdb/linux-nat: factor ptrace-detach code to new detach_one_pid function Simon Marchi
2021-11-26 22:51 ` Pedro Alves
2021-11-24 20:04 ` [PATCH 3/3] gdb, gdbserver: detach fork child when detaching from fork parent Simon Marchi
2021-11-26 22:54 ` Pedro Alves
2021-11-29 18:27 ` Simon Marchi
2021-11-24 20:56 ` [PATCH 0/3] Fix handling of pending fork events Simon Marchi
2021-11-26 22:50 ` Pedro Alves
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=682fd2be-73e6-3372-5b03-a9e94a04f101@polymtl.ca \
--to=simon.marchi@polymtl.ca \
--cc=gdb-patches@sourceware.org \
--cc=pedro@palves.net \
--cc=simon.marchi@efficios.com \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).