Stop remote_read_bytes from handling partial reads itself.
[deliverable/binutils-gdb.git] / gdb / remote.c
index 48d9d554ea9ed7051ec0ab46e23cb8d1ff865880..b440e9e9ab5b14c95b593feb6cec87fa3d33e58d 100644 (file)
@@ -6356,7 +6356,7 @@ remote_write_bytes_aux (const char *header, CORE_ADDR memaddr,
    Returns number of bytes transferred, or 0 (setting errno) for
    error.  Only transfer a single packet.  */
 
-int
+static int
 remote_write_bytes (CORE_ADDR memaddr, const gdb_byte *myaddr, int len)
 {
   char *packet_format = 0;
@@ -6391,19 +6391,14 @@ remote_write_bytes (CORE_ADDR memaddr, const gdb_byte *myaddr, int len)
 
    Returns number of bytes transferred, or 0 for error.  */
 
-/* NOTE: cagney/1999-10-18: This function (and its siblings in other
-   remote targets) shouldn't attempt to read the entire buffer.
-   Instead it should read a single packet worth of data and then
-   return the byte size of that packet to the caller.  The caller (its
-   caller and its callers caller ;-) already contains code for
-   handling partial reads.  */
-
-int
+static int
 remote_read_bytes (CORE_ADDR memaddr, gdb_byte *myaddr, int len)
 {
   struct remote_state *rs = get_remote_state ();
   int max_buf_size;            /* Max size of packet output buffer.  */
-  int origlen;
+  char *p;
+  int todo;
+  int i;
 
   if (len <= 0)
     return 0;
@@ -6412,56 +6407,37 @@ remote_read_bytes (CORE_ADDR memaddr, gdb_byte *myaddr, int len)
   /* The packet buffer will be large enough for the payload;
      get_memory_packet_size ensures this.  */
 
-  origlen = len;
-  while (len > 0)
-    {
-      char *p;
-      int todo;
-      int i;
+  /* Number if bytes that will fit.  */
+  todo = min (len, max_buf_size / 2);
 
-      todo = min (len, max_buf_size / 2);      /* num bytes that will fit.  */
-
-      /* construct "m"<memaddr>","<len>" */
-      /* sprintf (rs->buf, "m%lx,%x", (unsigned long) memaddr, todo); */
-      memaddr = remote_address_masked (memaddr);
-      p = rs->buf;
-      *p++ = 'm';
-      p += hexnumstr (p, (ULONGEST) memaddr);
-      *p++ = ',';
-      p += hexnumstr (p, (ULONGEST) todo);
-      *p = '\0';
-
-      putpkt (rs->buf);
-      getpkt (&rs->buf, &rs->buf_size, 0);
-
-      if (rs->buf[0] == 'E'
-         && isxdigit (rs->buf[1]) && isxdigit (rs->buf[2])
-         && rs->buf[3] == '\0')
-       {
-         /* There is no correspondance between what the remote
-            protocol uses for errors and errno codes.  We would like
-            a cleaner way of representing errors (big enough to
-            include errno codes, bfd_error codes, and others).  But
-            for now just return EIO.  */
-         errno = EIO;
-         return 0;
-       }
-
-      /* Reply describes memory byte by byte,
-         each byte encoded as two hex characters.  */
-
-      p = rs->buf;
-      if ((i = hex2bin (p, myaddr, todo)) < todo)
-       {
-         /* Reply is short.  This means that we were able to read
-            only part of what we wanted to.  */
-         return i + (origlen - len);
-       }
-      myaddr += todo;
-      memaddr += todo;
-      len -= todo;
+  /* Construct "m"<memaddr>","<len>".  */
+  memaddr = remote_address_masked (memaddr);
+  p = rs->buf;
+  *p++ = 'm';
+  p += hexnumstr (p, (ULONGEST) memaddr);
+  *p++ = ',';
+  p += hexnumstr (p, (ULONGEST) todo);
+  *p = '\0';
+  putpkt (rs->buf);
+  getpkt (&rs->buf, &rs->buf_size, 0);
+  if (rs->buf[0] == 'E'
+      && isxdigit (rs->buf[1]) && isxdigit (rs->buf[2])
+      && rs->buf[3] == '\0')
+    {
+      /* There is no correspondance between what the remote protocol
+        uses for errors and errno codes.  We would like a cleaner way
+        of representing errors (big enough to include errno codes,
+        bfd_error codes, and others).  But for now just return
+        EIO.  */
+      errno = EIO;
+      return 0;
     }
-  return origlen;
+  /* Reply describes memory byte by byte, each byte encoded as two hex
+     characters.  */
+  p = rs->buf;
+  i = hex2bin (p, myaddr, todo);
+  /* Return what we have.  Let higher layers handle partial reads.  */
+  return i;
 }
 \f
 
This page took 0.027579 seconds and 4 git commands to generate.