From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Subject: [PATCH v2 1/8] Remove mem2hex
Date: Tue, 20 Jun 2023 11:36:37 -0600 [thread overview]
Message-ID: <20230619-ax-new-v2-1-47638d750dd7@tromey.com> (raw)
In-Reply-To: <20230619-ax-new-v2-0-47638d750dd7@tromey.com>
tracepoint.c has a 'mem2hex' function that is functionally equivalent
to bin2hex. This patch removes the redundancy.
---
gdb/tracepoint.c | 30 ++----------------------------
1 file changed, 2 insertions(+), 28 deletions(-)
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index f297cea5b43..0af7404aef1 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -69,7 +69,7 @@
the worst case of maximum length for each of the pieces of a
continuation packet.
- NOTE: expressions get mem2hex'ed otherwise this would be twice as
+ NOTE: expressions get bin2hex'ed otherwise this would be twice as
large. (400 - 31)/2 == 184 */
#define MAX_AGENT_EXPR_LEN 184
@@ -156,7 +156,6 @@ static std::string trace_stop_notes;
/* support routines */
struct collection_list;
-static char *mem2hex (gdb_byte *, char *, int);
static counted_command_line all_tracepoint_actions (struct breakpoint *);
@@ -1226,7 +1225,7 @@ collection_list::stringify ()
end += 10; /* 'X' + 8 hex digits + ',' */
count += 10;
- end = mem2hex (m_aexprs[i]->buf, end, m_aexprs[i]->len);
+ end += 2 * bin2hex (m_aexprs[i]->buf, end, m_aexprs[i]->len);
count += 2 * m_aexprs[i]->len;
}
@@ -2888,31 +2887,6 @@ set_trace_stop_notes (const char *args, int from_tty,
warning (_("Target does not support trace notes, stop note ignored"));
}
-/* Convert the memory pointed to by mem into hex, placing result in buf.
- * Return a pointer to the last char put in buf (null)
- * "stolen" from sparc-stub.c
- */
-
-static const char hexchars[] = "0123456789abcdef";
-
-static char *
-mem2hex (gdb_byte *mem, char *buf, int count)
-{
- gdb_byte ch;
-
- while (count-- > 0)
- {
- ch = *mem++;
-
- *buf++ = hexchars[ch >> 4];
- *buf++ = hexchars[ch & 0xf];
- }
-
- *buf = 0;
-
- return buf;
-}
-
int
get_traceframe_number (void)
{
--
2.39.2
next prev parent reply other threads:[~2023-06-20 17:36 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-20 17:36 [PATCH v2 0/8] C++-ify and simplify agent expressions Tom Tromey
2023-06-20 17:36 ` Tom Tromey [this message]
2023-06-20 17:36 ` [PATCH v2 2/8] Use gdb::byte_vector in agent_expr Tom Tromey
2023-06-24 1:40 ` Simon Marchi
2023-06-30 3:16 ` Tom Tromey
2023-06-20 17:36 ` [PATCH v2 3/8] Use std::vector<bool> for agent_expr::reg_mask Tom Tromey
2023-06-21 16:16 ` Simon Marchi
2023-06-23 2:37 ` Tom Tromey
2023-06-20 17:36 ` [PATCH v2 4/8] Simplify agent_expr constructor Tom Tromey
2023-06-20 17:36 ` [PATCH v2 5/8] Use bool for agent_expr::tracing Tom Tromey
2023-06-20 17:36 ` [PATCH v2 6/8] Make aop_map 'static' Tom Tromey
2023-06-20 17:36 ` [PATCH v2 7/8] Remove aop_last Tom Tromey
2023-06-20 17:36 ` [PATCH v2 8/8] Use ARRAY_SIZE in ax-general.c Tom Tromey
2023-06-20 17:45 ` [PATCH v2 0/8] C++-ify and simplify agent expressions John Baldwin
2023-06-20 18:01 ` Tom Tromey
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=20230619-ax-new-v2-1-47638d750dd7@tromey.com \
--to=tom@tromey.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).