[RFC][PATCH v2 0/2][PR gdb/24069] Fix GDB hang on macOS 10.14 and later (PR gdb/24609)
Philippe Blain
levraiphilippeblain@gmail.com
Wed Feb 16 14:15:38 GMT 2022
Hello, this is a rebased version of Dominique Quatravaux's patches from April
2021 [1] (also at [2]) relating to PR gdb/24609.
The first patch of that series was commited in 83a559f7b93 (Remove unused
variable un darwin_nat_target::resume, 2021-04-08), so it's omitted here.
1/2 is thus Dominique's 2nd patch, ans 2/2 Dominique's 3rd.
1/2 is unchanged; 2/2 is mostly the re-worked version that Louis posted as an
attachment on Bugzilla recently [3], [4]. I've kept Dominique as author
and added a "Co-authored-by" trailer for Louis and myself, I hope this is OK
with everyone (and in line with the project's conventions).
Louis, tell me if you'd preferred a different name+email identity be recorded
in the commit message trailer.
The date used in the Changelog entries is current, but I kept the commit dates
to those of Dominiques's v1. Let me know if one or the other should be changed.
The patches are marked RFC because I can't yet show testsuite results. When
manually running GDB compiled with these patches on macOS 10.15, it seems to
work (not hang), although only with 'set startup-with-shell off'. However,
when I run the testsuite, GDB hangs systematically in the 'wait4' call at
gdb/darwin-nat.c:1097, i.e.
res_pid = wait4 (inf->pid, &wstatus, 0, NULL);
as can be seen by attaching LLDB, and so tests timeout. An exemple run on
GitHub Actions can be found at [5]. On my macOS 10.11 system, this hang does
not happen, with or without the patches. I'm not sure how to go about debugging
this hang when running the test suite... I did try "set debug infrun 1" and
"set debug darwin 12", as Simon suggested in [6], but it did not seem to help
me understand.
A range-diff against v1 is included below.
[1] https://pi.simark.ca/gdb-patches/20210408191449.27434-1-dominique.quatravaux@epfl.ch/t/#u
[2] https://sourceware.org/pipermail/gdb-patches/2021-April/177598.html
[3] https://sourceware.org/bugzilla/attachment.cgi?id=13953
[4] https://pi.simark.ca/gdb-patches/CAE1H+iEug4oQF1ty9tMz9xJUD1kW=6e7ZUuBcXPfuSAxzhFwvA@mail.gmail.com/
[5] https://github.com/phil-blain/binutils-gdb/runs/5114288157?check_suite_focus=true
[6] https://pi.simark.ca/gdb-patches/4bf807c4-d78f-05a4-6cf5-4fa283bc7c1d@simark.ca/
Dominique Quatravaux (2):
[delete] Not-so-harmless spurious call to `wait4`
[fix] Skip over WIFSTOPPED wait4 status
gdb/darwin-nat.c | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
Range-diff against v1:
1: faee0c55f49 < -: ----------- [fix] Unused struct
2: 1aeab1c3e10 ! 1: 1dd0dc08936 [delete] Not-so-harmless spurious call to `wait4`
@@ Commit message
commits bb00b29d7802 and a80b95ba67e2 from the 2008-2009 era, but
fails to answer the “why” question conclusively.
+ ChangeLog:
+
+ 2022-02-05 Dominique Quatravaux <dominique.quatravaux@epfl.ch>
+
+ PR gdb/24609
+ * gdb/darwin-nat.c (darwin_nat_target::decode_message): Remove
+ spurious call to wait4.
+
## gdb/darwin-nat.c ##
@@ gdb/darwin-nat.c: darwin_nat_target::decode_message (mach_msg_header_t *hdr,
inferior_debug (4, _("darwin_wait: pid=%d exit, status=0x%x\n"),
3: fa02ae8a550 ! 2: 8da6aefb32d [fix] Skip over WIFSTOPPED wait4 status
@@ Commit message
- 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 ##
@@ gdb/darwin-nat.c: 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. */
++ /* MACH_NOTIFY_DEAD_NAME: notification for exit *or* WIFSTOPPED. */
int res;
res = darwin_decode_notify_message (hdr, &inf);
@@ gdb/darwin-nat.c: darwin_nat_target::decode_message (mach_msg_header_t *hdr,
- {
- status->kind = TARGET_WAITKIND_EXITED;
- status->value.integer = WEXITSTATUS (wstatus);
-+ inferior_debug (4, _("darwin_wait: pid=%d exit, status=0x%x\n"),
+ 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->kind = TARGET_WAITKIND_IGNORE;
-+ inferior_debug (4, _("darwin_wait: pid %d received WIFSTOPPED\n"), res_pid);
++ status->set_ignore ();
++ inferior_debug (4, _("darwin_wait: pid %d received WIFSTOPPED\n"),
++ res_pid);
+ return minus_one_ptid;
- }
++ }
else
{
- status->kind = TARGET_WAITKIND_SIGNALLED;
- status->value.sig = gdb_signal_from_host (WTERMSIG (wstatus));
+ status->set_signalled
+ (gdb_signal_from_host (WTERMSIG (wstatus)));
+ inferior_debug (4, _("darwin_wait: pid=%d received signal %d\n"),
-+ res_pid, status->value.sig);
++ res_pid, status->sig());
}
- inferior_debug (4, _("darwin_wait: pid=%d exit, status=0x%x\n"),
base-commit: 0acf434a23768449cbb4b3732355f3f2febecaee
--
2.29.2
More information about the Gdb-patches
mailing list