clear_inline_frame_state (tp);
}
-/* Set the TP's state as exited. */
+/* See gdbthread.h. */
-static void
+void
set_thread_exited (thread_info *tp, bool silent)
{
/* Dead threads don't need to step-over. Remove from chain. */
{
highest_thread_num = 0;
- for (thread_info *tp : all_threads_safe ())
- {
- inferior *inf = tp->inf;
-
- if (tp->deletable ())
- delete tp;
- else
- set_thread_exited (tp, 1);
-
- inf->thread_list = NULL;
- }
+ for (inferior *inf : all_inferiors ())
+ inf->clear_thread_list (true);
}
/* Allocate a new thread of inferior INF with target id PTID and add
{
thread_info *tp = new thread_info (inf, ptid);
- if (inf->thread_list == NULL)
- inf->thread_list = tp;
- else
- {
- struct thread_info *last;
-
- for (last = inf->thread_list; last->next != NULL; last = last->next)
- gdb_assert (ptid != last->ptid
- || last->state == THREAD_EXITED);
-
- gdb_assert (ptid != last->ptid
- || last->state == THREAD_EXITED);
-
- last->next = tp;
- }
+ inf->thread_list.push_back (*tp);
return tp;
}
{
gdb_assert (thr != nullptr);
- struct thread_info *tp, *tpprev = NULL;
-
- for (tp = thr->inf->thread_list; tp; tpprev = tp, tp = tp->next)
- if (tp == thr)
- break;
-
- if (!tp)
- return;
-
- set_thread_exited (tp, silent);
+ set_thread_exited (thr, silent);
- if (!tp->deletable ())
+ if (!thr->deletable ())
{
/* Will be really deleted some other time. */
return;
}
- if (tpprev)
- tpprev->next = tp->next;
- else
- tp->inf->thread_list = tp->next;
+ auto it = thr->inf->thread_list.iterator_to (*thr);
+ thr->inf->thread_list.erase (it);
- delete tp;
+ delete thr;
}
/* See gdbthread.h. */
thread_info *
first_thread_of_inferior (inferior *inf)
{
- return inf->thread_list;
+ if (inf->thread_list.empty ())
+ return nullptr;
+
+ return &inf->thread_list.front ();
}
thread_info *
}
else
{
- uiout->field_string ("target-id",
- thread_target_id_str (tp).c_str ());
+ uiout->field_string ("target-id", thread_target_id_str (tp));
}
if (tp->state == THREAD_RUNNING)
int
show_inferior_qualified_tids (void)
{
- return (inferior_list->next != NULL || inferior_list->num != 1);
+ auto inf = inferior_list.begin ();
+ if (inf->num != 1)
+ return true;
+ ++inf;
+ return inf != inferior_list.end ();
}
/* See gdbthread.h. */
/* If the process has no threads, then it must be we have a
process-exit event pending. */
- if (inf->thread_list == NULL)
+ if (inf->thread_list.empty ())
{
targ->threads_executing = true;
return;
c = add_info ("threads", info_threads_command, info_threads_help.c_str ());
set_cmd_completer_handle_brkchars (c, info_threads_command_completer);
- add_prefix_cmd ("thread", class_run, thread_command, _("\
+ cmd_list_element *thread_cmd
+ = add_prefix_cmd ("thread", class_run, thread_command, _("\
Use this command to switch between threads.\n\
The new thread ID must be currently known."),
- &thread_cmd_list, 1, &cmdlist);
+ &thread_cmd_list, 1, &cmdlist);
+
+ add_com_alias ("t", thread_cmd, class_run, 1);
#define THREAD_APPLY_OPTION_HELP "\
Prints per-inferior thread number and target system's thread id\n\
Will display thread ids whose name, target ID, or extra info matches REGEXP."),
&thread_cmd_list);
- add_com_alias ("t", "thread", class_run, 1);
-
add_setshow_boolean_cmd ("thread-events", no_class,
&print_thread_events, _("\
Set printing of thread events (such as thread start and exit)."), _("\