return (struct thread_info *) find_inferior_id (&all_threads, ptid);
}
+/* Predicate function for matching thread entry's pid to the given
+ pid value passed by address in ARGS. */
+
+static int
+thread_pid_matches_callback (struct inferior_list_entry *entry, void *args)
+{
+ return (ptid_get_pid (entry->id) == *(pid_t *)args);
+}
+
+/* Find a thread associated with the given PROCESS, or NULL if no
+ such thread exists. */
+
+static struct thread_info *
+find_thread_process (const struct process_info *const process)
+{
+ pid_t pid = ptid_get_pid (ptid_of (process));
+
+ return (struct thread_info *)
+ find_inferior (&all_threads, thread_pid_matches_callback, &pid);
+}
+
ptid_t
gdb_id_to_thread_id (ptid_t gdb_id)
{
discard_queued_stop_replies (ptid_of (thread));
remove_inferior (&all_threads, (struct inferior_list_entry *) thread);
free_one_thread (&thread->entry);
+ if (current_thread == thread)
+ current_thread = NULL;
}
/* Return a pointer to the first inferior in LIST, or NULL if there isn't one.
{
clear_symbol_cache (&process->symbol_cache);
free_all_breakpoints (process);
+ gdb_assert (find_thread_process (process) == NULL);
remove_inferior (&all_processes, &process->entry);
free (process);
}