This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[linux-nat] fix a confusion with the lwp->resumed flag in follow-fork handling


While working on some other changes, I stumbled on this confusion
with the lwp->resumed flag (I hit the assertion in
resume_stopped_resumed_lwps, while I shouldn't have).

Neither the parent nor the child forks have been resumed
by the core at this point, so it's bogus to set the flag.
I also renamed the locals a bit to make it easier to read which
is which.

Tested on x86_64-linux (also with a hack to force the
!linux_supports_tracevforkdone() path), and checked in.

-- 
Pedro Alves

2011-08-26  Pedro Alves  <pedro@codesourcery.com>

	gdb/
	* linux-nat.c (linux_child_follow_fork): Don't set lp->resumed on
	either the parent or the child forks.  Rename a couple locals.

---
 gdb/linux-nat.c |   24 ++++++++++--------------
 1 file changed, 10 insertions(+), 14 deletions(-)

Index: src/gdb/linux-nat.c
===================================================================
--- src.orig/gdb/linux-nat.c	2011-08-26 20:16:04.725883502 +0100
+++ src/gdb/linux-nat.c	2011-08-26 20:51:52.955883878 +0100
@@ -696,7 +696,6 @@ holding the child stopped.  Try \"set de
 	  add_thread (inferior_ptid);
 	  child_lp = add_lwp (inferior_ptid);
 	  child_lp->stopped = 1;
-	  child_lp->resumed = 1;
 
 	  /* If this is a vfork child, then the address-space is
 	     shared with the parent.  */
@@ -738,7 +737,7 @@ holding the child stopped.  Try \"set de
 
       if (has_vforked)
 	{
-	  struct lwp_info *lp;
+	  struct lwp_info *parent_lp;
 	  struct inferior *parent_inf;
 
 	  parent_inf = current_inferior ();
@@ -753,17 +752,16 @@ holding the child stopped.  Try \"set de
 	  parent_inf->waiting_for_vfork_done = detach_fork;
 	  parent_inf->pspace->breakpoints_not_allowed = detach_fork;
 
-	  lp = find_lwp_pid (pid_to_ptid (parent_pid));
+	  parent_lp = find_lwp_pid (pid_to_ptid (parent_pid));
 	  gdb_assert (linux_supports_tracefork_flag >= 0);
+
 	  if (linux_supports_tracevforkdone (0))
 	    {
   	      if (debug_linux_nat)
   		fprintf_unfiltered (gdb_stdlog,
   				    "LCFF: waiting for VFORK_DONE on %d\n",
   				    parent_pid);
-
-	      lp->stopped = 1;
-	      lp->resumed = 1;
+	      parent_lp->stopped = 1;
 
 	      /* We'll handle the VFORK_DONE event like any other
 		 event, in target_wait.  */
@@ -812,10 +810,9 @@ holding the child stopped.  Try \"set de
 		 and leave it pending.  The next linux_nat_resume call
 		 will notice a pending event, and bypasses actually
 		 resuming the inferior.  */
-	      lp->status = 0;
-	      lp->waitstatus.kind = TARGET_WAITKIND_VFORK_DONE;
-	      lp->stopped = 0;
-	      lp->resumed = 1;
+	      parent_lp->status = 0;
+	      parent_lp->waitstatus.kind = TARGET_WAITKIND_VFORK_DONE;
+	      parent_lp->stopped = 1;
 
 	      /* If we're in async mode, need to tell the event loop
 		 there's something here to process.  */
@@ -827,7 +824,7 @@ holding the child stopped.  Try \"set de
   else
     {
       struct inferior *parent_inf, *child_inf;
-      struct lwp_info *lp;
+      struct lwp_info *child_lp;
       struct program_space *parent_pspace;
 
       if (info_verbose || debug_linux_nat)
@@ -887,9 +884,8 @@ holding the child stopped.  Try \"set de
 
       inferior_ptid = ptid_build (child_pid, child_pid, 0);
       add_thread (inferior_ptid);
-      lp = add_lwp (inferior_ptid);
-      lp->stopped = 1;
-      lp->resumed = 1;
+      child_lp = add_lwp (inferior_ptid);
+      child_lp->stopped = 1;
 
       /* If this is a vfork child, then the address-space is shared
 	 with the parent.  If we detached from the parent, then we can


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]