+void
+set_desired_inferior (int use_general)
+{
+ struct thread_info *found;
+
+ if (use_general == 1)
+ found = find_thread_ptid (general_thread);
+ else
+ {
+ found = NULL;
+
+ /* If we are continuing any (all) thread(s), use step_thread
+ to decide which thread to step and/or send the specified
+ signal to. */
+ if ((!ptid_equal (step_thread, null_ptid)
+ && !ptid_equal (step_thread, minus_one_ptid))
+ && (ptid_equal (cont_thread, null_ptid)
+ || ptid_equal (cont_thread, minus_one_ptid)))
+ found = find_thread_ptid (step_thread);
+
+ if (found == NULL)
+ found = find_thread_ptid (cont_thread);
+ }
+
+ if (found == NULL)
+ current_inferior = (struct thread_info *) all_threads.head;
+ else
+ current_inferior = found;
+}
+
+int
+read_inferior_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len)
+{
+ int res;
+ res = (*the_target->read_memory) (memaddr, myaddr, len);
+ check_mem_read (memaddr, myaddr, len);
+ return res;
+}
+
+int
+write_inferior_memory (CORE_ADDR memaddr, const unsigned char *myaddr,
+ int len)
+{
+ /* Lacking cleanups, there is some potential for a memory leak if the
+ write fails and we go through error(). Make sure that no more than
+ one buffer is ever pending by making BUFFER static. */
+ static unsigned char *buffer = 0;
+ int res;
+
+ if (buffer != NULL)
+ free (buffer);
+
+ buffer = xmalloc (len);
+ memcpy (buffer, myaddr, len);
+ check_mem_write (memaddr, buffer, len);
+ res = (*the_target->write_memory) (memaddr, buffer, len);
+ free (buffer);
+ buffer = NULL;
+
+ return res;
+}
+
+ptid_t
+mywait (ptid_t ptid, struct target_waitstatus *ourstatus, int options,
+ int connected_wait)
+{
+ ptid_t ret;
+
+ if (connected_wait)
+ server_waiting = 1;
+
+ ret = (*the_target->wait) (ptid, ourstatus, options);
+
+ if (ourstatus->kind == TARGET_WAITKIND_EXITED)
+ fprintf (stderr,
+ "\nChild exited with status %d\n", ourstatus->value.sig);
+ else if (ourstatus->kind == TARGET_WAITKIND_SIGNALLED)
+ fprintf (stderr, "\nChild terminated with signal = 0x%x (%s)\n",
+ target_signal_to_host (ourstatus->value.sig),
+ target_signal_to_name (ourstatus->value.sig));
+
+ if (connected_wait)
+ server_waiting = 0;
+
+ return ret;
+}
+
+int
+start_non_stop (int nonstop)
+{
+ if (the_target->start_non_stop == NULL)
+ {
+ if (nonstop)
+ return -1;
+ else
+ return 0;
+ }
+
+ return (*the_target->start_non_stop) (nonstop);
+}
+