* serial.h (SERIAL_SET_TTY_STATE): Comment return value.
[deliverable/binutils-gdb.git] / gdb / remote-mips.c
index 6fdf6bcc58b500a9fdd5d7b8253414a2293719db..0c5ee6e77b6ca98a2275bfffdf38cbb49f80efb9 100644 (file)
@@ -58,7 +58,7 @@ static int mips_receive_packet PARAMS ((char *buff, int throw_error,
 
 static int
 mips_request PARAMS ((char cmd, unsigned int addr, unsigned int data,
-                     int *perr, timeout));
+                     int *perr, int timeout));
 
 static void
 mips_initialize PARAMS ((void));
@@ -76,7 +76,7 @@ static void mips_resume PARAMS ((int pid, int step,
                                 enum target_signal siggnal));
 
 static int
-mips_wait PARAMS ((int pid, WAITTYPE *status));
+mips_wait PARAMS ((int pid, struct target_waitstatus *status));
 
 static int
 mips_map_regno PARAMS ((int regno));
@@ -888,6 +888,13 @@ mips_request (cmd, addr, data, perr, timeout)
   return rresponse;
 }
 
+static void
+mips_initialize_cleanups (arg)
+     PTR arg;
+{
+  mips_initializing = 0;
+}
+
 /* Initialize a new connection to the MIPS board, and make sure we are
    really connected.  */
 
@@ -897,9 +904,16 @@ mips_initialize ()
   char cr;
   char buff[DATA_MAXLEN + 1];
   int err;
+  struct cleanup *old_cleanups = make_cleanup (mips_initialize_cleanups, NULL);
 
+  /* What is this code doing here?  I don't see any way it can happen, and
+     it might mean mips_initializing didn't get cleared properly.
+     So I'll make it a warning.  */
   if (mips_initializing)
-    return;
+    {
+      warning ("internal error: mips_initialize called twice");
+      return;
+    }
 
   mips_initializing = 1;
 
@@ -929,7 +943,7 @@ mips_initialize ()
     }
   mips_receive_packet (buff, 1, 3);
 
-  mips_initializing = 0;
+  do_cleanups (old_cleanups);
 
   /* If this doesn't call error, we have connected; we don't care if
      the request itself succeeds or fails.  */
@@ -1026,6 +1040,26 @@ mips_resume (pid, step, siggnal)
                mips_receive_wait);
 }
 
+/* Return the signal corresponding to SIG, where SIG is the number which
+   the MIPS protocol uses for the signal.  */
+enum target_signal
+mips_signal_from_protocol (sig)
+     int sig;
+{
+  /* We allow a few more signals than the IDT board actually returns, on
+     the theory that there is at least *some* hope that perhaps the numbering
+     for these signals is widely agreed upon.  */
+  if (sig <= 0
+      || sig > 31)
+    return TARGET_SIGNAL_UNKNOWN;
+
+  /* Don't want to use target_signal_from_host because we are converting
+     from MIPS signal numbers, not host ones.  Our internal numbers
+     match the MIPS numbers for the signals the board can return, which
+     are: SIGINT, SIGSEGV, SIGBUS, SIGILL, SIGFPE, SIGTRAP.  */
+  return (enum target_signal) sig;
+}
+
 /* Wait until the remote stops, and return a wait status.  */
 
 static int
@@ -1062,20 +1096,12 @@ mips_wait (pid, status)
   else if ((rstatus & 0377) == 0177)
     {
       status->kind = TARGET_WAITKIND_STOPPED;
-      /* Don't want to use target_signal_from_host because we are converting
-        from MIPS signal numbers, not host ones.  Our internal numbers
-        match the MIPS numbers for the signals the board can return, which
-        are: SIGINT, SIGSEGV, SIGBUS, SIGILL, SIGFPE, SIGTRAP.  */
-      status->value.sig = (enum target_signal) (((rstatus) >> 8) & 0377);
+      status->value.sig = mips_signal_from_protocol (((rstatus) >> 8) & 0377);
     }
   else
     {
       status->kind = TARGET_WAITKIND_SIGNALLED;
-      /* Don't want to use target_signal_from_host because we are converting
-        from MIPS signal numbers, not host ones.  Our internal numbers
-        match the MIPS numbers for the signals the board can return, which
-        are: SIGINT, SIGSEGV, SIGBUS, SIGILL, SIGFPE, SIGTRAP.  */
-      status->value.sig = (enum target_signal) (rstatus & 0177);
+      status->value.sig = mips_signal_from_protocol (rstatus & 0177);
     }
 
   return 0;
@@ -1357,8 +1383,10 @@ struct target_ops mips_ops =
 {
   "mips",                      /* to_shortname */
   "Remote MIPS debugging over serial line",    /* to_longname */
-  "Debug a board using the MIPS remote debugging protocol over a serial line.\n\
-Specify the serial device it is connected to (e.g., /dev/ttya).",  /* to_doc */
+  "\
+Debug a board using the MIPS remote debugging protocol over a serial line.\n\
+The argument is the device it is connected to or, if it contains a colon,\n\
+HOST:PORT to access a board over a network",  /* to_doc */
   mips_open,                   /* to_open */
   mips_close,                  /* to_close */
   NULL,                                /* to_attach */
This page took 0.024762 seconds and 4 git commands to generate.