From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1879) id DF7DD3858402; Thu, 24 Feb 2022 15:49:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DF7DD3858402 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Simon Marchi To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb/darwin: skip over WIFSTOPPED wait4 status X-Act-Checkin: binutils-gdb X-Git-Author: Dominique Quatravaux X-Git-Refname: refs/heads/master X-Git-Oldrev: 0b313e95a73ad567915c9c1135d3d49f39236325 X-Git-Newrev: 7ff917016a203cdff3074abfcf96c1553944af94 Message-Id: <20220224154916.DF7DD3858402@sourceware.org> Date: Thu, 24 Feb 2022 15:49:16 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Feb 2022 15:49:17 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D7ff917016a20= 3cdff3074abfcf96c1553944af94 commit 7ff917016a203cdff3074abfcf96c1553944af94 Author: Dominique Quatravaux Date: Thu Feb 24 09:23:21 2022 -0500 gdb/darwin: skip over WIFSTOPPED wait4 status =20 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). =20 - 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 =20 Co-authored-by: Louis-He <1726110778@qq.com> Co-authored-by: Philippe Blain Change-Id: Ie86904a894e9bd154e6b674b1bfbfbaee7fde3e1 Diff: --- gdb/darwin-nat.c | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c index 8b0ecfd5b77..adbe7474c68 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 =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); @@ -1103,15 +1103,34 @@ 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=3D%d exit, status=3D0x%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=3D%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=3D%d exit, status=3D0x%x\n"), - res_pid, wstatus); =20 return ptid_t (inf->pid); }