diff mbox

[v2,2/6] Don't use sprintf_vma for CORE_ADDR

Message ID 20200225222243.8260-3-tom@tromey.com
State New
Headers show

Commit Message

Tom Tromey Feb. 25, 2020, 10:22 p.m. UTC
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 mbox

Patch

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