This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC] convert a host address to a string


The host_address_to_string function converts the host address to
a string using sprintf after having converted the address to an
unsigned long.

Unfortunately for us, on x86_64-windows, unsigned long is not big
enough to hold an address. My initial approach was to detect this case
by using a configure check which defines HOST_IS_LLP64 if sizeof (void*)
is 8 while sizeof (long) is 4.

Mark's reaction was that we should be able to use something more elegant.
One of the things we could do, perhaps, is use %p, which is mentioned by
the comment inside the function.  I checked the C90 draft, and %p is
definitely mentioned, so I suspect it's fine to use it assuming we
require C90. The problem is, are we going to break the build on some
targets if we do?

2009-01-07  Joel Brobecker  <brobecker@adacore.com>

        * configure.ac: Define HOST_IS_LLP64 if the host uses the LLP64 ABI.
        * configure, config.in: Regenerate.
        * utils.c (host_address_to_string): Use "long long" to print
        addresses rather than "long" if HOST_IS_LLP64 is defined.

Tested on x86-linux, x86-windows and x86_64-windows.

Thoughts?

-- 
Joel

Attachment: print_addr2.diff
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]