From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id YC2AJAyVF2I0IwAAWB0awg (envelope-from ) for ; Thu, 24 Feb 2022 09:24:12 -0500 Received: by simark.ca (Postfix, from userid 112) id 934401F3C8; Thu, 24 Feb 2022 09:24:12 -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 2B1881EE1F for ; Thu, 24 Feb 2022 09:24:12 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BDFEE3858017 for ; Thu, 24 Feb 2022 14:24:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BDFEE3858017 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1645712651; bh=taSrGcxpRANwiGyPlm5GlXLjNw0EiXuEwWo7oJ76Zh4=; 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=sFEA0+IiOWV51corZPTkh8EzBzwJ+wCp20M1zyIZHXx2Z8Vqa+49b07kL3gQqb8Pb BB7MU5UGlLFiVKyiVtqb7Kfl3zz2GKq7uznLv0R4X3D9qTf+OF3XsLf6COHUlIUwZX GxHTidDUxrWnMfgMjb4mktgLL+AAxi1AYoaiCtsw= Received: from mail-qv1-xf2b.google.com (mail-qv1-xf2b.google.com [IPv6:2607:f8b0:4864:20::f2b]) by sourceware.org (Postfix) with ESMTPS id A6933385841F for ; Thu, 24 Feb 2022 14:23:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A6933385841F Received: by mail-qv1-xf2b.google.com with SMTP id w7so3789859qvr.3 for ; Thu, 24 Feb 2022 06:23:26 -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=taSrGcxpRANwiGyPlm5GlXLjNw0EiXuEwWo7oJ76Zh4=; b=GWT8/efP3ctkpRQmvt/czpr3/YWNB9OrOOnL3eTAjkWV9NdgQj9kbbTOX1hne4wont 25BaVFTqiuMvhO1z83jo/iy5LTxpzYf6JeX/d4ZetT4zgYWuIFizyM361KMVwHdgHnEH yAnmUYcHQAX0PVGDXBHwVaO4lb63/Ofr6tv7jFso0gqGruxO+DNFFWWb0W7dv/5NLY08 XzcUODidJfphnR14OoAPbLLPVACXAN3npfJgTKK0LWJeV3bZeLrBPIfQXAWFfgNvl7GG GVbFFESdORbOjtT1GIz4+UjAbw/dKNzwp8YhWCBy2HSjMhXv3Sd6kPziZfT6xj6j1yxw 82jA== X-Gm-Message-State: AOAM531uKVZgbtBs4aesj2Q4/RnwOgjR2CxM4/86ML5i9ubwKV4QqNeo 4b6Z0jUReLH1bSfRNo814u6pCfJCWVw= X-Google-Smtp-Source: ABdhPJzCCN7hxFpwOQSY3YTDwrDaeutjwsdTDmOkzxPuo35IcY5BoMf10wXxgdusk0BC20zfYHDEaQ== X-Received: by 2002:ac8:48d3:0:b0:2d1:f334:4d70 with SMTP id l19-20020ac848d3000000b002d1f3344d70mr2534187qtr.366.1645712605501; Thu, 24 Feb 2022 06:23:25 -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 17sm1328005qka.119.2022.02.24.06.23.24 (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 24 Feb 2022 06:23:24 -0800 (PST) To: gdb-patches@sourceware.org Subject: [RFC][PATCH v3 1/1][PR gdb/24069] gdb/darwin: skip over WIFSTOPPED wait4 status Date: Thu, 24 Feb 2022 09:23:21 -0500 Message-Id: <20220224142321.585-2-levraiphilippeblain@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20220224142321.585-1-levraiphilippeblain@gmail.com> References: <20220216141540.96514-1-levraiphilippeblain@gmail.com> <20220224142321.585-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 MACH_NOTIFY_DEAD_NAME cases (WIFEXITED, WIFSTOPPED, signal, or something else), and warn in the last case 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. --- gdb/darwin-nat.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c index d96ce1a6c65..1adc6bd8bff 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,15 +1103,33 @@ darwin_nat_target::decode_message (mach_msg_header_t *hdr, return minus_one_ptid; } if (WIFEXITED (wstatus)) - status->set_exited (WEXITSTATUS (wstatus)); - else + { + status->set_exited (WEXITSTATUS (wstatus)); + inferior_debug (4, _("darwin_wait: pid=%d exit, status=0x%x\n"), + res_pid, wstatus); + } + else if (WIFSTOPPED (wstatus)) + { + /* Ignore stopped state, it will be handled by the next exception */ + status->set_ignore (); + inferior_debug (4, _("darwin_wait: pid %d received WIFSTOPPED\n"), + res_pid); + return minus_one_ptid; + } + else if (WIFSIGNALED (wstatus)) { status->set_signalled (gdb_signal_from_host (WTERMSIG (wstatus))); + inferior_debug (4, _("darwin_wait: pid=%d received signal %d\n"), + res_pid, status->sig()); + } + else + { + status->set_ignore (); + warning (_("Unexpected wait status after MACH_NOTIFY_DEAD_NAME " + "notification: 0x%x"), wstatus); + return minus_one_ptid; } - - inferior_debug (4, _("darwin_wait: pid=%d exit, status=0x%x\n"), - res_pid, wstatus); /* Looks necessary on Leopard and harmless... */ wait4 (inf->pid, &wstatus, 0, NULL); -- 2.29.2