[RFC] convert a host address to a string

Joel Brobecker brobecker@adacore.com
Tue Jan 13 12:09:00 GMT 2009


Here is the patch that I ended checkin in...

2009-01-13  Mark Kettenis  <kettenis@gnu.org>

        * utils.c (host_address_to_string): Reimplement in a way that
        avoids the cast of the address to long.

Tested on x86-linux and x86-windows.  I also re-built the debugger
on Vista64, and used "set debug arch" to verify that it can print
host addresses.

-- 
Joel
-------------- next part --------------
Index: utils.c
===================================================================
RCS file: /cvs/src/src/gdb/utils.c,v
retrieving revision 1.203
diff -u -p -r1.203 utils.c
--- utils.c	7 Jan 2009 12:11:07 -0000	1.203
+++ utils.c	13 Jan 2009 12:04:25 -0000
@@ -3071,10 +3071,7 @@ host_address_to_string (const void *addr
 {
   char *str = get_cell ();
 
-  /* We could use the %p conversion specifier to sprintf if we had any
-     way of knowing whether this host supports it.  But the following
-     should work on the Alpha and on 32 bit machines.  */
-  sprintf (str, "0x%lx", (unsigned long) addr);
+  xsnprintf (str, CELLSIZE, "0x%s", phex_nz ((uintptr_t) addr, sizeof (addr)));
   return str;
 }
 


More information about the Gdb-patches mailing list