From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id OAD+MloHDWIsNwAAWB0awg (envelope-from ) for ; Wed, 16 Feb 2022 09:16:58 -0500 Received: by simark.ca (Postfix, from userid 112) id CF2C41F3C9; Wed, 16 Feb 2022 09:16:58 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from sourceware.org (ip-8-43-85-97.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 3F8441EDF0 for ; Wed, 16 Feb 2022 09:16:58 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D67963858C20 for ; Wed, 16 Feb 2022 14:16:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D67963858C20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1645021017; bh=z/2cP9SHZjy0tPsB8fGNUDZSJfKwaR2+htgzAEQ7mxE=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=QDH3Y7lgYpYGQI+lKd0Rummm9VkO158s7sFa2z4j6refrh44AtaGZZrWcEGweA7+y Whn60Ewcohrr+FZ1Pon5VkqbqAPyhuJKgHDmk+OxmTITV8TZrFdxE0Eykecho8khPs gwA16OwvDDj8zzzn0SKBnIxltnvXmbQAA2qb7HHY= Received: from mail-qt1-x82a.google.com (mail-qt1-x82a.google.com [IPv6:2607:f8b0:4864:20::82a]) by sourceware.org (Postfix) with ESMTPS id 077F83858C2C for ; Wed, 16 Feb 2022 14:15:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 077F83858C2C Received: by mail-qt1-x82a.google.com with SMTP id e16so2149442qtq.6 for ; Wed, 16 Feb 2022 06:15:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=z/2cP9SHZjy0tPsB8fGNUDZSJfKwaR2+htgzAEQ7mxE=; b=UyBmQmHpaIRr0sJ/sBKWb35VGTLX6UoIbgo428SsXwyijCSiPxPeXH3U9fU0t/TpkY 6owSM1fr8MiDQZvyM+3YGwa62CPdrCYT9dXzUmglW3rEP6hejybNmaME56/v+8Dlo+TH ExdW2LC20Bwj3BjsbHqfXxvswC8O9rSXp1Kx7xM4IZWUrGspYPwC5vflGZL1GOGPSBhA AMEYF3+PHRlUv7TXTxNUL2PW2SrzAFyTiu11tUXzcSVqpc94/7kZRk5W4brfFdun5oa9 B/Ah4Lx694Qf0tBtlhCCPxeOz9fl0gq+/Z1RkztxCol4bmqObZDNo7BXgvHR7lTJtc24 d3sw== X-Gm-Message-State: AOAM530i3YNkXzo6hWmFYyvBfUnMwWku2OlMGrQylj1jInF21Hc5hW3T DAIHaioZ4VOzcsx6UKLVozCiM6D4byKhyg== X-Google-Smtp-Source: ABdhPJzON5qvWSEYH6eNbdChqeeH8e/3XUt6RsDPPqAsqyH5tNllhQyRuFUc0SP7ZOrZWGZnj+tLAg== X-Received: by 2002:a05:622a:1741:b0:2dc:eb59:7967 with SMTP id l1-20020a05622a174100b002dceb597967mr2041350qtk.563.1645020944860; Wed, 16 Feb 2022 06:15:44 -0800 (PST) Received: from localhost.localdomain (173-246-5-136.qc.cable.ebox.net. [173.246.5.136]) by smtp.gmail.com with ESMTPSA id w4sm19653239qko.123.2022.02.16.06.15.43 (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 16 Feb 2022 06:15:44 -0800 (PST) To: gdb-patches@sourceware.org Subject: [RFC][PATCH v2 2/2][PR gdb/24069] [fix] Skip over WIFSTOPPED wait4 status Date: Wed, 16 Feb 2022 09:15:40 -0500 Message-Id: <20220216141540.96514-3-levraiphilippeblain@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20220216141540.96514-1-levraiphilippeblain@gmail.com> References: <20210408191449.27434-1-dominique.quatravaux@epfl.ch> <20220216141540.96514-1-levraiphilippeblain@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: , From: Philippe Blain via Gdb-patches Reply-To: Philippe Blain Cc: Louis-He <1726110778@qq.com>, Dominique Quatravaux , Sam Warner Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" From: Dominique Quatravaux On modern Darwin's, there appears to be a new circumstance in which a MACH_NOTIFY_DEAD_NAME message can be received, and which was not previously accounted for: to signal the WIFSTOPPED condition in the debuggee. In that case the debuggee is not dead yet (and in fact, counting it as dead would cause a zombie leak - A process in such a state reparents to PID 1, but cannot be killed). - Read and ignore such messages (counting on the next exception message to let us know of the inferior's new state again) - Refactor logging so as to clearly distinguish between the three MACH_NOTIFY_DEAD_NAME cases (WIFEXITED, WIFSTOPPED, signal) Co-authored-by: Louis-He <1726110778@qq.com> Co-authored-by: Philippe Blain ChangeLog: 2022-02-05 Dominique Quatravaux PR gdb/24609 * gdb/darwin-nat.c (darwin_nat_target::decode_message): Also check for WIFSTOPPED upon MACH_NOTIFY_DEAD_NAME. --- Notes: I hope I did not mess up the indentation here. I did not find any guidelines about tab width in the C/C++ coding standards [1]. [1] https://sourceware.org/gdb/wiki/Internals%20GDB-C-Coding-Standards#Whitespaces gdb/darwin-nat.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c index 8b0ecfd5b77..a3c6a978676 100644 --- a/gdb/darwin-nat.c +++ b/gdb/darwin-nat.c @@ -1063,7 +1063,7 @@ darwin_nat_target::decode_message (mach_msg_header_t *hdr, } else if (hdr->msgh_id == 0x48) { - /* MACH_NOTIFY_DEAD_NAME: notification for exit. */ + /* MACH_NOTIFY_DEAD_NAME: notification for exit *or* WIFSTOPPED. */ int res; res = darwin_decode_notify_message (hdr, &inf); @@ -1103,16 +1103,26 @@ darwin_nat_target::decode_message (mach_msg_header_t *hdr, return minus_one_ptid; } if (WIFEXITED (wstatus)) - status->set_exited (WEXITSTATUS (wstatus)); + { + status->set_exited (WEXITSTATUS (wstatus)); + inferior_debug (4, _("darwin_wait: pid=%d exit, status=0x%x\n"), + res_pid, wstatus); + } + else if (WIFSTOPPED (wstatus)) + { + status->set_ignore (); + inferior_debug (4, _("darwin_wait: pid %d received WIFSTOPPED\n"), + res_pid); + return minus_one_ptid; + } else { status->set_signalled (gdb_signal_from_host (WTERMSIG (wstatus))); + inferior_debug (4, _("darwin_wait: pid=%d received signal %d\n"), + res_pid, status->sig()); } - inferior_debug (4, _("darwin_wait: pid=%d exit, status=0x%x\n"), - res_pid, wstatus); - return ptid_t (inf->pid); } else -- 2.29.2