diff mbox

[v7,02/10] Merge multiple hex conversions

Message ID 20150614192559.18346.31036.stgit@host1.jankratochvil.net
State New
Headers show

Commit Message

Jan Kratochvil June 14, 2015, 7:25 p.m. UTC
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  <aristovski@qnx.com
	    Jan Kratochvil  <jan.kratochvil@redhat.com>

	Merge multiple hex conversions.
	* gdbreplay.c (tohex): Rename to 'fromhex'.
	(logchar): Use fromhex.

gdb/ChangeLog
2014-02-26  Aleksandar Ristovski  <aristovski@qnx.com
	    Jan Kratochvil  <jan.kratochvil@redhat.com>

	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(-)

Comments

Joel Brobecker June 15, 2015, 1:33 p.m. UTC | #1
> gdb/gdbserver/ChangeLog
> 2014-02-26  Aleksandar Ristovski  <aristovski@qnx.com
> 	    Jan Kratochvil  <jan.kratochvil@redhat.com>
> 
> 	Merge multiple hex conversions.
> 	* gdbreplay.c (tohex): Rename to 'fromhex'.
> 	(logchar): Use fromhex.

I hesitated on this one, since I was wondering why we have two
implementations of fromhex, one there, and one in rsp-low.c.
I'm guessing it's because this on in gdbreplay has a call to
"exit" (!!!). But, in the end, it seems to me that this patch
is already an improvement over the previous situation, and I'm not
really sure of the reasons behind the current implementation,
so we can leave this as is for now. (FTAOD: this is OK).

> gdb/ChangeLog
> 2014-02-26  Aleksandar Ristovski  <aristovski@qnx.com
> 	    Jan Kratochvil  <jan.kratochvil@redhat.com>
> 
> 	Merge multiple hex conversions.
> 	* monitor.c: Include rsp-low.h.
> 	(fromhex): Remove definition.

OK.
Jan Kratochvil June 15, 2015, 3:09 p.m. UTC | #2
On Mon, 15 Jun 2015 15:33:10 +0200, Joel Brobecker wrote:
> > gdb/ChangeLog
> > 2014-02-26  Aleksandar Ristovski  <aristovski@qnx.com
> > 	    Jan Kratochvil  <jan.kratochvil@redhat.com>
> > 
> > 	Merge multiple hex conversions.
> > 	* monitor.c: Include rsp-low.h.
> > 	(fromhex): Remove definition.
> 
> OK.

Checked in:
	909c2cdaa78f5c33ce61a3b47e86f831025d0a02


Jan
diff mbox

Patch

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