From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 78074 invoked by alias); 14 Jun 2015 19:26:06 -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 78024 invoked by uid 89); 14 Jun 2015 19:26:05 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.5 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=no 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 (AES256-GCM-SHA384 encrypted) ESMTPS; Sun, 14 Jun 2015 19:26:03 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 9757019F384; Sun, 14 Jun 2015 19:26:01 +0000 (UTC) Received: from host1.jankratochvil.net (ovpn-116-41.ams2.redhat.com [10.36.116.41]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t5EJQ0pB032463; Sun, 14 Jun 2015 15:26:00 -0400 Subject: [PATCH v7 02/10] Merge multiple hex conversions From: Jan Kratochvil To: gdb-patches@sourceware.org Cc: Aleksandar Ristovski Date: Sun, 14 Jun 2015 19:26:00 -0000 Message-ID: <20150614192559.18346.31036.stgit@host1.jankratochvil.net> In-Reply-To: <20150614192542.18346.87859.stgit@host1.jankratochvil.net> References: <20150614192542.18346.87859.stgit@host1.jankratochvil.net> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2015-06/txt/msg00283.txt.bz2 Hi, here most of the patch has been reimplemented in the meantime and this is only a small remaint. Approved by: https://sourceware.org/ml/gdb-patches/2014-05/msg00366.html Jan gdb/gdbserver/ChangeLog 2014-02-26 Aleksandar Ristovski Merge multiple hex conversions. * gdbreplay.c (tohex): Rename to 'fromhex'. (logchar): Use fromhex. gdb/ChangeLog 2014-02-26 Aleksandar Ristovski Merge multiple hex conversions. * monitor.c: Include rsp-low.h. (fromhex): Remove definition. --- gdb/gdbserver/gdbreplay.c | 6 +++--- gdb/monitor.c | 16 +--------------- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/gdb/gdbserver/gdbreplay.c b/gdb/gdbserver/gdbreplay.c index a02a824..79aa8aa 100644 --- a/gdb/gdbserver/gdbreplay.c +++ b/gdb/gdbserver/gdbreplay.c @@ -259,7 +259,7 @@ remote_open (char *name) } static int -tohex (int ch) +fromhex (int ch) { if (ch >= '0' && ch <= '9') { @@ -322,11 +322,11 @@ logchar (FILE *fp) ch2 = fgetc (fp); fputc (ch2, stdout); fflush (stdout); - ch = tohex (ch2) << 4; + ch = fromhex (ch2) << 4; ch2 = fgetc (fp); fputc (ch2, stdout); fflush (stdout); - ch |= tohex (ch2); + ch |= fromhex (ch2); break; default: /* Treat any other char as just itself */ diff --git a/gdb/monitor.c b/gdb/monitor.c index 548dae3..c7f5fc7 100644 --- a/gdb/monitor.c +++ b/gdb/monitor.c @@ -54,6 +54,7 @@ #include "regcache.h" #include "gdbthread.h" #include "readline/readline.h" +#include "rsp-low.h" static char *dev_name; static struct target_ops *targ_ops; @@ -225,21 +226,6 @@ monitor_error (char *function, char *message, message, safe_string); } -/* Convert hex digit A to a number. */ - -static int -fromhex (int a) -{ - if (a >= '0' && a <= '9') - return a - '0'; - else if (a >= 'a' && a <= 'f') - return a - 'a' + 10; - else if (a >= 'A' && a <= 'F') - return a - 'A' + 10; - else - error (_("Invalid hex digit %d"), a); -} - /* monitor_vsprintf - similar to vsprintf but handles 64-bit addresses This function exists to get around the problem that many host platforms