keiths / rpms / gdb

Forked from rpms/gdb 5 days ago
Clone
1592379
Index: gdb-6.8.50.20090226/gdb/linux-nat.c
407ebe9
===================================================================
1592379
--- gdb-6.8.50.20090226.orig/gdb/linux-nat.c	2009-02-27 00:04:35.000000000 +0100
1592379
+++ gdb-6.8.50.20090226/gdb/linux-nat.c	2009-02-27 07:51:44.000000000 +0100
1592379
@@ -1790,15 +1790,17 @@ resume_set_callback (struct lwp_info *lp
5a72cda
 
5a72cda
 static void
1592379
 linux_nat_resume (struct target_ops *ops,
1592379
-		  ptid_t ptid, int step, enum target_signal signo)
1592379
+		  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));
1592379
@@ -2740,6 +2742,9 @@ linux_nat_filter_event (int lwpid, int s
407ebe9
   /* Check if the thread has exited.  */
407ebe9
   if ((WIFEXITED (status) || WIFSIGNALED (status)) && num_lwps > 1)
407ebe9
     {
407ebe9
+      enum resume_step step = lp->step;
407ebe9
+      pid_t pid = GET_PID (lp->ptid);
5a72cda
+
407ebe9
       /* If this is the main thread, we must stop all threads and
407ebe9
 	 verify if they are still alive.  This is because in the nptl
407ebe9
 	 thread model, there is no signal issued for exiting LWPs
1592379
@@ -2763,6 +2768,26 @@ linux_nat_filter_event (int lwpid, int s
5a72cda
 
407ebe9
       exit_lwp (lp);
5a72cda
 
407ebe9
+      if (step == RESUME_STEP_USER)
407ebe9
+	{
407ebe9
+	  /* Now stop the closest LWP's ...  */
407ebe9
+	  lp = find_lwp_pid (pid_to_ptid (pid));
407ebe9
+	  if (!lp)
407ebe9
+	    lp = lwp_list;
407ebe9
+	  gdb_assert (lp != NULL);
407ebe9
+	  errno = 0;
407ebe9
+	  ptrace (PTRACE_CONT, GET_LWP (lp->ptid), 0,
407ebe9
+		  (void *) (unsigned long) SIGSTOP);
407ebe9
+	  if (debug_linux_nat)
407ebe9
+	    fprintf_unfiltered (gdb_stdlog,
407ebe9
+				"PTRACE_CONT %s, 0, 0 (%s)\n",
407ebe9
+				target_pid_to_str (lp->ptid),
407ebe9
+				errno ? safe_strerror (errno)
407ebe9
+				      : "OK");
407ebe9
+	  /* Avoid the silent `delayed SIGSTOP' handling.  */
407ebe9
+	  lp->signalled = 0;
407ebe9
+	}
407ebe9
+
407ebe9
       /* If there is at least one more LWP, then the exit signal was
407ebe9
 	 not the end of the debugged application and should be
407ebe9
 	 ignored.  */