+target_require_runnable (void)
+{
+ struct target_ops *t;
+
+ for (t = target_stack; t != NULL; t = t->beneath)
+ {
+ /* If this target knows how to create a new program, then
+ assume we will still be able to after killing the current
+ one. Either killing and mourning will not pop T, or else
+ find_default_run_target will find it again. */
+ if (t->to_create_inferior != NULL)
+ return;
+
+ /* Do not worry about thread_stratum targets that can not
+ create inferiors. Assume they will be pushed again if
+ necessary, and continue to the process_stratum. */
+ if (t->to_stratum == thread_stratum)
+ continue;
+
+ error (_("\
+The \"%s\" target does not support \"run\". Try \"help target\" or \"continue\"."),
+ t->to_shortname);
+ }
+
+ /* This function is only called if the target is running. In that
+ case there should have been a process_stratum target and it
+ should either know how to create inferiors, or not... */
+ internal_error (__FILE__, __LINE__, "No targets found");
+}
+
+/* Look through the list of possible targets for a target that can
+ execute a run or attach command without any other data. This is
+ used to locate the default process stratum.
+
+ If DO_MESG is not NULL, the result is always valid (error() is
+ called for errors); else, return NULL on error. */
+
+static struct target_ops *
+find_default_run_target (char *do_mesg)
+{
+ struct target_ops **t;
+ struct target_ops *runable = NULL;
+ int count;
+
+ count = 0;
+
+ for (t = target_structs; t < target_structs + target_struct_size;
+ ++t)
+ {
+ if ((*t)->to_can_run && target_can_run (*t))
+ {
+ runable = *t;
+ ++count;
+ }
+ }
+
+ if (count != 1)
+ {
+ if (do_mesg)
+ error (_("Don't know how to %s. Try \"help target\"."), do_mesg);
+ else
+ return NULL;
+ }
+
+ return runable;
+}
+
+void
+find_default_attach (struct target_ops *ops, char *args, int from_tty)