* config/m68k/monitor.mt (TDEPFILE): Add remote-es.o.
[deliverable/binutils-gdb.git] / gdb / remote.c
index 9900b3b1ad71af96cf7a4ecb9b2a711a7de6537b..87437a177981bef7d81d91ef76a5591eed6bc6b3 100644 (file)
@@ -133,7 +133,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "gdb-stabs.h"
 
 #include "dcache.h"
-#include "remote-utils.h"
 
 #if !defined(DONT_USE_REMOTE)
 #ifdef USG
@@ -192,7 +191,7 @@ static int
 readchar PARAMS ((void));
 
 static int
-remote_wait PARAMS ((WAITTYPE *status));
+remote_wait PARAMS ((int pid, WAITTYPE *status));
 
 static int
 tohex PARAMS ((int nib));
@@ -229,7 +228,12 @@ int icache;
    starts.  */
 serial_t remote_desc = NULL;
 
-#define        PBUFSIZ 1024
+/* Having this larger than 400 causes us to be incompatible with m68k-stub.c
+   and i386-stub.c.  Normally, no one would notice because it only matters
+   for writing large chunks of memory (e.g. in downloads).  Also, this needs
+   to be more than 400 if required to hold the registers (see below, where
+   we round it up based on REGISTER_BYTES).  */
+#define        PBUFSIZ 400
 
 /* Maximum number of bytes to read/write at once.  The value here
    is chosen to fill up a packet (the headers account for the 32).  */
@@ -297,7 +301,7 @@ device is attached to the remote system (e.g. /dev/ttya).");
   if (!remote_desc)
     perror_with_name (name);
 
-  if (SERIAL_SETBAUDRATE (remote_desc, sr_get_baud_rate()))
+  if (SERIAL_SETBAUDRATE (remote_desc, baud_rate))
     {
       SERIAL_CLOSE (remote_desc);
       perror_with_name (name);
@@ -412,8 +416,8 @@ remote_interrupt (signo)
   /* If this doesn't work, try more severe steps.  */
   signal (signo, remote_interrupt_twice);
   
-  if (sr_get_debug ())
-    printf ("remote_interrupt called\n");
+  if (remote_debug)
+    printf_unfiltered ("remote_interrupt called\n");
 
   SERIAL_WRITE (remote_desc, "\003", 1); /* Send a ^C */
 }
@@ -455,7 +459,8 @@ Give up (and stop debugging it)? "))
    means in the case of this target).  */
 
 static int
-remote_wait (status)
+remote_wait (pid, status)
+     int pid;
      WAITTYPE *status;
 {
   unsigned char buf[PBUFSIZ];
@@ -560,12 +565,6 @@ remote_wait (status)
                 stuff.  (Just what does "text" as seen by the stub
                 mean, anyway?).  */
 
-             /* FIXME: Why don't the various symfile_offsets routines
-                in the sym_fns vectors set this?
-                (no good reason -kingdon).  */
-             if (symfile_objfile->num_sections == 0)
-               symfile_objfile->num_sections = SECT_OFF_MAX;
-
              offs = ((struct section_offsets *)
                      alloca (sizeof (struct section_offsets)
                              + (symfile_objfile->num_sections
@@ -581,16 +580,16 @@ remote_wait (status)
              objfile_relocate (symfile_objfile, offs);
              {
                struct obj_section *s;
-               bfd *bfd;
+               bfd *abfd;
 
-               bfd = symfile_objfile->obfd;
+               abfd = symfile_objfile->obfd;
 
                for (s = symfile_objfile->sections;
                     s < symfile_objfile->sections_end; ++s)
                  {
                    flagword flags;
 
-                   flags = bfd_get_section_flags (bfd, s->sec_ptr);
+                   flags = bfd_get_section_flags (abfd, s->sec_ptr);
 
                    if (flags & SEC_CODE)
                      {
@@ -656,8 +655,8 @@ remote_fetch_registers (regno)
   while ((buf[0] < '0' || buf[0] > '9')
         && (buf[0] < 'a' || buf[0] > 'f'))
     {
-      if (sr_get_debug () > 0)
-       printf ("Bad register packet; fetching a new packet\n");
+      if (remote_debug)
+       printf_unfiltered ("Bad register packet; fetching a new packet\n");
       getpkt (buf, 0);
     }
 
@@ -798,9 +797,6 @@ remote_write_bytes (memaddr, myaddr, len)
   int i;
   char *p;
 
-  if (len > PBUFSIZ / 2 - 20)
-    abort ();
-
   sprintf (buf, "M%x,%x:", memaddr, len);
 
   /* We send target system values byte by byte, in increasing byte addresses,
@@ -998,10 +994,10 @@ putpkt (buf)
 
   while (1)
     {
-      if (sr_get_debug ())
+      if (remote_debug)
        {
          *p = '\0';
-         printf ("Sending packet: %s...", buf2);  fflush(stdout);
+         printf_unfiltered ("Sending packet: %s...", buf2);  gdb_flush(gdb_stdout);
        }
       if (SERIAL_WRITE (remote_desc, buf2, p - buf2))
        perror_with_name ("putpkt: write failed");
@@ -1014,8 +1010,8 @@ putpkt (buf)
          switch (ch)
            {
            case '+':
-             if (sr_get_debug ())
-               printf("Ack\n");
+             if (remote_debug)
+               printf_unfiltered("Ack\n");
              return;
            case SERIAL_TIMEOUT:
              break;            /* Retransmit buffer */
@@ -1024,8 +1020,8 @@ putpkt (buf)
            case SERIAL_EOF:
              error ("putpkt: EOF while trying to read ACK");
            default:
-             if (sr_get_debug ())
-               printf ("%02X %c ", ch&0xFF, ch);
+             if (remote_debug)
+               printf_unfiltered ("%02X %c ", ch&0xFF, ch);
              continue;
            }
          break;                /* Here to retransmit */
@@ -1077,7 +1073,7 @@ getpkt (buf, forever)
          if (forever)
            continue;
          if (++retries >= MAX_RETRIES)
-           if (sr_get_debug ()) puts_filtered ("Timed out.\n");
+           if (remote_debug) puts_filtered ("Timed out.\n");
          goto out;
        }
 
@@ -1095,13 +1091,13 @@ getpkt (buf, forever)
          c = readchar ();
          if (c == SERIAL_TIMEOUT)
            {
-             if (sr_get_debug ())
+             if (remote_debug)
                puts_filtered ("Timeout in mid-packet, retrying\n");
              goto whole;               /* Start a new packet, count retries */
            } 
          if (c == '$')
            {
-             if (sr_get_debug ())
+             if (remote_debug)
                puts_filtered ("Saw new packet start in middle of old one\n");
              goto whole;               /* Start a new packet, count retries */
            }
@@ -1137,7 +1133,7 @@ whole:
        }
       else
        {
-         printf ("Ignoring packet error, continuing...\n");
+         printf_unfiltered ("Ignoring packet error, continuing...\n");
          break;
        }
     }
@@ -1146,8 +1142,8 @@ out:
 
   SERIAL_WRITE (remote_desc, "+", 1);
 
-  if (sr_get_debug ())
-    fprintf (stderr,"Packet received: %s\n", buf);
+  if (remote_debug)
+    fprintf_unfiltered (gdb_stderr,"Packet received: %s\n", buf);
 }
 \f
 static void
@@ -1259,10 +1255,12 @@ Specify the serial device it is connected to (e.g. /dev/ttya).",  /* to_doc */
   NULL,                                /* sections_end */
   OPS_MAGIC                    /* to_magic */
 };
+#endif /* Use remote.  */
 
 void
 _initialize_remote ()
 {
+#if !defined(DONT_USE_REMOTE)
   add_target (&remote_ops);
-}
 #endif
+}
This page took 0.025742 seconds and 4 git commands to generate.