From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 56C753851408 for ; Thu, 21 Jul 2022 02:25:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 56C753851408 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) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 16FC01E222; Wed, 20 Jul 2022 22:25:52 -0400 (EDT) Message-ID: <2fd4b59c-48a5-f802-f708-64e7d7db602f@simark.ca> Date: Wed, 20 Jul 2022 22:25:51 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH v2 05/29] Support clone events in the remote protocol Content-Language: en-US To: Pedro Alves , gdb-patches@sourceware.org References: <20220713222433.374898-1-pedro@palves.net> <20220713222433.374898-6-pedro@palves.net> From: Simon Marchi In-Reply-To: <20220713222433.374898-6-pedro@palves.net> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: Thu, 21 Jul 2022 02:25:54 -0000 Just some nits: > @@ -5897,16 +5901,35 @@ is_fork_status (target_waitkind kind) > || kind == TARGET_WAITKIND_VFORKED); > } > > -/* Return THREAD's pending status if it is a pending fork parent, else > - return nullptr. */ > +/* Determine if WS represents an event with a new child - a fork, > + vfork, or clone. */ > + > +static bool > +is_new_child_status (target_waitkind kind) > +{ > + return (kind == TARGET_WAITKIND_FORKED > + || kind == TARGET_WAITKIND_VFORKED > + || kind == TARGET_WAITKIND_THREAD_CLONED); > +} This could maybe be a shared util function in waitstatus.h, linux-nat has something really similar. > + > +/* Return a reference to the field that records the THREAD's pending > + child status, if there's one. */ > + > +static const target_waitstatus & > +thread_pending_status (struct thread_info *thread) > +{ > + return (thread->has_pending_waitstatus () > + ? thread->pending_waitstatus () > + : thread->pending_follow); > +} The "if there's one" part of the comment doesn't really work. We return a reference, so we will always return something. > @@ -7303,13 +7346,14 @@ remote_target::remove_new_fork_children (threads_listing_context *context) > context->remove_thread (ws->child_ptid ()); > } > > - /* Check for any pending fork events (not reported or processed yet) > - in process PID and remove those fork child threads from the > - CONTEXT list as well. */ > + /* Check for any pending (v)fork/clone events (not reported or > + processed yet) in process PID and remove those child threads from > + the CONTEXT list as well. */ > remote_notif_get_pending_events (notif); > for (auto &event : get_remote_state ()->stop_reply_queue) > if (event->ws.kind () == TARGET_WAITKIND_FORKED > - || event->ws.kind () == TARGET_WAITKIND_VFORKED) > + || event->ws.kind () == TARGET_WAITKIND_VFORKED > + || event->ws.kind () == TARGET_WAITKIND_THREAD_CLONED) This could use is_new_child_status. The function could maybe be renamed to just "remove_new_children". Simon