From 8af756ef818acb875865a21131a30e52cbcf15ce Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Mon, 29 Dec 2014 19:41:06 +0000 Subject: [PATCH] linux-nat.c: always mark execing LWP as resumed A subsequent patch will make the Linux backend's target_wait method pull all events out of the kernel (with waitpid) and store them as pending status in the LWP structure if no pending status was already available. Then, the backend goes over the pending statuses and pick one to report to the core. With that, the existing thread-execl.exp test exposes a bug, like: (gdb) set scheduler-locking on (gdb) PASS: gdb.threads/thread-execl.exp: schedlock on: set scheduler-locking on next FAIL: gdb.threads/thread-execl.exp: schedlock on: get to main in new image (timeout) Recall that when the non-leader thread execs, all threads in the process die, the execing thread changes its pid to the tgid, and then waitpid returns an exec event to the tgid. If GDB didn't resume the leader LWP, then GDB sees an event for an LWP that was supposedly stopped, and thus not marked as resumed. Because the code that picks a pending event to report to the core ignores not-resumed LWPs: /* Return non-zero if LP has a wait status pending. */ static int status_callback (struct lwp_info *lp, void *data) { /* Only report a pending wait status if we pretend that this has indeed been resumed. */ if (!lp->resumed) return 0; the event ends up pending forever, thus the timeout. gdb/ 2015-01-09 Pedro Alves * linux-nat.c (linux_handle_extended_wait) : Set the LWP's 'resumed' flag. --- gdb/ChangeLog | 5 +++++ gdb/linux-nat.c | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 8c7c13b57f..ab18b40b44 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2015-01-09 Pedro Alves + + * linux-nat.c (linux_handle_extended_wait) : + Set the LWP's 'resumed' flag. + 2015-01-09 Pedro Alves * linux-nat.c (linux_resume_one_lwp): New function. diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index 2097cb92b7..e2601e0dee 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -2085,6 +2085,10 @@ linux_handle_extended_wait (struct lwp_info *lp, int status, ourstatus->value.execd_pathname = xstrdup (linux_child_pid_to_exec_file (NULL, pid)); + /* The thread that execed must have been resumed, but, when a + thread execs, it changes its tid to the tgid, and the old + tgid thread might have not been resumed. */ + lp->resumed = 1; return 0; }