replace convert_int_to_ascii with bin2hex
authorTom Tromey <tromey@redhat.com>
Sun, 19 Jan 2014 02:34:15 +0000 (19:34 -0700)
committerTom Tromey <tromey@redhat.com>
Wed, 12 Feb 2014 16:59:18 +0000 (09:59 -0700)
convert_int_to_ascii is identical to bin2hex.  This removes the
former.  In this case I made the choice of which to keep on the basis
that I consider the name bin2hex to be superior to
convert_int_to_ascii.

2014-02-12  Tom Tromey  <tromey@redhat.com>

* common/rsp-low.h (convert_int_to_ascii): Don't declare.
* common/rsp-low.c (convert_int_to_ascii): Remove.

2014-02-12  Tom Tromey  <tromey@redhat.com>

* ax.c (gdb_unparse_agent_expr): Use bin2hex, not
convert_int_to_ascii.
* regcache.c (registers_to_string, collect_register_as_string):
Likewise.
* remote-utils.c (look_up_one_symbol, relocate_instruction):
Likewise.
* server.c (process_serial_event): Likewise.
* tracepoint.c (cmd_qtstatus, response_source, response_tsv)
(cmd_qtbuffer, cstr_to_hexstr): Likewise.

gdb/ChangeLog
gdb/common/rsp-low.c
gdb/common/rsp-low.h
gdb/gdbserver/ChangeLog
gdb/gdbserver/ax.c
gdb/gdbserver/regcache.c
gdb/gdbserver/remote-utils.c
gdb/gdbserver/server.c
gdb/gdbserver/tracepoint.c

index a0d6bc17c532ca4b163b28bbf136e3b0e04938d6..85b420a00d378a0f38fdd2b74824279ef25b744a 100644 (file)
@@ -1,3 +1,8 @@
+2014-02-12  Tom Tromey  <tromey@redhat.com>
+
+       * common/rsp-low.h (convert_int_to_ascii): Don't declare.
+       * common/rsp-low.c (convert_int_to_ascii): Remove.
+
 2014-02-12  Tom Tromey  <tromey@redhat.com>
 
        * common/rsp-low.h (hexify): Don't declare.
index a7b001446c8c31cb7e3866f1717ca99f5777d07a..c7a00c1308b4c08d56f5d2fc873af8c9f24383b6 100644 (file)
@@ -172,22 +172,6 @@ bin2hex (const gdb_byte *bin, char *hex, int count)
   return i;
 }
 
-void
-convert_int_to_ascii (const unsigned char *from, char *to, int n)
-{
-  int nib;
-  int ch;
-  while (n--)
-    {
-      ch = *from++;
-      nib = ((ch & 0xf0) >> 4) & 0x0f;
-      *to++ = tohex (nib);
-      nib = ch & 0x0f;
-      *to++ = tohex (nib);
-    }
-  *to++ = 0;
-}
-
 int
 remote_escape_output (const gdb_byte *buffer, int len,
                      gdb_byte *out_buf, int *out_len,
index 2ef5e6d8fb3808f4164ee954be1eb04b125fa355..e1944cf92a8f6b75621a529a99c7c2538752df55 100644 (file)
@@ -42,8 +42,6 @@ extern void convert_ascii_to_int (const char *from, unsigned char *to, int n);
 
 extern int bin2hex (const gdb_byte *bin, char *hex, int count);
 
-extern void convert_int_to_ascii (const unsigned char *from, char *to, int n);
-
 /* Convert BUFFER, binary data at least LEN bytes long, into escaped
    binary data in OUT_BUF.  Set *OUT_LEN to the length of the data
    encoded in OUT_BUF, and return the number of bytes in OUT_BUF
index dc2c078d4aff2f4a32ebd0c00046c0d836d322b6..cacc74beee5c2c41ca2e93baa87988472120696f 100644 (file)
@@ -1,3 +1,15 @@
+2014-02-12  Tom Tromey  <tromey@redhat.com>
+
+       * ax.c (gdb_unparse_agent_expr): Use bin2hex, not
+       convert_int_to_ascii.
+       * regcache.c (registers_to_string, collect_register_as_string):
+       Likewise.
+       * remote-utils.c (look_up_one_symbol, relocate_instruction):
+       Likewise.
+       * server.c (process_serial_event): Likewise.
+       * tracepoint.c (cmd_qtstatus, response_source, response_tsv)
+       (cmd_qtbuffer, cstr_to_hexstr): Likewise.
+
 2014-02-12  Tom Tromey  <tromey@redhat.com>
 
        * remote-utils.c (look_up_one_symbol, monitor_output): Use
index f62a6138555c321ea0525a14dcd4c05f78833581..1eefaf3e6a335fda1d8e6f2cbfaf6e41bdaf9228 100644 (file)
@@ -120,7 +120,7 @@ gdb_unparse_agent_expr (struct agent_expr *aexpr)
   char *rslt;
 
   rslt = xmalloc (2 * aexpr->length + 1);
-  convert_int_to_ascii (aexpr->bytes, rslt, aexpr->length);
+  bin2hex (aexpr->bytes, rslt, aexpr->length);
   return rslt;
 }
 
index f51e49895843c747737df375e87ebfdfe4923d51..6e5aa089c26354d9680479855e766ef22e73df20 100644 (file)
@@ -207,8 +207,7 @@ registers_to_string (struct regcache *regcache, char *buf)
     {
       if (regcache->register_status[i] == REG_VALID)
        {
-         convert_int_to_ascii (registers, buf,
-                               register_size (tdesc, i));
+         bin2hex (registers, buf, register_size (tdesc, i));
          buf += register_size (tdesc, i) * 2;
        }
       else
@@ -419,8 +418,8 @@ collect_register (struct regcache *regcache, int n, void *buf)
 void
 collect_register_as_string (struct regcache *regcache, int n, char *buf)
 {
-  convert_int_to_ascii (register_data (regcache, n, 1), buf,
-                       register_size (regcache->tdesc, n));
+  bin2hex (register_data (regcache, n, 1), buf,
+          register_size (regcache->tdesc, n));
 }
 
 void
index a81a739008a1f4f72c515f6658e0159075a013d4..3b3f18333cd637ab9b554628470473c5626e672e 100644 (file)
@@ -1423,7 +1423,7 @@ look_up_one_symbol (const char *name, CORE_ADDR *addrp, int may_ask_gdb)
       decode_m_packet (&own_buf[1], &mem_addr, &mem_len);
       mem_buf = xmalloc (mem_len);
       if (read_inferior_memory (mem_addr, mem_buf, mem_len) == 0)
-       convert_int_to_ascii (mem_buf, own_buf, mem_len);
+       bin2hex (mem_buf, own_buf, mem_len);
       else
        write_enn (own_buf);
       free (mem_buf);
@@ -1507,7 +1507,7 @@ relocate_instruction (CORE_ADDR *to, CORE_ADDR oldloc)
          decode_m_packet (&own_buf[1], &mem_addr, &mem_len);
          mem_buf = xmalloc (mem_len);
          if (read_inferior_memory (mem_addr, mem_buf, mem_len) == 0)
-           convert_int_to_ascii (mem_buf, own_buf, mem_len);
+           bin2hex (mem_buf, own_buf, mem_len);
          else
            write_enn (own_buf);
        }
index e09f2d598675c5f3cc7ecc404540521b42039e19..e582598ecaeb2cfc4e80042aeeee81a2446037a2 100644 (file)
@@ -3602,7 +3602,7 @@ process_serial_event (void)
       if (res < 0)
        write_enn (own_buf);
       else
-       convert_int_to_ascii (mem_buf, own_buf, res);
+       bin2hex (mem_buf, own_buf, res);
       break;
     case 'M':
       require_running (own_buf);
index 3ae3bdd29297fd505ccf3248df7bfb84f3bf8080..df320059be379bbb0472fac3200bd0f17c5a5aa9 100644 (file)
@@ -3663,7 +3663,7 @@ cmd_qtstatus (char *packet)
       p = stop_reason_rsp = alloca (strlen ("terror:") + hexstr_len + 1);
       strcpy (p, "terror:");
       p += strlen (p);
-      convert_int_to_ascii ((gdb_byte *) result_name, p, strlen (result_name));
+      bin2hex ((gdb_byte *) result_name, p, strlen (result_name));
     }
 
   /* If this was a forced stop, include any stop note that was supplied.  */
@@ -3782,7 +3782,7 @@ response_source (char *packet,
 
   len = strlen (src->str);
   buf = alloca (len * 2 + 1);
-  convert_int_to_ascii ((gdb_byte *) src->str, buf, len);
+  bin2hex ((gdb_byte *) src->str, buf, len);
 
   sprintf (packet, "Z%x:%s:%s:%x:%x:%s",
           tpoint->number, paddress (tpoint->address),
@@ -3871,7 +3871,7 @@ response_tsv (char *packet, struct trace_state_variable *tsv)
     {
       namelen = strlen (tsv->name);
       buf = alloca (namelen * 2 + 1);
-      convert_int_to_ascii ((gdb_byte *) tsv->name, buf, namelen);
+      bin2hex ((gdb_byte *) tsv->name, buf, namelen);
     }
 
   sprintf (packet, "%x:%s:%x:%s", tsv->number, phex_nz (tsv->initial_value, 0),
@@ -4041,7 +4041,7 @@ cmd_qtbuffer (char *own_buf)
   if (num >= (PBUFSIZ - 16) / 2 )
     num = (PBUFSIZ - 16) / 2;
 
-  convert_int_to_ascii (tbp, own_buf, num);
+  bin2hex (tbp, own_buf, num);
 }
 
 static void
@@ -6930,7 +6930,7 @@ cstr_to_hexstr (const char *str)
 {
   int len = strlen (str);
   char *hexstr = xmalloc (len * 2 + 1);
-  convert_int_to_ascii ((gdb_byte *) str, hexstr, len);
+  bin2hex ((gdb_byte *) str, hexstr, len);
   return hexstr;
 }
 
This page took 0.034725 seconds and 4 git commands to generate.