* infcmd.c (kill_if_already_running): Make static. Use
authorDaniel Jacobowitz <drow@false.org>
Thu, 28 Feb 2008 16:26:18 +0000 (16:26 +0000)
committerDaniel Jacobowitz <drow@false.org>
Thu, 28 Feb 2008 16:26:18 +0000 (16:26 +0000)
target_require_runnable.
* target.c (target_require_runnable): New.
* target.h (target_require_runnable): Declare.

* gdb.texinfo (Starting): Mention always-running targets.
(Target Commands): Add an anchor for load.
(Connecting): Explain continue instead of run.

gdb/ChangeLog
gdb/doc/ChangeLog
gdb/doc/gdb.texinfo
gdb/infcmd.c
gdb/target.c
gdb/target.h

index 50481cecd7fbc62c7fd12e739b4e260557830192..18a4641e27c6485a36199939e2d807927e6d0528 100644 (file)
@@ -1,3 +1,10 @@
+2008-02-28  Daniel Jacobowitz  <dan@codesourcery.com>
+
+       * infcmd.c (kill_if_already_running): Make static.  Use
+       target_require_runnable.
+       * target.c (target_require_runnable): New.
+       * target.h (target_require_runnable): Declare.
+
 2008-02-28  Daniel Jacobowitz  <dan@codesourcery.com>
 
        * frame.c (reinit_frame_cache): Only annotate if frames were
index 1cc9af44f068a0c4e0483b9c2904b45251d22a41..95d94d99d97b29ba8725ee821d6fbecbaf99dc70 100644 (file)
@@ -1,3 +1,9 @@
+2008-02-28  Daniel Jacobowitz  <dan@codesourcery.com>
+
+       * gdb.texinfo (Starting): Mention always-running targets.
+       (Target Commands): Add an anchor for load.
+       (Connecting): Explain continue instead of run.
+
 2008-02-27  Daniel Jacobowitz  <dan@codesourcery.com>
 
        * gdb.texinfo (Debugging Output): Document "set debug timestamp".
index 4f4b6948ce1258faed4fa5401eeaea8a371b6e55..dfc6e813a894dac5ff3bb41c3cb48374de4ec6e7 100644 (file)
@@ -1818,8 +1818,19 @@ argument to @value{GDBN} (@pxref{Invocation, ,Getting In and Out of
 
 If you are running your program in an execution environment that
 supports processes, @code{run} creates an inferior process and makes
-that process run your program.  (In environments without processes,
-@code{run} jumps to the start of your program.)
+that process run your program.  In some environments without processes,
+@code{run} jumps to the start of your program.  Other targets,
+like @samp{remote}, are always running.  If you get an error
+message like this one:
+
+@smallexample
+The "remote" target does not support "run".
+Try "help target" or "continue".
+@end smallexample
+
+@noindent
+then use @code{continue} to run your program.  You may need @code{load}
+first (@pxref{load}).
 
 The execution of a program is affected by certain information it
 receives from its superior.  @value{GDBN} provides ways to specify this
@@ -12669,6 +12680,7 @@ Show the current status of displaying communications between
 
 @kindex load @var{filename}
 @item load @var{filename}
+@anchor{load}
 Depending on what remote debugging facilities are configured into
 @value{GDBN}, the @code{load} command may be available.  Where it exists, it
 is meant to make @var{filename} (an executable) available for debugging
@@ -12847,8 +12859,9 @@ program has already exited, this will have no effect.)
 @end table
 
 Once the connection has been established, you can use all the usual
-commands to examine and change data and to step and continue the
-remote program.
+commands to examine and change data.  The remote program is already
+running; you can use @kbd{step} and @kbd{continue}, and you do not
+need to use @kbd{run}.
 
 @cindex interrupting remote programs
 @cindex remote programs, interrupting
index 972f9e22324df0cc91682cd7456dff1de052aee4..9d889b2bff98285f93ffbfd2691445ffa75a2b49 100644 (file)
@@ -444,11 +444,15 @@ post_create_inferior (struct target_ops *target, int from_tty)
    from the beginning.  Ask the user to confirm that he wants to restart
    the program being debugged when FROM_TTY is non-null.  */
 
-void
+static void
 kill_if_already_running (int from_tty)
 {
   if (! ptid_equal (inferior_ptid, null_ptid) && target_has_execution)
     {
+      /* Bail out before killing the program if we will not be able to
+        restart it.  */
+      target_require_runnable ();
+
       if (from_tty
          && !query ("The program being debugged has been started already.\n\
 Start it from the beginning? "))
index 87ddf249e0a8eeff0ce2c373083fa5538df15467..ceb71b36cde459d360e811b88e00dd34cb9f1d7f 100644 (file)
@@ -1723,6 +1723,41 @@ target_read_description (struct target_ops *target)
   return NULL;
 }
 
+/* Look through the currently pushed targets.  If none of them will
+   be able to restart the currently running process, issue an error
+   message.  */
+
+void
+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.
index 4a2236cbc3a44b19c5f6e8fc9b17cde5f3713794..b7038304cbad2802fa18ddb2ec0d8d8950dd1abb 100644 (file)
@@ -1188,6 +1188,8 @@ extern void initialize_targets (void);
 
 extern void noprocess (void);
 
+extern void target_require_runnable (void);
+
 extern void find_default_attach (char *, int);
 
 extern void find_default_create_inferior (char *, char *, char **, int);
This page took 0.049111 seconds and 4 git commands to generate.