Revert call to bfd_cache_close().
[deliverable/binutils-gdb.git] / gdb / serial.c
index 99c5a54f8323ac0d3aa2735fb0ffd0dc2138594b..1719f7d6c88789366779431c1a8b71ca624a08d9 100644 (file)
@@ -1,5 +1,7 @@
 /* Generic serial interface routines
-   Copyright 1992, 1993, 1996, 1997, 1999 Free Software Foundation, Inc.
+
+   Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+   Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -46,16 +48,16 @@ static serial_t scb_base;
    suitable for playback by gdbserver. */
 
 static char *serial_logfile = NULL;
-static GDB_FILE *serial_logfp = NULL;
+static struct ui_file *serial_logfp = NULL;
 
 static struct serial_ops *serial_interface_lookup (char *);
-static void serial_logchar (struct gdb_file *stream, int ch_type, int ch, int timeout);
-static char logbase_hex[] = "hex";
-static char logbase_octal[] = "octal";
-static char logbase_ascii[] = "ascii";
-static char *logbase_enums[] =
+static void serial_logchar (struct ui_file *stream, int ch_type, int ch, int timeout);
+static const char logbase_hex[] = "hex";
+static const char logbase_octal[] = "octal";
+static const char logbase_ascii[] = "ascii";
+static const char *logbase_enums[] =
 {logbase_hex, logbase_octal, logbase_ascii, NULL};
-static char *serial_logbase = logbase_ascii;
+static const char *serial_logbase = logbase_ascii;
 \f
 
 
@@ -68,7 +70,7 @@ static int serial_current_type = 0;
 #define SERIAL_BREAK 1235
 
 static void
-serial_logchar (struct gdb_file *stream, int ch_type, int ch, int timeout)
+serial_logchar (struct ui_file *stream, int ch_type, int ch, int timeout)
 {
   if (ch_type != serial_current_type)
     {
@@ -209,11 +211,11 @@ serial_open (const char *name)
 
   if (scb->ops->open (scb, open_name))
     {
-      free (scb);
+      xfree (scb);
       return NULL;
     }
 
-  scb->name = strsave (name);
+  scb->name = xstrdup (name);
   scb->next = scb_base;
   scb->refcnt = 1;
   scb->debug_p = 0;
@@ -288,7 +290,7 @@ do_serial_close (serial_t scb, int really_close)
       serial_current_type = 0;
 
       /* XXX - What if serial_logfp == gdb_stdout or gdb_stderr? */
-      gdb_fclose (&serial_logfp);
+      ui_file_delete (serial_logfp);
       serial_logfp = NULL;
     }
 
@@ -310,7 +312,7 @@ do_serial_close (serial_t scb, int really_close)
     scb->ops->close (scb);
 
   if (scb->name)
-    free (scb->name);
+    xfree (scb->name);
 
   if (scb_base == scb)
     scb_base = scb_base->next;
@@ -324,7 +326,7 @@ do_serial_close (serial_t scb, int really_close)
        break;
       }
 
-  free (scb);
+  xfree (scb);
 }
 
 void
@@ -344,6 +346,12 @@ serial_readchar (serial_t scb, int timeout)
 {
   int ch;
 
+  /* FIXME: cagney/1999-10-11: Don't enable this check until the ASYNC
+     code is finished. */
+  if (0 && SERIAL_IS_ASYNC_P (scb) && timeout < 0)
+    internal_error (__FILE__, __LINE__,
+                   "serial_readchar: blocking read in async mode");
+
   ch = scb->ops->readchar (scb, timeout);
   if (serial_logfp != NULL)
     {
@@ -389,10 +397,10 @@ serial_printf (serial_t desc, const char *format,...)
   char *buf;
   va_start (args, format);
 
-  vasprintf (&buf, format, args);
+  xvasprintf (&buf, format, args);
   SERIAL_WRITE (desc, buf, strlen (buf));
 
-  free (buf);
+  xfree (buf);
   va_end (args);
 }
 
@@ -444,7 +452,7 @@ serial_set_tty_state (serial_t scb, serial_ttystate ttystate)
 void
 serial_print_tty_state (serial_t scb,
                        serial_ttystate ttystate,
-                       struct gdb_file *stream)
+                       struct ui_file *stream)
 {
   scb->ops->print_tty_state (scb, ttystate, stream);
 }
@@ -501,7 +509,8 @@ deprecated_serial_fd (serial_t scb)
      called? */
   if (scb->fd < 0)
     {
-      internal_error ("serial: FD not valid");
+      internal_error (__FILE__, __LINE__,
+                     "serial: FD not valid");
     }
   return scb->fd; /* sigh */
 }
@@ -546,7 +555,7 @@ cleanup_tty (serial_ttystate ttystate)
 {
   printf_unfiltered ("\r\n[Exiting connect mode]\r\n");
   SERIAL_SET_TTY_STATE (tty_desc, ttystate);
-  free (ttystate);
+  xfree (ttystate);
   SERIAL_CLOSE (tty_desc);
 }
 
@@ -662,16 +671,16 @@ by gdbserver.",
 
   add_show_from_set
     (add_set_enum_cmd ("remotelogbase", no_class,
-                      logbase_enums, (char *) &serial_logbase,
+                      logbase_enums, &serial_logbase,
                       "Set numerical base for remote session logging",
                       &setlist),
      &showlist);
 
-  add_show_from_set (add_set_cmd ("serialdebug",
+  add_show_from_set (add_set_cmd ("serial",
                                  class_maintenance,
                                  var_zinteger,
                                  (char *)&global_serial_debug_p,
                                  "Set serial debugging.\n\
-When non-zero, serial port debugging is enabled.", &setlist),
-                    &showlist);
+When non-zero, serial port debugging is enabled.", &setdebuglist),
+                    &showdebuglist);
 }
This page took 0.024957 seconds and 4 git commands to generate.