From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 897ED3858438 for ; Mon, 29 Nov 2021 12:46:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 897ED3858438 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 1ATCkdlk005754 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 29 Nov 2021 07:46:44 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 1ATCkdlk005754 Received: from [10.0.0.11] (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 4FD6D1ECEB; Mon, 29 Nov 2021 07:46:39 -0500 (EST) Message-ID: <682fd2be-73e6-3372-5b03-a9e94a04f101@polymtl.ca> Date: Mon, 29 Nov 2021 07:46:38 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.0 Subject: Re: [PATCH 1/3] gdbserver: hide fork child threads from GDB Content-Language: en-US To: Pedro Alves , Simon Marchi , gdb-patches@sourceware.org References: <20211029203332.69894-1-simon.marchi@polymtl.ca> <20211124200444.614978-1-simon.marchi@efficios.com> <20211124200444.614978-2-simon.marchi@efficios.com> <1e343901-2199-1034-2c05-be8668e2c8a5@palves.net> From: Simon Marchi In-Reply-To: <1e343901-2199-1034-2c05-be8668e2c8a5@palves.net> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Mon, 29 Nov 2021 12:46:39 +0000 X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Nov 2021 12:46:50 -0000 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