};
void remove_thread (struct thread_info *thread);
-struct thread_info *add_thread (ptid_t ptid, void *target_data);
/* Return a pointer to the first thread, or NULL if there isn't one. */
Empty if not specified. */
static std::string current_inferior_cwd;
-struct thread_info *
-add_thread (ptid_t thread_id, void *target_data)
+thread_info *
+process_info::add_thread (ptid_t id, void *target_data)
{
- process_info *process = find_process_pid (thread_id.pid ());
- gdb_assert (process != nullptr);
-
- auto &new_thread
- = process->thread_list ().emplace_back (thread_id, process, target_data);
- bool inserted
- = process->thread_map ().insert ({thread_id, &new_thread}).second;
+ auto &new_thread = m_thread_list.emplace_back (id, this, target_data);
+ bool inserted = m_ptid_thread_map.insert ({ id, &new_thread }).second;
/* A thread with this ptid should not exist in the map yet. */
gdb_assert (inserted);
/* Invoke FUNC for each thread. */
void for_each_thread (gdb::function_view<void (thread_info *)> func);
+ /* Add a thread with id ID to this process. */
+ thread_info *add_thread (ptid_t id, void *target_data);
+
private:
/* This processes' thread list, sorted by creation order. */
owning_intrusive_list<thread_info> m_thread_list;
{
lwp_info *lwp = new lwp_info;
- lwp->thread = add_thread (ptid, lwp);
+ lwp->thread = find_process_pid (ptid.pid ())->add_thread (ptid, lwp);
low_new_thread (lwp);
ourstatus->set_spurious ();
else
{
- add_thread (wptid, NULL);
+ find_process_pid (wptid.pid ())->add_thread (wptid, nullptr);
ourstatus->set_thread_created ();
}
return wptid;
that was not fully initialized during the attach stage. */
if (wptid.lwp () != 0 && !find_thread_ptid (wptid)
&& ourstatus->kind () != TARGET_WAITKIND_THREAD_EXITED)
- add_thread (wptid, nullptr);
+ find_process_pid (wptid.pid ())->add_thread (wptid, nullptr);
switch (ourstatus->kind ())
{
#endif
th = new windows_thread_info (tid, h, base);
- add_thread (ptid, th);
+ find_process_pid (pid)->add_thread (ptid, th);
if (the_low_target.thread_added != NULL)
(*the_low_target.thread_added) (th);