public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [RFC] [gdbserver] paddress() can truncate its argument
@ 2010-07-16 20:49 Ozkan Sezer
  2010-07-20 17:51 ` [ping] " Ozkan Sezer
  0 siblings, 1 reply; 4+ messages in thread
From: Ozkan Sezer @ 2010-07-16 20:49 UTC (permalink / raw)
  To: gdb-patches

Hi:

Noticed this while messing around with win64 support: paddress() casts
its CORE_ADDR argument (which is specifically defined as long long in
gdbserver) to long, probably assuming LP64 convention. For win64, which
is LLP64, it is not true (sizeof(long) == 4 always) and it truncates
its argument.

Shouldn't paddress() just return phex_nz() instead, like the following:

Index: utils.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/utils.c,v
retrieving revision 1.23
diff -u -p -r1.23 utils.c
--- utils.c	1 Jun 2010 13:20:52 -0000	1.23
+++ utils.c	16 Jul 2010 20:41:14 -0000
@@ -257,17 +257,6 @@ xsnprintf (char *str, size_t size, const
   return ret;
 }

-/* Convert a CORE_ADDR into a HEX string, like %lx.
-   The result is stored in a circular static buffer, NUMCELLS deep.  */
-
-char *
-paddress (CORE_ADDR addr)
-{
-  char *str = get_cell ();
-  xsnprintf (str, CELLSIZE, "%lx", (long) addr);
-  return str;
-}
-
 static char *
 decimal2str (char *sign, ULONGEST addr, int width)
 {
@@ -372,3 +361,12 @@ phex_nz (ULONGEST l, int sizeof_l)

   return str;
 }
+
+/* Convert a CORE_ADDR into a HEX string, like %lx.
+   The result is stored in a circular static buffer, NUMCELLS deep.  */
+
+char *
+paddress (CORE_ADDR addr)
+{
+  return phex_nz (addr, sizeof (CORE_ADDR));
+}

Comments?

--
Ozkan

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-07-20 18:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-16 20:49 [RFC] [gdbserver] paddress() can truncate its argument Ozkan Sezer
2010-07-20 17:51 ` [ping] " Ozkan Sezer
2010-07-20 18:00   ` Pedro Alves
2010-07-20 18:12     ` Ozkan Sezer

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