From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) by sourceware.org (Postfix) with ESMTPS id B30383858D39 for ; Fri, 26 Nov 2021 22:51:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B30383858D39 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f52.google.com with SMTP id g191-20020a1c9dc8000000b0032fbf912885so7697571wme.4 for ; Fri, 26 Nov 2021 14:51:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=wxt+RJ49cgedKwoIjxps+JzKZG8MA48ywmSxz6rNl5k=; b=gm+d1iql5+qh478RKcj3fksdnz8mBq/qfsbefiPqcELSFhoHAYMZbajgF0y87mwhiE f+dX54lHrMM0hNhCNZ4tG/+KZn21BpMZm7hnQaAc79soDr+TDPl4c6gFC2Fsbz7M1s94 476D5X7t4ckVMU/243KMR5zayF6nOlEWWo4eS9s7++ew9eGF1UjzwSdA5sYs8reIzNPY 2Bx8x/q2CrPtpMuduJ39VGLQ7j4Gba34UJWORTyBJtd2fndITDtFnncYFG+2MOcQSUnG /dQLMOyrFBlGyzeFWQwAiVtD0UFELR24G1j5ItOLvI7GpGkUONJFqP3vIM9x+YrKH9QL QXyg== X-Gm-Message-State: AOAM530sV3jEz8I5TWFVmSViFWscZsdXLLVLNmCxLdBNyKMkf79lKuZn WHfB2vLD7Y/ZZalp3gNS0iMp7QC3LlM= X-Google-Smtp-Source: ABdhPJwhOQYcQ7nNpDDbhubSdDaCe76SCt2Zyb53vNtYEAIdE0SDDsUNPi0JZzCK2M4pmYN/+obYXg== X-Received: by 2002:a1c:5414:: with SMTP id i20mr19296662wmb.88.1637967086761; Fri, 26 Nov 2021 14:51:26 -0800 (PST) Received: from ?IPV6:2001:8a0:f912:1a00:d3db:ac91:4b9e:1449? ([2001:8a0:f912:1a00:d3db:ac91:4b9e:1449]) by smtp.gmail.com with ESMTPSA id o4sm8752938wry.80.2021.11.26.14.51.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 26 Nov 2021 14:51:26 -0800 (PST) Message-ID: <1e343901-2199-1034-2c05-be8668e2c8a5@palves.net> Date: Fri, 26 Nov 2021 22:51:25 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 Subject: Re: [PATCH 1/3] gdbserver: hide fork child threads from GDB Content-Language: en-US To: 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> From: Pedro Alves In-Reply-To: <20211124200444.614978-2-simon.marchi@efficios.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, 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: Fri, 26 Nov 2021 22:51:29 -0000 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.