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 29912385841D for ; Mon, 7 Mar 2022 20:08:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 29912385841D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca Received: from [172.16.0.95] (192-222-180-24.qc.cable.ebox.net [192.222.180.24]) (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 815031EA69; Mon, 7 Mar 2022 15:08:06 -0500 (EST) Message-ID: Date: Mon, 7 Mar 2022 15:08:05 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH 07/11] Re-add zombie leader on exit, gdb/linux Content-Language: tl To: Pedro Alves , gdb-patches@sourceware.org References: <20220303144020.3601082-1-pedro@palves.net> <20220303144020.3601082-8-pedro@palves.net> From: Simon Marchi In-Reply-To: <20220303144020.3601082-8-pedro@palves.net> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3639.4 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, NICE_REPLY_A, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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, 07 Mar 2022 20:08:08 -0000 On 2022-03-03 09:40, Pedro Alves wrote: > @@ -2814,7 +2822,23 @@ linux_nat_filter_event (int lwpid, int status) > /* Don't report an event for the exit of an LWP not in our > list, i.e. not part of any inferior we're debugging. > This can happen if we detach from a program we originally > - forked and then it exits. */ > + forked and then it exits. However, note that we may have > + earlier deleted a leader of an inferior we're debugging, > + in check_zombie_leaders. Re-add it back here if so. */ > + for (inferior *inf : all_inferiors (linux_target)) > + { > + if (inf->pid == lwpid) > + { > + linux_nat_debug_printf > + ("Re-adding thread group leader LWP %d after exit.", > + lwpid); > + > + lp = add_lwp (ptid_t (lwpid, lwpid)); > + lp->resumed = 1; > + add_thread (linux_target, lp->ptid); > + break; > + } > + } Should we do this only if WIFEXITED? We don't expect to get any other event from a deleted leader, so it's more to be safe in case there is a kernel bug or something that would make us see something else. Otherwise, LGTM. Simon