[RFC][PATCH v3 0/1][PR gdb/24069] Fix GDB hang on macOS 10.14 and later

Philippe Blain levraiphilippeblain@gmail.com
Thu Feb 24 14:23:20 GMT 2022


Hello, here is v3 of the series.

1/2 of v2 was commited in 9cca177baec (gdb/darwin: remove not-so-harmless
spurious call to `wait4`, 2022-02-16), and so is ommited here.

So this patch is 2/2 of v2, tweaked following Simon's feedback.

Once again Louis, tell me if you'd preferred a different name+email identity be
recorded in the Co-authored-by commit message trailer.

The patches are still marked RFC because I can't yet show testsuite results
(see cover letter of v2 [1]).

A range-diff against v2 is included below.

[1] https://pi.simark.ca/gdb-patches/20220216141540.96514-1-levraiphilippeblain@gmail.com/#t

Dominique Quatravaux (1):
  gdb/darwin: skip over WIFSTOPPED wait4 status

 gdb/darwin-nat.c | 30 ++++++++++++++++++++++++------
 1 file changed, 24 insertions(+), 6 deletions(-)

Range-diff against v2:
1:  e57a887cace < -:  ----------- [deleted] Not-so-harmless spurious call to `wait4`
2:  f7819ff3e55 ! 1:  7e2e0fa614b [fix] Skip over WIFSTOPPED wait4 status
    @@ Metadata
     Author: Dominique Quatravaux <dominique.quatravaux@epfl.ch>
     
      ## Commit message ##
    -    [fix] Skip over WIFSTOPPED wait4 status
    +    gdb/darwin: skip over WIFSTOPPED wait4 status
     
         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
    @@ Commit message
     
         - 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)
    +    - 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 <levraiphilippeblain@gmail.com>
    @@ Commit message
     
         2022-02-05  Dominique Quatravaux <dominique.quatravaux@epfl.ch>
     
    -    PR gdb/24609
    +            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: 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,
      		}
      	      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"),
    @@ gdb/darwin-nat.c: darwin_nat_target::decode_message (mach_msg_header_t *hdr,
     +		}
     +	      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
    ++	      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);
    --
    - 	      return ptid_t (inf->pid);
    - 	    }
    - 	  else
    + 
    + 	      /* Looks necessary on Leopard and harmless...  */
    + 	      wait4 (inf->pid, &wstatus, 0, NULL);

base-commit: 0acf434a23768449cbb4b3732355f3f2febecaee
-- 
2.29.2



More information about the Gdb-patches mailing list