* write.c (relax_segment <rs_space>): Calculate growth using
[deliverable/binutils-gdb.git] / gdb / remote.c
index 60d462c166a3c256832db58593eea99a34186f67..e2e9f7395388e05c2c2671974263ca20c32a0c87 100644 (file)
@@ -190,6 +190,8 @@ static int fromhex (int a);
 
 static int hex2bin (const char *hex, char *bin, int);
 
+static int bin2hex (const char *bin, char *hex, int);
+
 static int putpkt_binary (char *buf, int cnt);
 
 static void check_binary_download (CORE_ADDR addr);
@@ -2346,10 +2348,6 @@ hex2bin (const char *hex, char *bin, int count)
 {
   int i;
 
-  /* May use a length, or a nul-terminated string as input. */
-  if (count == 0)
-    count = strlen (hex) / 2;
-
   for (i = 0; i < count; i++)
     {
       if (hex[0] == 0 || hex[1] == 0)
@@ -2376,7 +2374,7 @@ tohex (int nib)
 }
 
 static int
-bin2hex (char *bin, char *hex, int count)
+bin2hex (const char *bin, char *hex, int count)
 {
   int i;
   /* May use a length, or a nul-terminated string as input. */
@@ -2449,7 +2447,7 @@ remote_resume (ptid_t ptid, int step, enum target_signal siggnal)
              putpkt (buf);
              getpkt (buf, PBUFSIZ, 0);
 
-             if (packet_ok(buf, &remote_protocol_E) == PACKET_OK)
+             if (packet_ok (buf, &remote_protocol_E) == PACKET_OK)
                return;
            }
        }
@@ -2467,7 +2465,7 @@ remote_resume (ptid_t ptid, int step, enum target_signal siggnal)
              putpkt (buf);
              getpkt (buf, PBUFSIZ, 0);
 
-             if (packet_ok(buf, &remote_protocol_e) == PACKET_OK)
+             if (packet_ok (buf, &remote_protocol_e) == PACKET_OK)
                return;
            }
        }
@@ -2537,7 +2535,7 @@ remote_async_resume (ptid_t ptid, int step, enum target_signal siggnal)
              putpkt (buf);
              getpkt (buf, PBUFSIZ, 0);
 
-             if (packet_ok(buf, &remote_protocol_E) == PACKET_OK)
+             if (packet_ok (buf, &remote_protocol_E) == PACKET_OK)
                goto register_event_loop;
            }
        }
@@ -2555,7 +2553,7 @@ remote_async_resume (ptid_t ptid, int step, enum target_signal siggnal)
              putpkt (buf);
              getpkt (buf, PBUFSIZ, 0);
 
-             if (packet_ok(buf, &remote_protocol_e) == PACKET_OK)
+             if (packet_ok (buf, &remote_protocol_e) == PACKET_OK)
                goto register_event_loop;
            }
        }
@@ -2843,6 +2841,7 @@ remote_wait (ptid_t ptid, struct target_waitstatus *status)
              {
                unsigned char *p1;
                char *p_temp;
+               int fieldsize;
 
                /* Read the register number */
                regno = strtol ((const char *) p, &p_temp, 16);
@@ -2876,8 +2875,9 @@ Packet: '%s'\n",
 Packet: '%s'\n",
                               regno, p, buf);
 
-                   if (hex2bin (p, regs, REGISTER_RAW_SIZE (regno))
-                       < REGISTER_RAW_SIZE (regno))
+                   fieldsize = hex2bin (p, regs, REGISTER_RAW_SIZE (regno));
+                   p += 2 * fieldsize;
+                   if (fieldsize < REGISTER_RAW_SIZE (regno))
                      warning ("Remote reply is too short: %s", buf);
                    supply_register (regno, regs);
                  }
@@ -3060,6 +3060,7 @@ remote_async_wait (ptid_t ptid, struct target_waitstatus *status)
              {
                unsigned char *p1;
                char *p_temp;
+               int fieldsize;
 
                /* Read the register number */
                regno = strtol ((const char *) p, &p_temp, 16);
@@ -3093,8 +3094,9 @@ Packet: '%s'\n",
 Packet: '%s'\n",
                               regno, p, buf);
 
-                   if (hex2bin (p, regs, REGISTER_RAW_SIZE (regno)) 
-                       < REGISTER_RAW_SIZE (regno))
+                   fieldsize = hex2bin (p, regs, REGISTER_RAW_SIZE (regno));
+                   p += 2 * fieldsize;
+                   if (fieldsize < REGISTER_RAW_SIZE (regno))
                      warning ("Remote reply is too short: %s", buf);
                    supply_register (regno, regs);
                  }
@@ -3629,8 +3631,8 @@ remote_write_bytes (CORE_ADDR memaddr, char *myaddr, int len)
       /* Normal mode: Send target system values byte by byte, in
         increasing byte addresses.  Each byte is encoded as a two hex
         value.  */
-      bin2hex (myaddr, p, todo);
-      nr_bytes = todo;
+      nr_bytes = bin2hex (myaddr, p, todo);
+      p += 2 * nr_bytes;
       break;
     case PACKET_SUPPORT_UNKNOWN:
       internal_error (__FILE__, __LINE__,
This page took 0.025772 seconds and 4 git commands to generate.