From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 3XGhLipUn19afQAAWB0awg (envelope-from ) for ; Sun, 01 Nov 2020 19:34:50 -0500 Received: by simark.ca (Postfix, from userid 112) id B2ABD1F08B; Sun, 1 Nov 2020 19:34:50 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 680E31E590 for ; Sun, 1 Nov 2020 19:34:49 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D4CCA3857C6C; Mon, 2 Nov 2020 00:34:48 +0000 (GMT) Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 3F4323857C6C for ; Mon, 2 Nov 2020 00:34:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 3F4323857C6C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark@simark.ca Received: from [10.0.0.11] (173-246-6-90.qc.cable.ebox.net [173.246.6.90]) (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 4C23D1E590; Sun, 1 Nov 2020 19:34:45 -0500 (EST) Subject: Re: [PATCH] Limit the switch_to_thread() calls in startup_inferior() To: Kamil Rytarowski , gdb-patches@sourceware.org References: <20201014084940.1289-1-n54@gmx.com> From: Simon Marchi Message-ID: <3d161154-215c-2725-cdc3-02f96dca25ee@simark.ca> Date: Sun, 1 Nov 2020 19:34:44 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20201014084940.1289-1-n54@gmx.com> Content-Type: text/plain; charset=utf-8 Content-Language: fr Content-Transfer-Encoding: 7bit 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: , Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" On 2020-10-14 4:49 a.m., Kamil Rytarowski wrote: > Do not jump over the threads during the startup unless we encounter > TARGET_WAITKIND_STOPPED with SIGTRAP or TARGET_WAITKIND_EXECD. > > Otherwise whenever a startup-with-shell processes signals on the > startup stage, it might indicate to switch to a non-existing > thread or a special-thread number (target lwp=0 on NetBSD means > that a signal was directed to all threads within a process). > > This caused a crash with tcsh on NetBSD, where the tcsh shell > runs startup detection of the hostname. This action involves > spwaning a new process through fork. Kamil, one last question: out of curiosity, could you please share what's the list of target events reported by your target_wait, while in startup_inferior, in the problematic case? You can for apply this hack that will print them: diff --git a/gdb/nat/fork-inferior.c b/gdb/nat/fork-inferior.c index 7ba0126871dd..b8fc14ab83ac 100644 --- a/gdb/nat/fork-inferior.c +++ b/gdb/nat/fork-inferior.c @@ -485,6 +485,10 @@ startup_inferior (process_stratum_target *proc_target, pid_t pid, int ntraps, memset (&ws, 0, sizeof (ws)); event_ptid = target_wait (resume_ptid, &ws, 0); + void print_target_wait_results (ptid_t waiton_ptid, ptid_t result_ptid, + const struct target_waitstatus *ws); + print_target_wait_results (resume_ptid, event_ptid, &ws); + if (last_waitstatus != NULL) *last_waitstatus = ws; if (last_ptid != NULL) Simon