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