From: Tom Tromey <tromey@redhat.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@redhat.com>
Subject: [RFC 6/9] replace convert_int_to_ascii with bin2hex
Date: Mon, 20 Jan 2014 19:18:00 -0000 [thread overview]
Message-ID: <1390245501-1186-7-git-send-email-tromey@redhat.com> (raw)
In-Reply-To: <1390245501-1186-1-git-send-email-tromey@redhat.com>
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-01-20 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-01-20 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 | 5 +++++
gdb/common/rsp-low.c | 16 ----------------
gdb/common/rsp-low.h | 2 --
gdb/gdbserver/ChangeLog | 12 ++++++++++++
gdb/gdbserver/ax.c | 2 +-
gdb/gdbserver/regcache.c | 7 +++----
gdb/gdbserver/remote-utils.c | 4 ++--
gdb/gdbserver/server.c | 2 +-
gdb/gdbserver/tracepoint.c | 10 +++++-----
9 files changed, 29 insertions(+), 31 deletions(-)
diff --git a/gdb/common/rsp-low.c b/gdb/common/rsp-low.c
index e288c6a..ea044ee 100644
--- a/gdb/common/rsp-low.c
+++ b/gdb/common/rsp-low.c
@@ -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,
diff --git a/gdb/common/rsp-low.h b/gdb/common/rsp-low.h
index 4903cd8..8c70dee 100644
--- a/gdb/common/rsp-low.h
+++ b/gdb/common/rsp-low.h
@@ -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
diff --git a/gdb/gdbserver/ax.c b/gdb/gdbserver/ax.c
index f62a613..1eefaf3 100644
--- a/gdb/gdbserver/ax.c
+++ b/gdb/gdbserver/ax.c
@@ -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;
}
diff --git a/gdb/gdbserver/regcache.c b/gdb/gdbserver/regcache.c
index f51e498..6e5aa08 100644
--- a/gdb/gdbserver/regcache.c
+++ b/gdb/gdbserver/regcache.c
@@ -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
diff --git a/gdb/gdbserver/remote-utils.c b/gdb/gdbserver/remote-utils.c
index 9d0ec55..a10af64 100644
--- a/gdb/gdbserver/remote-utils.c
+++ b/gdb/gdbserver/remote-utils.c
@@ -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);
}
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index 2fe81cf..a53d9a2 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -3487,7 +3487,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);
diff --git a/gdb/gdbserver/tracepoint.c b/gdb/gdbserver/tracepoint.c
index 8dffe83..8be12ed 100644
--- a/gdb/gdbserver/tracepoint.c
+++ b/gdb/gdbserver/tracepoint.c
@@ -3648,7 +3648,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. */
@@ -3767,7 +3767,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),
@@ -3856,7 +3856,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),
@@ -4026,7 +4026,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
@@ -6915,7 +6915,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;
}
--
1.8.1.4
next prev parent reply other threads:[~2014-01-20 19:18 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-20 19:18 [RFC 0/9] move more code into common/ Tom Tromey
2014-01-20 19:18 ` [RFC 1/9] share "cell" code Tom Tromey
2014-02-05 20:05 ` Pedro Alves
2014-02-05 20:13 ` Tom Tromey
2014-02-06 2:28 ` Yao Qi
2014-02-06 18:51 ` Tom Tromey
2014-01-20 19:18 ` [RFC 3/9] don't let bin2hex call strlen Tom Tromey
2014-02-05 20:36 ` Pedro Alves
2014-01-20 19:18 ` [RFC 2/9] move some rsp bits into rsp-low.h Tom Tromey
2014-01-21 3:24 ` Yao Qi
2014-02-05 20:33 ` Pedro Alves
2014-02-06 18:56 ` Tom Tromey
2014-02-06 19:08 ` Pedro Alves
2014-01-20 19:18 ` Tom Tromey [this message]
2014-02-05 20:39 ` [RFC 6/9] replace convert_int_to_ascii with bin2hex Pedro Alves
2014-01-20 19:23 ` [RFC 5/9] replace hexify " Tom Tromey
2014-02-05 20:38 ` Pedro Alves
2014-01-20 19:23 ` [RFC 9/9] update rsp-low comments Tom Tromey
2014-02-05 22:22 ` Pedro Alves
2014-01-20 19:23 ` [RFC 4/9] don't let hexify call strlen Tom Tromey
2014-02-05 20:37 ` Pedro Alves
2014-01-20 19:23 ` [RFC 8/9] replace convert_ascii_to_int with hex2bin Tom Tromey
2014-02-05 22:18 ` Pedro Alves
2014-01-20 19:38 ` [RFC 7/9] replace unhexify " Tom Tromey
2014-02-05 22:14 ` Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1390245501-1186-7-git-send-email-tromey@redhat.com \
--to=tromey@redhat.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox