* inftarg.c (child_thread_alive): New function to see if a
[deliverable/binutils-gdb.git] / gdb / inflow.c
index f3757d5e3a98b760a12ecbc917770c4bc3764c09..353c6c4ee3f417c72515397fdb3f257c5ef6ed4c 100644 (file)
@@ -57,12 +57,6 @@ kill_command PARAMS ((char *, int));
 
 static void
 terminal_ours_1 PARAMS ((int));
-
-/* Nonzero if we are debugging an attached outside process
-   rather than an inferior.  */
-
-int attach_flag;
-
 \f
 /* Record terminal status separately for debugger and inferior.  */
 
@@ -176,7 +170,13 @@ terminal_init_inferior ()
        free (inferior_ttystate);
       inferior_ttystate = SERIAL_GET_TTY_STATE (stdin_serial);
 #ifdef PROCESS_GROUP_TYPE
-#ifdef PIDGET                  /* XXX Lynx */
+#ifdef PIDGET
+      /* This is for Lynx, and should be cleaned up by having Lynx be
+        a separate debugging target with a version of
+        target_terminal_init_inferior which passes in the process
+        group to a generic routine which does all the work (and the
+        non-threaded child_terminal_init_inferior can just pass in
+        inferior_pid to the same routine).  */
       inferior_process_group = PIDGET (inferior_pid);
 #else
       inferior_process_group = inferior_pid;
@@ -318,7 +318,10 @@ terminal_ours_1 (output_only)
 
       /* Here we used to set ICANON in our ttystate, but I believe this
         was an artifact from before when we used readline.  Readline sets
-        the tty state when it needs to.  */
+        the tty state when it needs to.
+        FIXME-maybe: However, query() expects non-raw mode and doesn't
+        use readline.  Maybe query should use readline (on the other hand,
+        this only matters for HAVE_SGTTY, not termio or termios, I think).  */
 
       /* Set tty state to our_ttystate.  We don't change in our out of raw
         mode, to avoid flushing input.  We need to do the same thing
@@ -326,6 +329,7 @@ terminal_ours_1 (output_only)
         terminal_is_ours and terminal_is_ours_for_output flags.  It's OK,
         though, since readline will deal with raw mode when/if it needs to.
         */
+
       SERIAL_NOFLUSH_SET_TTY_STATE (stdin_serial, our_ttystate,
                                    inferior_ttystate);
 
@@ -529,8 +533,7 @@ kill_command (arg, from_tty)
      char *arg;
      int from_tty;
 {
-  /* Shouldn't this be target_has_execution?  FIXME.  */
-  if (inferior_pid == 0)
+  if (!target_has_execution)
     error ("The program is not being run.");
   if (!query ("Kill the program being debugged? "))
     error ("Not confirmed.");
@@ -541,36 +544,13 @@ kill_command (arg, from_tty)
   /* Killing off the inferior can leave us with a core file.  If so,
      print the state we are left in.  */
   if (target_has_stack) {
-    printf_filtered ("In %s,\n", current_target->to_longname);
+    printf_filtered ("In %s,\n", target_longname);
     if (selected_frame == NULL)
       fputs_filtered ("No selected stack frame.\n", gdb_stdout);
     else
       print_stack_frame (selected_frame, selected_frame_level, 1);
   }
 }
-
-/* The inferior process has died.  Long live the inferior!  */
-
-void
-generic_mourn_inferior ()
-{
-  inferior_pid = 0;
-  attach_flag = 0;
-  breakpoint_init_inferior ();
-  registers_changed ();
-
-#ifdef CLEAR_DEFERRED_STORES
-  /* Delete any pending stores to the inferior... */
-  CLEAR_DEFERRED_STORES;
-#endif
-
-  reopen_exec_file ();
-  reinit_frame_cache ();
-
-  /* It is confusing to the user for ignore counts to stick around
-     from previous runs of the inferior.  So clear them.  */
-  breakpoint_clear_ignore_counts ();
-}
 \f
 /* Call set_sigint_trap when you need to pass a signal on to an attached
    process when handling SIGINT */
@@ -597,8 +577,67 @@ clear_sigint_trap()
   signal (SIGINT, osig);
 }
 \f
+#if defined (SIGIO) && defined (FASYNC) && defined (FD_SET) && defined (F_SETOWN)
+static void (*old_sigio) ();
+
+static void
+handle_sigio (signo)
+     int signo;
+{
+  int numfds;
+  fd_set readfds;
+
+  signal (SIGIO, handle_sigio);
+
+  FD_ZERO (&readfds);
+  FD_SET (target_activity_fd, &readfds);
+  numfds = select (target_activity_fd + 1, &readfds, NULL, NULL, NULL);
+  if (numfds >= 0 && FD_ISSET (target_activity_fd, &readfds))
+    {
+      if ((*target_activity_function) ())
+       kill (inferior_pid, SIGINT);
+    }
+}
 
-int job_control;
+static int old_fcntl_flags;
+
+void
+set_sigio_trap ()
+{
+  if (target_activity_function)
+    {
+      old_sigio = (void (*) ()) signal (SIGIO, handle_sigio);
+      fcntl (target_activity_fd, F_SETOWN, getpid()); 
+      old_fcntl_flags = fcntl (target_activity_fd, F_GETFL, 0);
+      fcntl (target_activity_fd, F_SETFL, old_fcntl_flags | FASYNC);
+    }
+}
+
+void
+clear_sigio_trap ()
+{
+  if (target_activity_function)
+    {
+      signal (SIGIO, old_sigio);
+      fcntl (target_activity_fd, F_SETFL, old_fcntl_flags);
+    }
+}
+#else /* No SIGIO.  */
+void
+set_sigio_trap ()
+{
+  if (target_activity_function)
+    abort ();
+}
+
+void
+clear_sigio_trap ()
+{
+  if (target_activity_function)
+    abort ();
+}
+#endif /* No SIGIO.  */
+\f
 
 /* This is here because this is where we figure out whether we (probably)
    have job control.  Just using job_control only does part of it because
@@ -613,6 +652,7 @@ int
 gdb_setpgid ()
 {
   int retval = 0;
+
   if (job_control)
     {
 #if defined (NEED_POSIX_SETPGID) || defined (HAVE_TERMIOS)
This page took 0.024759 seconds and 4 git commands to generate.