2005-02-11 Andrew Cagney <cagney@gnu.org>
[deliverable/binutils-gdb.git] / gdb / inflow.c
index 66671f7a681bef1715397ec560e47b4de1ad177a..420acb9850b91b13983317cd5e5e3dccce9bc945 100644 (file)
@@ -1,6 +1,7 @@
 /* Low level interface to ptrace, for GDB when running under Unix.
    Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
-   1996, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+   1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004
+   Free Software Foundation, Inc.
 
    This file is part of GDB.
 
 #include <sys/select.h>
 #endif
 
-#ifdef HAVE_TERMIOS
-#define PROCESS_GROUP_TYPE pid_t
-#endif
-
-#ifdef HAVE_TERMIO
-#define PROCESS_GROUP_TYPE int
-#endif
-
-#ifdef HAVE_SGTTY
-#ifdef SHORT_PGRP
-/* This is only used for the ultra.  Does it have pid_t?  */
-#define PROCESS_GROUP_TYPE short
-#else
-#define PROCESS_GROUP_TYPE int
-#endif
-#endif /* sgtty */
+#include "inflow.h"
 
 #ifdef HAVE_SYS_IOCTL_H
 #include <sys/ioctl.h>
 #endif
 
+#ifndef O_NOCTTY
+#define O_NOCTTY 0
+#endif
+
 #if defined (SIGIO) && defined (FASYNC) && defined (FD_SET) && defined (F_SETOWN)
 static void handle_sigio (int);
 #endif
@@ -171,7 +161,7 @@ gdb_has_a_terminal (void)
 #define        OOPSY(what)     \
   if (result == -1)    \
     fprintf_unfiltered(gdb_stderr, "[%s failed in terminal_inferior: %s]\n", \
-           what, strerror (errno))
+           what, safe_strerror (errno))
 
 static void terminal_ours_1 (int);
 
@@ -200,6 +190,23 @@ terminal_init_inferior_with_pgrp (int pgrp)
     }
 }
 
+/* Save the terminal settings again.  This is necessary for the TUI
+   when it switches to TUI or non-TUI mode;  curses changes the terminal
+   and gdb must be able to restore it correctly.  */
+
+void
+terminal_save_ours (void)
+{
+  if (gdb_has_a_terminal ())
+    {
+      /* We could just as well copy our_ttystate (if we felt like adding
+         a new function serial_copy_tty_state).  */
+      if (our_ttystate)
+        xfree (our_ttystate);
+      our_ttystate = serial_get_tty_state (stdin_serial);
+    }
+}
+
 void
 terminal_init_inferior (void)
 {
@@ -221,6 +228,7 @@ void
 terminal_inferior (void)
 {
   if (gdb_has_a_terminal () && terminal_is_ours
+      && inferior_ttystate != NULL
       && inferior_thisrun_terminal == 0)
     {
       int result;
@@ -374,7 +382,7 @@ terminal_ours_1 (int output_only)
             such situations as well.  */
          if (result == -1)
            fprintf_unfiltered (gdb_stderr, "[tcsetpgrp failed in terminal_ours: %s]\n",
-                               strerror (errno));
+                               safe_strerror (errno));
 #endif
 #endif /* termios */
 
@@ -410,24 +418,22 @@ terminal_ours_1 (int output_only)
     }
 }
 
-/* ARGSUSED */
 void
 term_info (char *arg, int from_tty)
 {
   target_terminal_info (arg, from_tty);
 }
 
-/* ARGSUSED */
 void
 child_terminal_info (char *args, int from_tty)
 {
   if (!gdb_has_a_terminal ())
     {
-      printf_filtered ("This GDB does not control a terminal.\n");
+      printf_filtered (_("This GDB does not control a terminal.\n"));
       return;
     }
 
-  printf_filtered ("Inferior's terminal status (currently saved by GDB):\n");
+  printf_filtered (_("Inferior's terminal status (currently saved by GDB):\n"));
 
   /* First the fcntl flags.  */
   {
@@ -513,7 +519,7 @@ new_tty_prefork (char *ttyname)
 void
 new_tty (void)
 {
-  register int tty;
+  int tty;
 
   if (inferior_thisrun_terminal == 0)
     return;
@@ -535,12 +541,7 @@ new_tty (void)
 #endif
 
   /* Now open the specified new terminal.  */
-
-#ifdef USE_O_NOCTTY
   tty = open (inferior_thisrun_terminal, O_RDWR | O_NOCTTY);
-#else
-  tty = open (inferior_thisrun_terminal, O_RDWR);
-#endif
   if (tty == -1)
     {
       print_sys_errmsg (inferior_thisrun_terminal, errno);
@@ -570,7 +571,6 @@ new_tty (void)
 \f
 /* Kill the inferior process.  Make us have no inferior.  */
 
-/* ARGSUSED */
 static void
 kill_command (char *arg, int from_tty)
 {
@@ -579,9 +579,9 @@ kill_command (char *arg, int from_tty)
      some targets don't have processes! */
 
   if (ptid_equal (inferior_ptid, null_ptid))
-    error ("The program is not being run.");
+    error (_("The program is not being run."));
   if (!query ("Kill the program being debugged? "))
-    error ("Not confirmed.");
+    error (_("Not confirmed."));
   target_kill ();
 
   init_thread_list ();         /* Destroy thread info */
@@ -590,18 +590,18 @@ kill_command (char *arg, int from_tty)
      print the state we are left in.  */
   if (target_has_stack)
     {
-      printf_filtered ("In %s,\n", target_longname);
-      if (selected_frame == NULL)
+      printf_filtered (_("In %s,\n"), target_longname);
+      if (deprecated_selected_frame == NULL)
        fputs_filtered ("No selected stack frame.\n", gdb_stdout);
       else
-       print_stack_frame (selected_frame, selected_frame_level, 1);
+       print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC);
     }
+  bfd_cache_close_all ();
 }
 \f
 /* Call set_sigint_trap when you need to pass a signal on to an attached
    process when handling SIGINT */
 
-/* ARGSUSED */
 static void
 pass_signal (int signo)
 {
@@ -681,14 +681,14 @@ void
 set_sigio_trap (void)
 {
   if (target_activity_function)
-    internal_error (__FILE__, __LINE__, "failed internal consistency check");
+    internal_error (__FILE__, __LINE__, _("failed internal consistency check"));
 }
 
 void
 clear_sigio_trap (void)
 {
   if (target_activity_function)
-    internal_error (__FILE__, __LINE__, "failed internal consistency check");
+    internal_error (__FILE__, __LINE__, _("failed internal consistency check"));
 }
 #endif /* No SIGIO.  */
 \f
This page took 0.026922 seconds and 4 git commands to generate.