From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1771 invoked by alias); 20 Jan 2014 19:23:47 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 1679 invoked by uid 89); 20 Jan 2014 19:23:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 20 Jan 2014 19:23:45 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s0KJIS9B002996 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 20 Jan 2014 14:18:28 -0500 Received: from barimba.redhat.com (ovpn-113-85.phx2.redhat.com [10.3.113.85]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s0KJIND0031799; Mon, 20 Jan 2014 14:18:27 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFC 8/9] replace convert_ascii_to_int with hex2bin Date: Mon, 20 Jan 2014 19:23:00 -0000 Message-Id: <1390245501-1186-9-git-send-email-tromey@redhat.com> In-Reply-To: <1390245501-1186-1-git-send-email-tromey@redhat.com> References: <1390245501-1186-1-git-send-email-tromey@redhat.com> X-SW-Source: 2014-01/txt/msg00755.txt.bz2 convert_ascii_to_int is identical to hex2bin. This removes the former. 2014-01-20 Tom Tromey * common/rsp-low.c (convert_ascii_to_int): Remove. * common/rsp-low.h (convert_ascii_to_int): Don't declare. 2014-01-20 Tom Tromey * ax.c (gdb_parse_agent_expr): Use hex2bin, not convert_ascii_to_int. * regcache.c (registers_to_string): Likewise. * remote-utils.c (decode_M_packet): Likewise. * server.c (process_serial_event): Likewise. --- gdb/ChangeLog | 5 +++++ gdb/common/rsp-low.c | 12 ------------ gdb/common/rsp-low.h | 2 -- gdb/gdbserver/ChangeLog | 8 ++++++++ gdb/gdbserver/ax.c | 2 +- gdb/gdbserver/regcache.c | 2 +- gdb/gdbserver/remote-utils.c | 2 +- gdb/gdbserver/server.c | 4 ++-- 8 files changed, 18 insertions(+), 19 deletions(-) diff --git a/gdb/common/rsp-low.c b/gdb/common/rsp-low.c index 9c1a56f..d7a1280 100644 --- a/gdb/common/rsp-low.c +++ b/gdb/common/rsp-low.c @@ -127,18 +127,6 @@ hex2bin (const char *hex, gdb_byte *bin, int count) return i; } -void -convert_ascii_to_int (const char *from, unsigned char *to, int n) -{ - int nib1, nib2; - while (n--) - { - nib1 = fromhex (*from++); - nib2 = fromhex (*from++); - *to++ = (((nib1 & 0x0f) << 4) & 0xf0) | (nib2 & 0x0f); - } -} - int bin2hex (const gdb_byte *bin, char *hex, int count) { diff --git a/gdb/common/rsp-low.h b/gdb/common/rsp-low.h index 229b909..611dba3 100644 --- a/gdb/common/rsp-low.h +++ b/gdb/common/rsp-low.h @@ -36,8 +36,6 @@ extern char *unpack_varlen_hex (char *buff, ULONGEST *result); extern int hex2bin (const char *hex, gdb_byte *bin, int count); -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); /* Convert BUFFER, binary data at least LEN bytes long, into escaped diff --git a/gdb/gdbserver/ax.c b/gdb/gdbserver/ax.c index 1eefaf3..ef659dc 100644 --- a/gdb/gdbserver/ax.c +++ b/gdb/gdbserver/ax.c @@ -105,7 +105,7 @@ gdb_parse_agent_expr (char **actparm) aexpr = xmalloc (sizeof (struct agent_expr)); aexpr->length = xlen; aexpr->bytes = xmalloc (xlen); - convert_ascii_to_int (act, aexpr->bytes, xlen); + hex2bin (act, aexpr->bytes, xlen); *actparm = act + (xlen * 2); return aexpr; } diff --git a/gdb/gdbserver/regcache.c b/gdb/gdbserver/regcache.c index 6e5aa08..bed10b48 100644 --- a/gdb/gdbserver/regcache.c +++ b/gdb/gdbserver/regcache.c @@ -234,7 +234,7 @@ registers_from_string (struct regcache *regcache, char *buf) if (len > tdesc->registers_size * 2) len = tdesc->registers_size * 2; } - convert_ascii_to_int (buf, registers, len / 2); + hex2bin (buf, registers, len / 2); } struct reg * diff --git a/gdb/gdbserver/remote-utils.c b/gdb/gdbserver/remote-utils.c index a10af64..22253d4 100644 --- a/gdb/gdbserver/remote-utils.c +++ b/gdb/gdbserver/remote-utils.c @@ -1270,7 +1270,7 @@ decode_M_packet (char *from, CORE_ADDR *mem_addr_ptr, unsigned int *len_ptr, if (*to_p == NULL) *to_p = xmalloc (*len_ptr); - convert_ascii_to_int (&from[i++], *to_p, *len_ptr); + hex2bin (&from[i++], *to_p, *len_ptr); } int diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c index 255a048..5b4d202 100644 --- a/gdb/gdbserver/server.c +++ b/gdb/gdbserver/server.c @@ -3509,7 +3509,7 @@ process_serial_event (void) break; case 'C': require_running (own_buf); - convert_ascii_to_int (own_buf + 1, &sig, 1); + hex2bin (own_buf + 1, &sig, 1); if (gdb_signal_to_host_p (sig)) signal = gdb_signal_to_host (sig); else @@ -3518,7 +3518,7 @@ process_serial_event (void) break; case 'S': require_running (own_buf); - convert_ascii_to_int (own_buf + 1, &sig, 1); + hex2bin (own_buf + 1, &sig, 1); if (gdb_signal_to_host_p (sig)) signal = gdb_signal_to_host (sig); else -- 1.8.1.4