[RFC][PATCH v2 2/2][PR gdb/24069] [fix] Skip over WIFSTOPPED wait4 status
Philippe Blain
levraiphilippeblain@gmail.com
Wed Feb 16 14:15:40 GMT 2022
From: Dominique Quatravaux <dominique.quatravaux@epfl.ch>
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 <levraiphilippeblain@gmail.com>
ChangeLog:
2022-02-05 Dominique Quatravaux <dominique.quatravaux@epfl.ch>
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
More information about the Gdb-patches
mailing list