5a72cda
Index: ./gdb/linux-nat.c
5a72cda
===================================================================
5a72cda
RCS file: /cvs/src/src/gdb/linux-nat.c,v
5a72cda
retrieving revision 1.64
5a72cda
diff -u -p -r1.64 linux-nat.c
5a72cda
--- ./gdb/linux-nat.c	16 Jun 2007 17:16:25 -0000	1.64
5a72cda
+++ ./gdb/linux-nat.c	18 Jun 2007 12:53:41 -0000
5a72cda
@@ -1109,15 +1109,17 @@ resume_set_callback (struct lwp_info *lp
5a72cda
 }
5a72cda
 
5a72cda
 static void
5a72cda
-linux_nat_resume (ptid_t ptid, int step, enum target_signal signo)
5a72cda
+linux_nat_resume (ptid_t ptid, int step_int, enum target_signal signo)
5a72cda
 {
5a72cda
   struct lwp_info *lp;
5a72cda
   int resume_all;
5a72cda
+  enum resume_step step = step_int;
5a72cda
 
5a72cda
   if (debug_linux_nat)
5a72cda
     fprintf_unfiltered (gdb_stdlog,
5a72cda
 			"LLR: Preparing to %s %s, %s, inferior_ptid %s\n",
5a72cda
-			step ? "step" : "resume",
5a72cda
+			(step == RESUME_STEP_NEEDED
5a72cda
+			 ? "needed" : (step ? "step" : "resume")),
5a72cda
 			target_pid_to_str (ptid),
5a72cda
 			signo ? strsignal (signo) : "0",
5a72cda
 			target_pid_to_str (inferior_ptid));
5a72cda
@@ -2077,6 +2082,9 @@ retry:
5a72cda
 	  /* Check if the thread has exited.  */
5a72cda
 	  if ((WIFEXITED (status) || WIFSIGNALED (status)) && num_lwps > 1)
5a72cda
 	    {
5a72cda
+	      enum resume_step step = lp->step;
5a72cda
+	      pid_t pid = GET_PID (lp->ptid);
5a72cda
+
5a72cda
 	      /* If this is the main thread, we must stop all threads and
5a72cda
 	         verify if they are still alive.  This is because in the nptl
5a72cda
 	         thread model, there is no signal issued for exiting LWPs
5a72cda
@@ -2095,6 +2103,10 @@ retry:
5a72cda
 		fprintf_unfiltered (gdb_stdlog,
5a72cda
 				    "LLW: %s exited.\n",
5a72cda
 				    target_pid_to_str (lp->ptid));
5a72cda
+	      /* Backward compatibility with:
5a72cda
+		 gdb-6.3-step-thread-exit-20050211.patch  */
5a72cda
+	      if (step == RESUME_STEP_USER)
5a72cda
+		printf_unfiltered ("[Stepped over thread exit]\n");
5a72cda
 
5a72cda
 	      exit_lwp (lp);
5a72cda
 
5a72cda
@@ -2105,8 +2117,29 @@ retry:
5a72cda
 	         ignored.  */
5a72cda
 	      if (num_lwps > 0)
5a72cda
 		{
5a72cda
-		  /* Make sure there is at least one thread running.  */
5a72cda
-		  gdb_assert (iterate_over_lwps (running_callback, NULL));
5a72cda
+		  if (step == RESUME_STEP_USER)
5a72cda
+		    {
5a72cda
+		      /* Now stop the closest LWP's ...  */
5a72cda
+		      lp = find_lwp_pid (pid_to_ptid (pid));
5a72cda
+		      if (!lp)
5a72cda
+		        lp = lwp_list;
5a72cda
+		      errno = 0;
5a72cda
+		      ptrace (PTRACE_CONT, GET_LWP (lp->ptid), 0,
5a72cda
+			      (void *) (unsigned long) SIGSTOP);
5a72cda
+		      if (debug_linux_nat)
5a72cda
+			fprintf_unfiltered (gdb_stdlog,
5a72cda
+					    "PTRACE_CONT %s, 0, 0 (%s)\n",
5a72cda
+					    target_pid_to_str (lp->ptid),
5a72cda
+					    errno ? safe_strerror (errno)
5a72cda
+						  : "OK");
5a72cda
+		      /* Avoid the silent `delayed SIGSTOP' handling.  */
5a72cda
+		      lp->signalled = 0;
5a72cda
+		    }
5a72cda
+		  else
5a72cda
+		    {
5a72cda
+		      /* Make sure there is at least one thread running.  */
5a72cda
+		      gdb_assert (iterate_over_lwps (running_callback, NULL));
5a72cda
+		    }
5a72cda
 
5a72cda
 		  /* Discard the event.  */
5a72cda
 		  status = 0;