From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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) From: Philippe Blain To: gdb-patches@sourceware.org Cc: Dominique Quatravaux , Sam Warner , Louis-He <1726110778@qq.com>, Simon Marchi 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-Spam-Status: No, score=-9.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, 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: Wed, 16 Feb 2022 14:15:48 -0000 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