(mi_cmd_stack_list_frames, mi_cmd_stack_info_depth):
[deliverable/binutils-gdb.git] / gdb / serial.c
index 38e1e0e0cfd42f127a99e1b4bf9eeaa0f4180786..3ad08caef6850a62b087d6bd43f87914b68d3d9a 100644 (file)
@@ -1,7 +1,7 @@
 /* Generic serial interface routines
 
-   Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
-   Free Software Foundation, Inc.
+   Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
+   2001, 2002 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -58,9 +58,6 @@ static const char logbase_ascii[] = "ascii";
 static const char *logbase_enums[] =
 {logbase_hex, logbase_octal, logbase_ascii, NULL};
 static const char *serial_logbase = logbase_ascii;
-
-#undef XMALLOC
-#define XMALLOC(TYPE) ((TYPE*) xmalloc (sizeof (TYPE)))
 \f
 
 static int serial_current_type = 0;
@@ -185,9 +182,7 @@ serial_open (const char *name)
        return scb;
       }
 
-  if (strcmp (name, "ocd") == 0)
-    ops = serial_interface_lookup ("ocd");
-  else if (strcmp (name, "pc") == 0)
+  if (strcmp (name, "pc") == 0)
     ops = serial_interface_lookup ("pc");
   else if (strchr (name, ':'))
     ops = serial_interface_lookup ("tcp");
@@ -350,9 +345,9 @@ serial_readchar (struct serial *scb, int timeout)
 
   /* 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)
+  if (0 && serial_is_async_p (scb) && timeout < 0)
     internal_error (__FILE__, __LINE__,
-                   "serial_readchar: blocking read in async mode");
+                   _("serial_readchar: blocking read in async mode"));
 
   ch = scb->ops->readchar (scb, timeout);
   if (serial_logfp != NULL)
@@ -363,7 +358,7 @@ serial_readchar (struct serial *scb, int timeout)
          in case we are getting ready to dump core or something. */
       gdb_flush (serial_logfp);
     }
-  if (SERIAL_DEBUG_P (scb))
+  if (serial_debug_p (scb))
     {
       fprintf_unfiltered (gdb_stdlog, "[");
       serial_logchar (gdb_stdlog, 'r', ch, timeout);
@@ -399,8 +394,8 @@ serial_printf (struct serial *desc, const char *format,...)
   char *buf;
   va_start (args, format);
 
-  xvasprintf (&buf, format, args);
-  SERIAL_WRITE (desc, buf, strlen (buf));
+  buf = xstrvprintf (format, args);
+  serial_write (desc, buf, strlen (buf));
 
   xfree (buf);
   va_end (args);
@@ -512,7 +507,7 @@ deprecated_serial_fd (struct serial *scb)
   if (scb->fd < 0)
     {
       internal_error (__FILE__, __LINE__,
-                     "serial: FD not valid");
+                     _("serial: FD not valid"));
     }
   return scb->fd; /* sigh */
 }
@@ -554,9 +549,9 @@ static void
 cleanup_tty (serial_ttystate ttystate)
 {
   printf_unfiltered ("\r\n[Exiting connect mode]\r\n");
-  SERIAL_SET_TTY_STATE (tty_desc, ttystate);
+  serial_set_tty_state (tty_desc, ttystate);
   xfree (ttystate);
-  SERIAL_CLOSE (tty_desc);
+  serial_close (tty_desc);
 }
 
 static void
@@ -574,13 +569,13 @@ connect_command (char *args, int fromtty)
 
   printf_unfiltered ("[Entering connect mode.  Use ~. or ~^D to escape]\n");
 
-  tty_desc = SERIAL_FDOPEN (0);
+  tty_desc = serial_fdopen (0);
   port_desc = last_serial_opened;
 
-  ttystate = SERIAL_GET_TTY_STATE (tty_desc);
+  ttystate = serial_get_tty_state (tty_desc);
 
-  SERIAL_RAW (tty_desc);
-  SERIAL_RAW (port_desc);
+  serial_raw (tty_desc);
+  serial_raw (port_desc);
 
   make_cleanup (cleanup_tty, ttystate);
 
@@ -588,7 +583,7 @@ connect_command (char *args, int fromtty)
     {
       int mask;
 
-      mask = SERIAL_WAIT_2 (tty_desc, port_desc, -1);
+      mask = serial_wait_2 (tty_desc, port_desc, -1);
 
       if (mask & 2)
        {                       /* tty input */
@@ -596,16 +591,16 @@ connect_command (char *args, int fromtty)
 
          while (1)
            {
-             c = SERIAL_READCHAR (tty_desc, 0);
+             c = serial_readchar (tty_desc, 0);
 
              if (c == SERIAL_TIMEOUT)
                break;
 
              if (c < 0)
-               perror_with_name ("connect");
+               perror_with_name (_("connect"));
 
              cx = c;
-             SERIAL_WRITE (port_desc, &cx, 1);
+             serial_write (port_desc, &cx, 1);
 
              switch (cur_esc)
                {
@@ -634,53 +629,86 @@ connect_command (char *args, int fromtty)
 
          while (1)
            {
-             c = SERIAL_READCHAR (port_desc, 0);
+             c = serial_readchar (port_desc, 0);
 
              if (c == SERIAL_TIMEOUT)
                break;
 
              if (c < 0)
-               perror_with_name ("connect");
+               perror_with_name (_("connect"));
 
              cx = c;
 
-             SERIAL_WRITE (tty_desc, &cx, 1);
+             serial_write (tty_desc, &cx, 1);
            }
        }
     }
 }
 #endif /* 0 */
 
+/* Serial set/show framework.  */
+
+static struct cmd_list_element *serial_set_cmdlist;
+static struct cmd_list_element *serial_show_cmdlist;
+
+static void
+serial_set_cmd (char *args, int from_tty)
+{
+  printf_unfiltered ("\"set serial\" must be followed by the name of a command.\n");
+  help_list (serial_set_cmdlist, "set serial ", -1, gdb_stdout);
+}
+
+static void
+serial_show_cmd (char *args, int from_tty)
+{
+  cmd_show_list (serial_show_cmdlist, from_tty, "");
+}
+
+
 void
 _initialize_serial (void)
 {
 #if 0
-  add_com ("connect", class_obscure, connect_command,
-          "Connect the terminal directly up to the command monitor.\n\
-Use <CR>~. or <CR>~^D to break out.");
+  add_com ("connect", class_obscure, connect_command, _("\
+Connect the terminal directly up to the command monitor.\n\
+Use <CR>~. or <CR>~^D to break out."));
 #endif /* 0 */
 
-  add_show_from_set
-    (add_set_cmd ("remotelogfile", no_class,
-                 var_filename, (char *) &serial_logfile,
-                 "Set filename for remote session recording.\n\
+  add_prefix_cmd ("serial", class_maintenance, serial_set_cmd, _("\
+Set default serial/parallel port configuration."),
+                 &serial_set_cmdlist, "set serial ",
+                 0/*allow-unknown*/,
+                 &setlist);
+
+  add_prefix_cmd ("serial", class_maintenance, serial_show_cmd, _("\
+Show default serial/parallel port configuration."),
+                 &serial_show_cmdlist, "show serial ",
+                 0/*allow-unknown*/,
+                 &showlist);
+
+  add_setshow_filename_cmd ("remotelogfile", no_class, &serial_logfile, _("\
+Set filename for remote session recording."), _("\
+Show filename for remote session recording."), _("\
 This file is used to record the remote session for future playback\n\
-by gdbserver.",
-                 &setlist),
-     &showlist);
-
-  add_show_from_set
-    (add_set_enum_cmd ("remotelogbase", no_class,
-                      logbase_enums, &serial_logbase,
-                      "Set numerical base for remote session logging",
-                      &setlist),
-     &showlist);
-
-  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.", &setdebuglist),
-                    &showdebuglist);
+by gdbserver."),
+                           NULL,
+                           NULL, /* FIXME: i18n: */
+                           &setlist, &showlist);
+
+  add_setshow_enum_cmd ("remotelogbase", no_class, logbase_enums,
+                       &serial_logbase, _("\
+Set numerical base for remote session logging"), _("\
+Show numerical base for remote session logging"), NULL,
+                       NULL,
+                       NULL, /* FIXME: i18n: */
+                       &setlist, &showlist);
+
+  add_setshow_zinteger_cmd ("serial", class_maintenance,
+                           &global_serial_debug_p, _("\
+Set serial debugging."), _("\
+Show serial debugging."), _("\
+When non-zero, serial port debugging is enabled."),
+                           NULL,
+                           NULL, /* FIXME: i18n: */
+                           &setdebuglist, &showdebuglist);
 }
This page took 0.027562 seconds and 4 git commands to generate.