diff --git a/gdb/gdbthread.h b/gdb/gdbthread.h index b3052b28d1a..1bdbf621982 100644 --- a/gdb/gdbthread.h +++ b/gdb/gdbthread.h @@ -796,7 +796,14 @@ void thread_change_ptid (process_stratum_target *targ, using for_each_thread_callback_ftype = gdb::function_view; -/* Call CALLBACK once for each known thread. */ +/* Call CALLBACK once for each known thread. + + CALLBACK must not delete the thread. To delete threads, use: + + for (thread_info &t : all_threads_safe ()) + if (some_condition ()) + delete &t; +*/ extern void for_each_thread (for_each_thread_callback_ftype callback); diff --git a/gdb/thread.c b/gdb/thread.c index 4f62ca280cd..110e58a70aa 100644 --- a/gdb/thread.c +++ b/gdb/thread.c @@ -605,7 +605,7 @@ find_thread_by_handle (gdb::array_view handle, void for_each_thread (for_each_thread_callback_ftype callback) { - for (thread_info &tp : all_threads_safe ()) + for (thread_info &tp : all_threads ()) callback (&tp); }