Same idea as the previous patch, but for `remove_thread`.
Change-Id: I7e227655be5fcf29a3256e8389eb32051f27882d
Reviewed-By: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
process_info *m_process;
};
-void remove_thread (struct thread_info *thread);
-
/* Return a pointer to the first thread, or NULL if there isn't one. */
struct thread_info *get_first_thread (void);
}
void
-remove_thread (struct thread_info *thread)
+process_info::remove_thread (thread_info *thread)
{
if (thread->btrace != NULL)
target_disable_btrace (thread->btrace);
discard_queued_stop_replies (ptid_of (thread));
- process_info *process = get_thread_process (thread);
- gdb_assert (process != nullptr);
if (current_thread == thread)
switch_to_thread (nullptr);
/* We should not try to remove a thread that was not added. */
- int num_erased = process->thread_map ().erase (thread->id);
+ gdb_assert (thread->process () == this);
+ int num_erased = m_ptid_thread_map.erase (thread->id);
gdb_assert (num_erased > 0);
- process->thread_list ().erase (process->thread_list ().iterator_to (*thread));
+ m_thread_list.erase (m_thread_list.iterator_to (*thread));
}
void *
/* Add a thread with id ID to this process. */
thread_info *add_thread (ptid_t id, void *target_data);
+ /* Remove thread THREAD.
+
+ THREAD must be part of this process' thread list. */
+ void remove_thread (thread_info *thread);
+
private:
/* This processes' thread list, sorted by creation order. */
owning_intrusive_list<thread_info> m_thread_list;
void
linux_process_target::delete_lwp (lwp_info *lwp)
{
- struct thread_info *thr = get_lwp_thread (lwp);
+ thread_info *thr = get_lwp_thread (lwp);
threads_debug_printf ("deleting %ld", lwpid_of (thr));
- remove_thread (thr);
+ thr->process ()->remove_thread (thr);
low_delete_thread (lwp->arch_private);
/* NetBSD does not store an LWP exit status. */
ourstatus->set_thread_exited (0);
- remove_thread (thr);
+ thr->process ()->remove_thread (thr);
}
return wptid;
}
{
windows_thread_info *th = (windows_thread_info *) thread_target_data (thread);
- remove_thread (thread);
+ thread->process ()->remove_thread (thread);
delete th;
}