2015-03-24 Pedro Alves <palves@redhat.com>
+ * thread.c (thread_apply_all_command): Take exited threads into
+ account.
+
+2015-03-24 Pedro Alves <palves@redhat.com>
+
* infrun.c (resume, proceed): Mention
switch_back_to_stepped_thread, not switch_back_to_stepping.
2015-03-24 Pedro Alves <palves@redhat.com>
+ * gdb.threads/no-unwaited-for-left.exp: Test "thread apply all".
+
+2015-03-24 Pedro Alves <palves@redhat.com>
+
* gdb.threads/schedlock.exp (test_step): No longer expect that
"set scheduler-locking step" with "next" over a function call runs
threads unlocked.
gdb_test "info threads" \
"\r\n\[ \t\]*Id\[ \t\]+Target\[ \t\]+Id\[ \t\]+Frame\[ \t\]*\r\n *3 *Thread \[^\r\n\]* \[^\r\n\]*.*The current thread <Thread ID 1> has terminated.*" \
"only thread 3 left, main thread terminated"
+
+# Make sure thread apply all works when we have exited threads in the
+# list.
+gdb_test "thread apply all print 999" " = 999" "thread apply all with exited thread"
execute_command. */
saved_cmd = xstrdup (cmd);
make_cleanup (xfree, saved_cmd);
- tc = thread_count ();
- if (tc)
+ /* Note this includes exited threads. */
+ tc = thread_count ();
+ if (tc != 0)
{
struct thread_info **tp_array;
struct thread_info *tp;
command. */
tp_array = xmalloc (sizeof (struct thread_info *) * tc);
make_cleanup (xfree, tp_array);
- ta_cleanup.tp_array = tp_array;
- ta_cleanup.count = tc;
ALL_NON_EXITED_THREADS (tp)
{
tp->refcount++;
i++;
}
+ /* Because we skipped exited threads, we may end up with fewer
+ threads in the array than the total count of threads. */
+ gdb_assert (i <= tc);
- qsort (tp_array, i, sizeof (*tp_array), tp_array_compar);
+ if (i != 0)
+ qsort (tp_array, i, sizeof (*tp_array), tp_array_compar);
+ ta_cleanup.tp_array = tp_array;
+ ta_cleanup.count = i;
make_cleanup (set_thread_refcount, &ta_cleanup);
for (k = 0; k != i; k++)