aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog12
-rw-r--r--gdb/gdbthread.h14
-rw-r--r--gdb/infrun.c2
-rw-r--r--gdb/linux-nat.c18
-rw-r--r--gdb/remote.c2
-rw-r--r--gdb/thread.c19
6 files changed, 57 insertions, 10 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index ef9dd65..b0c65a2 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,15 @@
+2015-04-07 Pedro Alves <palves@redhat.com>
+
+ * gdbthread.h (ALL_NON_EXITED_THREADS_SAFE): Rename to ...
+ (ALL_THREADS_SAFE): ... this, and don't skip exited threads.
+ (delete_exited_threads): New declaration.
+ * infrun.c (follow_exec): Use ALL_THREADS_SAFE.
+ * linux-nat.c (linux_nat_update_thread_list): New function.
+ (linux_nat_add_target): Install it.
+ * remote.c (remote_update_thread_list): Use ALL_THREADS_SAFE.
+ * thread.c (prune_threads): Use ALL_THREADS_SAFE.
+ (delete_exited_threads): New function.
+
2015-04-07 Pedro Alves <pedro@codesourcery.com>
* infrun.c (resume) <displaced stepping debug output>: Get the
diff --git a/gdb/gdbthread.h b/gdb/gdbthread.h
index bb15717..ff7cec2 100644
--- a/gdb/gdbthread.h
+++ b/gdb/gdbthread.h
@@ -380,13 +380,12 @@ extern struct thread_info *iterate_over_threads (thread_callback_func, void *);
for (T = thread_list; T; T = T->next) \
if ((T)->state != THREAD_EXITED)
-/* Like ALL_NON_EXITED_THREADS, but allows deleting the currently
- iterated thread. */
-#define ALL_NON_EXITED_THREADS_SAFE(T, TMP) \
+/* Traverse all threads, including those that have THREAD_EXITED
+ state. Allows deleting the currently iterated thread. */
+#define ALL_THREADS_SAFE(T, TMP) \
for ((T) = thread_list; \
(T) != NULL ? ((TMP) = (T)->next, 1): 0; \
- (T) = (TMP)) \
- if ((T)->state != THREAD_EXITED)
+ (T) = (TMP))
extern int thread_count (void);
@@ -484,6 +483,11 @@ extern void update_thread_list (void);
extern void prune_threads (void);
+/* Delete threads marked THREAD_EXITED. Unlike prune_threads, this
+ does not consult the target about whether the thread is alive right
+ now. */
+extern void delete_exited_threads (void);
+
/* Return true if PC is in the stepping range of THREAD. */
int pc_in_thread_step_range (CORE_ADDR pc, struct thread_info *thread);
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 607a6e4..d52b8ad 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -1099,7 +1099,7 @@ follow_exec (ptid_t ptid, char *execd_pathname)
them. Deleting them now rather than at the next user-visible
stop provides a nicer sequence of events for user and MI
notifications. */
- ALL_NON_EXITED_THREADS_SAFE (th, tmp)
+ ALL_THREADS_SAFE (th, tmp)
if (ptid_get_pid (th->ptid) == pid && !ptid_equal (th->ptid, ptid))
delete_thread (th->ptid);
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index 04707dc..6c198cf 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -4030,6 +4030,23 @@ linux_nat_thread_alive (struct target_ops *ops, ptid_t ptid)
return linux_thread_alive (ptid);
}
+/* Implement the to_update_thread_list target method for this
+ target. */
+
+static void
+linux_nat_update_thread_list (struct target_ops *ops)
+{
+ if (linux_supports_traceclone ())
+ {
+ /* With support for clone events, we add/delete threads from the
+ list as clone/exit events are processed, so just try deleting
+ exited threads still in the thread list. */
+ delete_exited_threads ();
+ }
+ else
+ prune_threads ();
+}
+
static char *
linux_nat_pid_to_str (struct target_ops *ops, ptid_t ptid)
{
@@ -4854,6 +4871,7 @@ linux_nat_add_target (struct target_ops *t)
t->to_kill = linux_nat_kill;
t->to_mourn_inferior = linux_nat_mourn_inferior;
t->to_thread_alive = linux_nat_thread_alive;
+ t->to_update_thread_list = linux_nat_update_thread_list;
t->to_pid_to_str = linux_nat_pid_to_str;
t->to_thread_name = linux_nat_thread_name;
t->to_has_thread_control = tc_schedlock;
diff --git a/gdb/remote.c b/gdb/remote.c
index 69a67a8..dcd24c4 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -2835,7 +2835,7 @@ remote_update_thread_list (struct target_ops *ops)
/* CONTEXT now holds the current thread list on the remote
target end. Delete GDB-side threads no longer found on the
target. */
- ALL_NON_EXITED_THREADS_SAFE (tp, tmp)
+ ALL_THREADS_SAFE (tp, tmp)
{
for (i = 0;
VEC_iterate (thread_item_t, context.items, i, item);
diff --git a/gdb/thread.c b/gdb/thread.c
index ec398f5..80c8705 100644
--- a/gdb/thread.c
+++ b/gdb/thread.c
@@ -625,16 +625,29 @@ thread_alive (struct thread_info *tp)
void
prune_threads (void)
{
- struct thread_info *tp, *next;
+ struct thread_info *tp, *tmp;
- for (tp = thread_list; tp; tp = next)
+ ALL_THREADS_SAFE (tp, tmp)
{
- next = tp->next;
if (!thread_alive (tp))
delete_thread (tp->ptid);
}
}
+/* See gdbthreads.h. */
+
+void
+delete_exited_threads (void)
+{
+ struct thread_info *tp, *tmp;
+
+ ALL_THREADS_SAFE (tp, tmp)
+ {
+ if (tp->state == THREAD_EXITED)
+ delete_thread (tp->ptid);
+ }
+}
+
/* Disable storing stack temporaries for the thread whose id is
stored in DATA. */