* remote.c, remote-mon.c, remote-utils.c, remote-utils.h,
[deliverable/binutils-gdb.git] / gdb / remote-utils.c
index 75137e4522a620d8d2820c3f02868aed613908f3..482e2476b6403f565c595780e08d8b85258e6423 100644 (file)
@@ -1,6 +1,6 @@
 /* Generic support for remote debugging interfaces.
 
-   Copyright 1993 Free Software Foundation, Inc.
+   Copyright 1993, 1994 Free Software Foundation, Inc.
 
 This file is part of GDB.
 
@@ -42,6 +42,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include <ctype.h>
 
 #include "defs.h"
+#include <string.h>
 #include "gdbcmd.h"
 #include "target.h"
 #include "serial.h"
@@ -76,10 +77,8 @@ usage(proto, junk)
   if (junk != NULL)
     fprintf_unfiltered(gdb_stderr, "Unrecognized arguments: `%s'.\n", junk);
 
-  /* FIXME-now: service@host? */
-
-  error("Usage: target %s <device <speed <debug>>>\n\
-or target %s <host> <port>\n", proto, proto);
+  error ("Usage: target %s [DEVICE [SPEED [DEBUG]]]\n\
+where DEVICE is the name of a device or HOST:PORT", proto, proto);
 
   return;
 }
@@ -124,7 +123,7 @@ sr_scan_args(proto, args)
 
   /* check for missing or empty baud rate.  */
   CHECKDONE(p, q);
-  sr_set_baud_rate(n);
+  baud_rate = n;
 
   /* look for debug value.  */
   n = strtol(p, &q, 10);
@@ -167,14 +166,24 @@ gr_open(args, from_tty, gr)
   if (sr_get_desc() != NULL)
     gr_close (0);
 
+  /* If no args are specified, then we use the device specified by a
+     previous command or "set remotedevice".  But if there is no
+     device, better stop now, not dump core.  */
+
+  if (sr_get_device () == NULL)
+    usage (gr->ops->to_shortname, NULL);
+
   sr_set_desc(SERIAL_OPEN (sr_get_device()));
   if (!sr_get_desc())
     perror_with_name((char *) sr_get_device());
 
-  if (SERIAL_SETBAUDRATE(sr_get_desc(), sr_get_baud_rate()) != 0)
+  if (baud_rate != -1)
     {
-      SERIAL_CLOSE(sr_get_desc());
-      perror_with_name(sr_get_device());
+      if (SERIAL_SETBAUDRATE(sr_get_desc(), baud_rate) != 0)
+       {
+         SERIAL_CLOSE(sr_get_desc());
+         perror_with_name(sr_get_device());
+       }
     }
 
   SERIAL_RAW (sr_get_desc());
@@ -192,8 +201,13 @@ gr_open(args, from_tty, gr)
     gr_settings->clear_all_breakpoints = remove_breakpoints;
 
   if (from_tty)
-      printf_filtered ("Remote debugging using `%s' at baud rate of %d\n",
-                      sr_get_device(), sr_get_baud_rate());
+    {
+      printf_filtered ("Remote debugging using `%s'", sr_get_device ());
+      if (baud_rate != -1)
+       printf_filtered (" at baud rate of %d",
+                        baud_rate);
+      print_filtered ("\n");
+    }
 
   push_target(gr->ops);
   gr_checkin();
@@ -430,22 +444,20 @@ void
 gr_files_info (ops)
      struct target_ops *ops;
 {
-  char *file = "nothing";
-
-  if (exec_bfd)
-    file = bfd_get_filename (exec_bfd);
-
-  if (exec_bfd)
-    {
 #ifdef __GO32__
-      printf_filtered ("\tAttached to DOS asynctsr\n");
+  printf_filtered ("\tAttached to DOS asynctsr\n");
 #else
-      printf_filtered ("\tAttached to %s at %d baud\n",
-                      sr_get_device(), sr_get_baud_rate());
+  printf_filtered ("\tAttached to %s", sr_get_device());
+  if (baud_rate != -1)
+    printf_filtered ("at %d baud", baud_rate);
+  printf_filtered ("\n");
 #endif
-    }
 
-  printf_filtered ("\tand running program %s\n", file);
+  if (exec_bfd)
+    {
+      printf_filtered ("\tand running program %s\n",
+                      bfd_get_filename (exec_bfd));
+    }
   printf_filtered ("\tusing the %s protocol.\n", ops->to_shortname);
 }
 
This page took 0.024882 seconds and 4 git commands to generate.