From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH v2 2/6] Don't use sprintf_vma for CORE_ADDR
Date: Tue, 25 Feb 2020 22:22:00 -0000 [thread overview]
Message-ID: <20200225222243.8260-3-tom@tromey.com> (raw)
In-Reply-To: <20200225222243.8260-1-tom@tromey.com>
A few spots in gdb use sprintf_vma to print a CORE_ADDR. This will
fail on a 32-bit build once CORE_ADDR is always a 64-bit type.
This patch replaces these calls with phex instead.
2020-02-25 Tom Tromey <tom@tromey.com>
* remote.c (remote_target::download_tracepoint)
(remote_target::enable_tracepoint)
(remote_target::disable_tracepoint): Use phex, not sprintf_vma.
* breakpoint.c (print_recreate_masked_watchpoint): Use phex, not
sprintf_vma.
---
gdb/ChangeLog | 8 ++++++++
gdb/breakpoint.c | 5 ++---
gdb/remote.c | 12 +++++-------
3 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 5a9352c26fe..e49025461ba 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -10400,7 +10400,6 @@ static void
print_recreate_masked_watchpoint (struct breakpoint *b, struct ui_file *fp)
{
struct watchpoint *w = (struct watchpoint *) b;
- char tmp[40];
switch (b->type)
{
@@ -10418,8 +10417,8 @@ print_recreate_masked_watchpoint (struct breakpoint *b, struct ui_file *fp)
_("Invalid hardware watchpoint type."));
}
- sprintf_vma (tmp, w->hw_wp_mask);
- fprintf_unfiltered (fp, " %s mask 0x%s", w->exp_string, tmp);
+ fprintf_unfiltered (fp, " %s mask 0x%s", w->exp_string,
+ phex (w->hw_wp_mask, sizeof (CORE_ADDR)));
print_recreate_thread (b, fp);
}
diff --git a/gdb/remote.c b/gdb/remote.c
index 4a70ab3fb0d..026cedcbbdc 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -12814,7 +12814,7 @@ remote_target::download_tracepoint (struct bp_location *loc)
encode_actions_rsp (loc, &tdp_actions, &stepping_actions);
tpaddr = loc->address;
- sprintf_vma (addrbuf, tpaddr);
+ strcpy (addrbuf, phex (tpaddr, sizeof (CORE_ADDR)));
ret = snprintf (buf.data (), buf.size (), "QTDP:%x:%s:%c:%lx:%x",
b->number, addrbuf, /* address */
(b->enable_state == bp_enabled ? 'E' : 'D'),
@@ -13076,11 +13076,10 @@ void
remote_target::enable_tracepoint (struct bp_location *location)
{
struct remote_state *rs = get_remote_state ();
- char addr_buf[40];
- sprintf_vma (addr_buf, location->address);
xsnprintf (rs->buf.data (), get_remote_packet_size (), "QTEnable:%x:%s",
- location->owner->number, addr_buf);
+ location->owner->number,
+ phex (location->address, sizeof (CORE_ADDR)));
putpkt (rs->buf);
remote_get_noisy_reply ();
if (rs->buf[0] == '\0')
@@ -13093,11 +13092,10 @@ void
remote_target::disable_tracepoint (struct bp_location *location)
{
struct remote_state *rs = get_remote_state ();
- char addr_buf[40];
- sprintf_vma (addr_buf, location->address);
xsnprintf (rs->buf.data (), get_remote_packet_size (), "QTDisable:%x:%s",
- location->owner->number, addr_buf);
+ location->owner->number,
+ phex (location->address, sizeof (CORE_ADDR)));
putpkt (rs->buf);
remote_get_noisy_reply ();
if (rs->buf[0] == '\0')
--
2.17.2
next prev parent reply other threads:[~2020-02-25 22:22 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-25 22:22 [PATCH v2 0/6] Change gdbserver to use existing gdbsupport Tom Tromey
2020-02-25 22:22 ` [PATCH v2 6/6] " Tom Tromey
2020-02-25 22:22 ` [PATCH v2 5/6] Change gdbsupport not to rely on BFD Tom Tromey
2020-02-25 22:22 ` [PATCH v2 4/6] Fix gdbserver build when intl already built Tom Tromey
2020-02-25 22:22 ` Tom Tromey [this message]
2020-02-25 22:22 ` [PATCH v2 1/6] Fix CORE_ADDR size assertion in symfile-mem.c Tom Tromey
2020-02-25 22:22 ` [PATCH v2 3/6] Cast to bfd_vma in arm-tdep.c Tom Tromey
2020-03-11 3:38 ` Simon Marchi
2020-03-12 17:58 ` Tom Tromey
2020-03-12 18:05 ` Simon Marchi
2020-03-12 19:35 ` Tom Tromey
2020-03-11 0:30 ` [PATCH v2 0/6] Change gdbserver to use existing gdbsupport 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=20200225222243.8260-3-tom@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).