gdb/gdb-6.6-step-thread-exit.patch
2008-12-14 14:05:20 +00:00

62 lines
2.1 KiB
Diff

Index: gdb-6.8.50.20081128/gdb/linux-nat.c
===================================================================
--- gdb-6.8.50.20081128.orig/gdb/linux-nat.c 2008-12-04 01:44:26.000000000 +0100
+++ gdb-6.8.50.20081128/gdb/linux-nat.c 2008-12-04 10:21:32.000000000 +0100
@@ -1661,15 +1661,17 @@ resume_set_callback (struct lwp_info *lp
}
static void
-linux_nat_resume (ptid_t ptid, int step, enum target_signal signo)
+linux_nat_resume (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));
@@ -2586,6 +2588,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
@@ -2609,6 +2614,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. */