+/* Wrapper around get_first_inferior to return a struct process_info *. */
+
+struct process_info *
+get_first_process (void)
+{
+ return (struct process_info *) get_first_inferior (&all_processes);
+}
+
+/* Return non-zero if INF, a struct process_info, was started by us,
+ i.e. not attached to. */
+
+static int
+started_inferior_callback (struct inferior_list_entry *entry, void *args)
+{
+ struct process_info *process = (struct process_info *) entry;
+
+ return ! process->attached;
+}
+
+/* Return non-zero if there are any inferiors that we have created
+ (as opposed to attached-to). */
+
+int
+have_started_inferiors_p (void)
+{
+ return (find_inferior (&all_processes, started_inferior_callback, NULL)
+ != NULL);
+}
+
+/* Return non-zero if INF, a struct process_info, was attached to. */
+
+static int
+attached_inferior_callback (struct inferior_list_entry *entry, void *args)
+{
+ struct process_info *process = (struct process_info *) entry;
+
+ return process->attached;
+}
+
+/* Return non-zero if there are any inferiors that we have attached to. */
+
+int
+have_attached_inferiors_p (void)
+{
+ return (find_inferior (&all_processes, attached_inferior_callback, NULL)
+ != NULL);
+}
+
+struct process_info *
+get_thread_process (const struct thread_info *thread)
+{
+ int pid = ptid_get_pid (thread->entry.id);
+ return find_process_pid (pid);
+}
+
+struct process_info *
+current_process (void)
+{
+ gdb_assert (current_thread != NULL);
+ return get_thread_process (current_thread);
+}
+
+static void
+do_restore_current_thread_cleanup (void *arg)
+{
+ current_thread = (struct thread_info *) arg;
+}
+
+struct cleanup *
+make_cleanup_restore_current_thread (void)
+{
+ return make_cleanup (do_restore_current_thread_cleanup, current_thread);
+}
+
+/* See common/common-gdbthread.h. */
+