2008-11-12 Tristan Gingold <gingold@adacore.com>
[binutils-gdb.git] / gdb / infcall.c
index 5cc068a9cca21bf2a591dc9432f8d281b0a63eab..aa3bee0999ad3e22f8d5ef841a07d8901341b8db 100644 (file)
@@ -699,6 +699,16 @@ call_function_by_hand (struct value *function, int nargs, struct value **args)
     discard_cleanups (old_cleanups);
   }
 
+  if (! target_has_execution)
+    {
+      /* If we try to restore the inferior status (via the cleanup),
+        we'll crash as the inferior is no longer running.  */
+      discard_cleanups (inf_status_cleanup);
+      discard_inferior_status (inf_status);
+      error (_("\
+The program being debugged exited while in a function called from GDB."));
+    }
+
   if (stopped_by_random_signal || !stop_stack_dummy)
     {
       /* Find the name of the function we're about to complain about.  */