This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[Patch/Darwin]: Fortify inferior kill
- From: Tristan Gingold <gingold at adacore dot com>
- To: "gdb-patches at sourceware dot org ml" <gdb-patches at sourceware dot org>
- Date: Tue, 10 Apr 2012 17:33:30 +0200
- Subject: [Patch/Darwin]: Fortify inferior kill
Hi,
killing the inferior seldom resulted in a freeze of gdb, which is a real pain while the testsuite is run.
Fixed by using the no-ptrace existing code.
Committed on trunk after having run the testsuite.
Tristan.
2012-04-10 Tristan Gingold <gingold@adacore.com>
* darwin-nat.c (darwin_kill_inferior): Always use the no ptrace
code to kill the inferior.
Index: darwin-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/darwin-nat.c,v
retrieving revision 1.32
diff -c -r1.32 darwin-nat.c
*** darwin-nat.c 2 Apr 2012 11:57:30 -0000 1.32
--- darwin-nat.c 10 Apr 2012 15:29:04 -0000
***************
*** 1313,1347 ****
gdb_assert (inf != NULL);
! if (!inf->private->no_ptrace)
! {
! darwin_stop_inferior (inf);
!
! res = PTRACE (PT_KILL, inf->pid, 0, 0);
! if (res != 0)
! warning (_("Failed to kill inferior: ptrace returned %d "
! "[%s] (pid=%d)"),
! res, safe_strerror (errno), inf->pid);
! darwin_reply_to_all_pending_messages (inf);
! darwin_resume_inferior (inf);
! ptid = darwin_wait (inferior_ptid, &wstatus);
! }
! else
{
- kret = darwin_restore_exception_ports (inf->private);
- MACH_CHECK_ERROR (kret);
-
- darwin_reply_to_all_pending_messages (inf);
-
darwin_resume_inferior (inf);
!
! res = kill (inf->pid, 9);
!
ptid = darwin_wait (inferior_ptid, &wstatus);
}
target_mourn_inferior ();
}
--- 1313,1334 ----
gdb_assert (inf != NULL);
! kret = darwin_restore_exception_ports (inf->private);
! MACH_CHECK_ERROR (kret);
! darwin_reply_to_all_pending_messages (inf);
! res = kill (inf->pid, 9);
! if (res == 0)
{
darwin_resume_inferior (inf);
!
ptid = darwin_wait (inferior_ptid, &wstatus);
}
+ else if (errno != ESRCH)
+ warning (_("Failed to kill inferior: kill (%d, 9) returned [%s]"),
+ inf->pid, safe_strerror (errno));
target_mourn_inferior ();
}