* configure: Ignore new autoconf configure options.
[binutils-gdb.git] / gdb / inftarg.c
index 2c110ab5b32c2c8693a812ff80fe3e292bee8414..eff9969c64e7f91ef351345c89d064ba52939472 100644 (file)
@@ -31,12 +31,10 @@ static void
 child_prepare_to_store PARAMS ((void));
 
 #ifndef CHILD_WAIT
-static int
-child_wait PARAMS ((int, int *));
+static int child_wait PARAMS ((int, struct target_waitstatus *));
 #endif /* CHILD_WAIT */
 
-static void
-child_open PARAMS ((char *, int));
+static void child_open PARAMS ((char *, int));
 
 static void
 child_files_info PARAMS ((struct target_ops *));
@@ -53,8 +51,7 @@ ptrace_me PARAMS ((void));
 static void
 ptrace_him PARAMS ((int));
 
-static void
-child_create_inferior PARAMS ((char *, char *, char **));
+static void child_create_inferior PARAMS ((char *, char *, char **));
 
 static void
 child_mourn_inferior PARAMS ((void));
@@ -70,22 +67,27 @@ extern struct target_ops child_ops;
 #ifndef CHILD_WAIT
 
 /* Wait for child to do something.  Return pid of child, or -1 in case
-   of error; store status through argument pointer STATUS.  */
+   of error; store status through argument pointer OURSTATUS.  */
 
 static int
-child_wait (pid, status)
+child_wait (pid, ourstatus)
      int pid;
-     int *status;
+     struct target_waitstatus *ourstatus;
 {
   int save_errno;
+  int status;
 
   do {
     if (attach_flag)
       set_sigint_trap();       /* Causes SIGINT to be passed on to the
                                   attached process. */
-    pid = wait (status);
+    set_sigio_trap ();
+
+    pid = wait (&status);
     save_errno = errno;
 
+    clear_sigio_trap ();
+
     if (attach_flag)
       clear_sigint_trap();
 
@@ -93,12 +95,15 @@ child_wait (pid, status)
       {
        if (save_errno == EINTR)
          continue;
-       fprintf (stderr, "Child process unexpectedly missing: %s.\n",
+       fprintf_unfiltered (gdb_stderr, "Child process unexpectedly missing: %s.\n",
                 safe_strerror (save_errno));
-       *status = 42;   /* Claim it exited with signal 42 */
+       /* Claim it exited with unknown signal.  */
+       ourstatus->kind = TARGET_WAITKIND_SIGNALLED;
+       ourstatus->value.sig = TARGET_SIGNAL_UNKNOWN;
         return -1;
       }
   } while (pid != inferior_pid); /* Some other child died or stopped */
+  store_waitstatus (ourstatus, status);
   return pid;
 }
 #endif /* CHILD_WAIT */
@@ -130,12 +135,12 @@ child_attach (args, from_tty)
        exec_file = (char *) get_exec_file (0);
 
        if (exec_file)
-         printf ("Attaching to program `%s', %s\n", exec_file,
+         printf_unfiltered ("Attaching to program `%s', %s\n", exec_file,
                  target_pid_to_str (pid));
        else
-         printf ("Attaching to %s\n", target_pid_to_str (pid));
+         printf_unfiltered ("Attaching to %s\n", target_pid_to_str (pid));
 
-       fflush (stdout);
+       gdb_flush (gdb_stdout);
       }
 
     attach (pid);
@@ -168,9 +173,9 @@ child_detach (args, from_tty)
        char *exec_file = get_exec_file (0);
        if (exec_file == 0)
          exec_file = "";
-       printf ("Detaching from program: %s %s\n", exec_file,
+       printf_unfiltered ("Detaching from program: %s %s\n", exec_file,
                target_pid_to_str (inferior_pid));
-       fflush (stdout);
+       gdb_flush (gdb_stdout);
       }
     if (args)
       siggnal = atoi (args);
@@ -204,7 +209,7 @@ static void
 child_files_info (ignore)
      struct target_ops *ignore;
 {
-  printf ("\tUsing the running image of %s %s.\n",
+  printf_unfiltered ("\tUsing the running image of %s %s.\n",
          attach_flag? "attached": "child", target_pid_to_str (inferior_pid));
 }
 
@@ -235,6 +240,13 @@ ptrace_him (pid)
      int pid;
 {
   push_target (&child_ops);
+
+#ifdef START_INFERIOR_TRAPS_EXPECTED
+  startup_inferior (START_INFERIOR_TRAPS_EXPECTED);
+#else
+  /* One trap to exec the shell, one to exec the program being debugged.  */
+  startup_inferior (2);
+#endif
 }
 
 /* Start an inferior Unix child process and sets inferior_pid to its pid.
@@ -248,10 +260,10 @@ child_create_inferior (exec_file, allargs, env)
      char *allargs;
      char **env;
 {
-  fork_inferior (exec_file, allargs, env, ptrace_me, ptrace_him);
+  fork_inferior (exec_file, allargs, env, ptrace_me, ptrace_him, NULL);
   /* We are at the first instruction we care about.  */
   /* Pedal to the metal... */
-  proceed ((CORE_ADDR) -1, 0, 0);
+  proceed ((CORE_ADDR) -1, TARGET_SIGNAL_0, 0);
 }
 
 static void