From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id aLQEEUNWb2BCGQAAWB0awg (envelope-from ) for ; Thu, 08 Apr 2021 15:15:15 -0400 Received: by simark.ca (Postfix, from userid 112) id 3CA751E965; Thu, 8 Apr 2021 15:15:15 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,URIBL_BLOCKED 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 1557F1EE0E for ; Thu, 8 Apr 2021 15:15:14 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B7C743954C04; Thu, 8 Apr 2021 19:15:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B7C743954C04 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1617909313; bh=5kTla0OBTvsObIJzvLE7JqcHOZavOlyTRNaJ6LitZGk=; 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=ZOmKf38VGip7esj+DrVsOgb5SK2Yl22Pw4GbGRibsSF0Wf+wxI6VCUECEB7AB4p0s 5O7lZ9kEMpb4RKJyO7xWbVqhXCxxoYZCqowYxO9Ykx5edh4swUHDzRuBLh5CmESsLF GkXVTaTCYy5Ko/40G5oOA5i3dc1B1QB2+4yYeFEA= Received: from SCXMACQUATRAVAUXD.localdomain (vpn-253-187.epfl.ch [128.179.253.187]) by sourceware.org (Postfix) with SMTP id 92BB83954460 for ; Thu, 8 Apr 2021 19:15:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 92BB83954460 Received: by SCXMACQUATRAVAUXD.localdomain (Postfix, from userid 502) id DB2CB55E7427; Thu, 8 Apr 2021 21:15:10 +0200 (CEST) To: gdb-patches@sourceware.org Subject: [PATCH 3/3] [fix] Skip over WIFSTOPPED wait4 status Date: Thu, 8 Apr 2021 21:14:48 +0200 Message-Id: <20210408191449.27434-3-dominique.quatravaux@epfl.ch> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210408191449.27434-1-dominique.quatravaux@epfl.ch> References: <20210408191449.27434-1-dominique.quatravaux@epfl.ch> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: Dominique Quatravaux via Gdb-patches Reply-To: Dominique Quatravaux Cc: Dominique Quatravaux Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" 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) --- gdb/darwin-nat.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c index 9c6423ceb02..cbe36eba626 100644 --- a/gdb/darwin-nat.c +++ b/gdb/darwin-nat.c @@ -1053,7 +1053,7 @@ darwin_nat_target::decode_message (mach_msg_header_= t *hdr, } else if (hdr->msgh_id =3D=3D 0x48) { - /* MACH_NOTIFY_DEAD_NAME: notification for exit. */ + /* MACH_NOTIFY_DEAD_NAME: notification for exit *or* WIFSTOPPED. = */ int res; =20 res =3D darwin_decode_notify_message (hdr, &inf); @@ -1096,16 +1096,23 @@ darwin_nat_target::decode_message (mach_msg_heade= r_t *hdr, { status->kind =3D TARGET_WAITKIND_EXITED; status->value.integer =3D WEXITSTATUS (wstatus); + inferior_debug (4, _("darwin_wait: pid=3D%d exit, status=3D0x%x\n"), + res_pid, wstatus); + } + else if (WIFSTOPPED (wstatus)) + { + status->kind =3D TARGET_WAITKIND_IGNORE; + inferior_debug (4, _("darwin_wait: pid %d received WIFSTOPPED\n"), r= es_pid); + return minus_one_ptid; } else { status->kind =3D TARGET_WAITKIND_SIGNALLED; status->value.sig =3D gdb_signal_from_host (WTERMSIG (wstatus)); + inferior_debug (4, _("darwin_wait: pid=3D%d received signal %d\n"), + res_pid, status->value.sig); } =20 - inferior_debug (4, _("darwin_wait: pid=3D%d exit, status=3D0x%x\n= "), - res_pid, wstatus); - return ptid_t (inf->pid); } else --=20 2.31.1