* config/monitor.exp: Detect the "Couldn't establish connection"
[deliverable/binutils-gdb.git] / gdb / remote-os9k.c
index cf4cd9b7d33be8b12f94b8b78d82ee1987a10560..f195aaf82ed266cb2a15de7122b4b61d399e853e 100644 (file)
@@ -15,7 +15,7 @@ GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
-Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
 /* This file was derived from remote-eb.c, which did a similar job, but for
    an AMD-29K running EBMON.  That file was in turn derived from remote.c
@@ -33,13 +33,20 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
    of ROMBUG is not available yet.
 */
 
+/* FIXME This file needs to be rewritten if it's to work again, either
+   to self-contained or to use the new monitor interface.  */
+
 #include "defs.h"
 #include "gdbcore.h"
 #include "target.h"
 #include "wait.h"
+#ifdef ANSI_PROTOTYPES
+#include <stdarg.h>
+#else
 #include <varargs.h>
+#endif
 #include <signal.h>
-#include <string.h>
+#include "gdb_string.h"
 #include <sys/types.h>
 #include "command.h"
 #include "serial.h"
@@ -49,15 +56,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "symfile.h"
 #include "objfiles.h"
 #include "gdb-stabs.h"
-#include <termio.h>
-
-#ifdef HAVE_TERMIO
-#  define TERMINAL struct termios
-#else
-#  define TERMINAL struct sgttyb
-#endif
 
-struct monitor_ops *current_monitor;
 struct cmd_list_element *showlist;
 extern struct target_ops rombug_ops;           /* Forward declaration */
 extern struct monitor_ops rombug_cmds;         /* Forward declaration */
@@ -93,19 +92,27 @@ static char readbuf[16];
 
 /* Send data to monitor.  Works just like printf. */
 static void
+#ifdef ANSI_PROTOTYPES
+printf_monitor(char *pattern, ...)
+#else
 printf_monitor(va_alist)
      va_dcl
+#endif
 {
   va_list args;
-  char *pattern;
   char buf[200];
   int i;
 
+#ifdef ANSI_PROTOTYPES
+  va_start (args, pattern);
+#else
+  char *pattern;
   va_start(args);
-
   pattern = va_arg(args, char *);
+#endif
 
   vsprintf(buf, pattern, args);
+  va_end(args);
 
   if (SERIAL_WRITE(monitor_desc, buf, strlen(buf)))
     fprintf(stderr, "SERIAL_WRITE failed: %s\n", safe_strerror(errno));
@@ -270,13 +277,11 @@ get_hex_regs (n, regno)
       val = 0;
       for (j = 0; j < 4; j++)
        {
-#if TARGET_BYTE_ORDER == BIG_ENDIAN
-         get_hex_byte(&b);
-         val = (val << 8) + b;
-#else
-         get_hex_byte(&b);
-         val = val + (b << (j*8));
-#endif
+         get_hex_byte (&b);
+         if (TARGET_BYTE_ORDER == BIG_ENDIAN)
+           val = (val << 8) + b;
+         else
+           val = val + (b << (j*8));
        }
       supply_register (regno++, (char *) &val);
     }
@@ -361,14 +366,17 @@ rombug_open(args, from_tty)
   push_monitor (&rombug_cmds);
   printf_monitor("\r");        /* CR wakes up monitor */
   expect_prompt(1);
-
   push_target (&rombug_ops);
+  attach_flag = 1;
+
   if (from_tty)
     printf("Remote %s connected to %s\n", target_shortname,
           dev_name);
 
-  attach_flag = 1;
   rombug_fetch_registers();
+
+  printf_monitor ("ov e \r");
+  expect_prompt(1);
   bufaddr = 0;
   buflen = 0;
 }
@@ -490,7 +498,8 @@ rombug_wait (pid, status)
   status->kind = TARGET_WAITKIND_EXITED;
   status->value.integer = 0;
 
-  timeout = 0;         /* Don't time out -- user program is running. */
+  timeout = -1;                /* Don't time out -- user program is running. */
+  expect ("eax:", 0);   /* output any message before register display */
   expect_prompt(1);     /* Wait for prompt, outputting extraneous text */
 
   status->kind = TARGET_WAITKIND_STOPPED;
@@ -577,13 +586,11 @@ rombug_fetch_registers ()
          val = 0;
          for (j = 0; j < 2; j++)
             {
-#if TARGET_BYTE_ORDER == BIG_ENDIAN
-              get_hex_byte(&b);
-              val = (val << 8) + b;
-#else
-              get_hex_byte(&b);
-              val = val + (b << (j*8));
-#endif
+              get_hex_byte (&b);
+             if (TARGET_BYTE_ORDER == BIG_ENDIAN)
+               val = (val << 8) + b;
+             else
+               val = val + (b << (j*8));
             }
 
          if (regno == 8) i = 10;
@@ -640,13 +647,11 @@ rombug_fetch_register (regno)
          val = 0;
          for (j = 0; j < 2; j++)
             {
-#if TARGET_BYTE_ORDER == BIG_ENDIAN
-              get_hex_byte(&b);
-              val = (val << 8) + b;
-#else
-              get_hex_byte(&b);
-              val = val + (b << (j*8));
-#endif
+              get_hex_byte (&b);
+             if (TARGET_BYTE_ORDER == BIG_ENDIAN)
+               val = (val << 8) + b;
+             else
+               val = val + (b << (j*8));
             }
          supply_register (regno, (char *) &val);
        }
@@ -765,6 +770,8 @@ rombug_write_inferior_memory (memaddr, myaddr, len)
   is_trace_mode = 0;
   expect_prompt (1);
 
+  bufaddr = 0;
+  buflen = 0;
   return len;
 }
 
@@ -1164,6 +1171,7 @@ Specify the serial device it is connected to (e.g. /dev/ttya).",
   rombug_mourn_inferior,
   0,                           /* can_run */
   0,                           /* notice_signals */
+  0,                           /* to_stop */
   process_stratum,
   0,                           /* next */
   1,
This page took 0.028336 seconds and 4 git commands to generate.