[commit] Fix an NPTL + vfork follow-fork bug

Daniel Jacobowitz drow@false.org
Wed Mar 2 15:10:00 GMT 2005


While working on another problem, I discovered that following a vfork from a
secondary thread didn't work.  I'm not precisely sure why it worked for me
before, but there have been reports that it didn't work for others which are
probably fixed by this change.  We were expecting the main thread instead of
the parent thread to deliver a VFORK_DONE event, and resuming the wrong
thread.

Committed as obvious (in hindsight).  The problem is easily fixed now that
linux-thread-db.c provides the LWP ID.

-- 
Daniel Jacobowitz
CodeSourcery, LLC

2005-03-02  Daniel Jacobowitz  <dan@codesourcery.com>

	* linux-nat.c (linux_supports_tracevforkdone, child_follow_fork):
	Use LWP IDs.

Index: linux-nat.c
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/gdb/linux-nat.c,v
retrieving revision 1.25
diff -u -p -r1.25 linux-nat.c
--- linux-nat.c	24 Feb 2005 13:51:34 -0000	1.25
+++ linux-nat.c	1 Mar 2005 21:34:03 -0000
@@ -293,9 +293,12 @@ linux_supports_tracevforkdone (int pid)
 void
 linux_enable_event_reporting (ptid_t ptid)
 {
-  int pid = ptid_get_pid (ptid);
+  int pid = ptid_get_lwp (ptid);
   int options;
 
+  if (pid == 0)
+    pid = ptid_get_pid (ptid);
+
   if (! linux_supports_tracefork (pid))
     return;
 
@@ -340,7 +343,9 @@ child_follow_fork (int follow_child)
 
   get_last_target_status (&last_ptid, &last_status);
   has_vforked = (last_status.kind == TARGET_WAITKIND_VFORKED);
-  parent_pid = ptid_get_pid (last_ptid);
+  parent_pid = ptid_get_lwp (last_ptid);
+  if (parent_pid == 0)
+    parent_pid = ptid_get_pid (last_ptid);
   child_pid = last_status.value.related_pid;
 
   if (! follow_child)



More information about the Gdb-patches mailing list