From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9446 invoked by alias); 20 Jan 2014 19:38:52 -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 9433 invoked by uid 89); 20 Jan 2014 19:38:52 -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:38:51 +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 s0KJIRoS031956 (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 s0KJINCx031799; Mon, 20 Jan 2014 14:18:27 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFC 7/9] replace unhexify with hex2bin Date: Mon, 20 Jan 2014 19:38:00 -0000 Message-Id: <1390245501-1186-8-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/msg00756.txt.bz2 unhexify and hex2bin are identical, so this removes unhexify. The particular choice of which to keep was made on the basis of parallelism with the earlier patch that removed hexify. 2014-01-20 Tom Tromey * common/rsp-low.h (unhexify): Don't declare. * common/rsp-low.c (unhexify): Remove. 2014-01-20 Tom Tromey * server.c (handle_query, handle_v_run): Use hex2bin, not unhexify. * tracepoint.c (cmd_qtdpsrc, cmd_qtdv, cmd_qtnotes): Likewise. --- gdb/ChangeLog | 5 +++++ gdb/common/rsp-low.c | 19 ------------------- gdb/common/rsp-low.h | 2 -- gdb/gdbserver/ChangeLog | 6 ++++++ gdb/gdbserver/server.c | 5 +++-- gdb/gdbserver/tracepoint.c | 10 +++++----- 6 files changed, 19 insertions(+), 28 deletions(-) diff --git a/gdb/common/rsp-low.c b/gdb/common/rsp-low.c index ea044ee..9c1a56f 100644 --- a/gdb/common/rsp-low.c +++ b/gdb/common/rsp-low.c @@ -127,25 +127,6 @@ hex2bin (const char *hex, gdb_byte *bin, int count) return i; } -int -unhexify (char *bin, const char *hex, int count) -{ - int i; - - for (i = 0; i < count; i++) - { - if (hex[0] == 0 || hex[1] == 0) - { - /* Hex string is short, or of uneven length. - Return the count that has been converted so far. */ - return i; - } - *bin++ = fromhex (hex[0]) * 16 + fromhex (hex[1]); - hex += 2; - } - return i; -} - void convert_ascii_to_int (const char *from, unsigned char *to, int n) { diff --git a/gdb/common/rsp-low.h b/gdb/common/rsp-low.h index 8c70dee..229b909 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 int unhexify (char *bin, const char *hex, 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); diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c index a53d9a2..255a048 100644 --- a/gdb/gdbserver/server.c +++ b/gdb/gdbserver/server.c @@ -1931,7 +1931,8 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p) return; } - if ((len % 2) != 0 || unhexify (mon, own_buf + 6, len / 2) != len / 2) + if ((len % 2) != 0 + || hex2bin (own_buf + 6, (gdb_byte *) mon, len / 2) != len / 2) { write_enn (own_buf); free (mon); @@ -2314,7 +2315,7 @@ handle_v_run (char *own_buf) { /* FIXME: Fail request if out of memory instead of dying. */ new_argv[i] = xmalloc (1 + (next_p - p) / 2); - unhexify (new_argv[i], p, (next_p - p) / 2); + hex2bin (p, (gdb_byte *) new_argv[i], (next_p - p) / 2); new_argv[i][(next_p - p) / 2] = '\0'; } diff --git a/gdb/gdbserver/tracepoint.c b/gdb/gdbserver/tracepoint.c index 8be12ed..2585191 100644 --- a/gdb/gdbserver/tracepoint.c +++ b/gdb/gdbserver/tracepoint.c @@ -2693,7 +2693,7 @@ cmd_qtdpsrc (char *own_buf) packet = unpack_varlen_hex (packet, &slen); ++packet; /* skip a colon */ src = xmalloc (slen + 1); - nbytes = unhexify (src, packet, strlen (packet) / 2); + nbytes = hex2bin (packet, (gdb_byte *) src, strlen (packet) / 2); src[nbytes] = '\0'; newlast = xmalloc (sizeof (struct source_string)); @@ -2735,7 +2735,7 @@ cmd_qtdv (char *own_buf) nbytes = strlen (packet) / 2; varname = xmalloc (nbytes + 1); - nbytes = unhexify (varname, packet, nbytes); + nbytes = hex2bin (packet, (gdb_byte *) varname, nbytes); varname[nbytes] = '\0'; tsv = create_trace_state_variable (num, 1); @@ -4093,7 +4093,7 @@ cmd_qtnotes (char *own_buf) packet = strchr (packet, ';'); nbytes = (packet - saved) / 2; user = xmalloc (nbytes + 1); - nbytes = unhexify (user, saved, nbytes); + nbytes = hex2bin (saved, (gdb_byte *) user, nbytes); user[nbytes] = '\0'; ++packet; /* skip the semicolon */ trace_debug ("User is '%s'", user); @@ -4107,7 +4107,7 @@ cmd_qtnotes (char *own_buf) packet = strchr (packet, ';'); nbytes = (packet - saved) / 2; notes = xmalloc (nbytes + 1); - nbytes = unhexify (notes, saved, nbytes); + nbytes = hex2bin (saved, (gdb_byte *) notes, nbytes); notes[nbytes] = '\0'; ++packet; /* skip the semicolon */ trace_debug ("Notes is '%s'", notes); @@ -4121,7 +4121,7 @@ cmd_qtnotes (char *own_buf) packet = strchr (packet, ';'); nbytes = (packet - saved) / 2; stopnote = xmalloc (nbytes + 1); - nbytes = unhexify (stopnote, saved, nbytes); + nbytes = hex2bin (saved, (gdb_byte *) stopnote, nbytes); stopnote[nbytes] = '\0'; ++packet; /* skip the semicolon */ trace_debug ("tstop note is '%s'", stopnote); -- 1.8.1.4