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] |
> > 3. Work through uintptr_t. > > > > #ifdef PRINTF_HAS_LONG_LONG > > fprintf (buf, "0x%llx", (unsigned long long) (uintptr_t) address); > > #else > > fprintf (buf, "0x%lx", (unsigned long) (uintptr_t) address); > > #endif > > This wouldn't be the first place where we'd use a double cast in > connection with intptr_t/uintptr_t. So I'd say that while this is a > bit ugly, it's certainly acceptable. It's by far the simplest way to > fix things. Here is a new patch implementing this approach. As I told Kai, it's probably not going to work for x86_64/XP, but it works for x86_64/Vista (I think Kai agreed to take on the job of improving this approach to work on XP as well :-). 2009-01-09 Joel Brobecker <brobecker@adacore.com> * utils.c (host_address_to_string): Cast the address to uintptr_t first to avoid a possible compilation warning about casting to an integer of the wrong size. Then format the address using unsigned long long if supported by printf. Otherwise, fallback on using usingned long, hoping that long is large enough to hold an address. Tested on x86-linux. I also verified that it still builds on x86_64 Vista, as well as x86/Windows XP (on XP, PRINTF_HAS_LONG_LONG is undefined). -- Joel
Attachment:
host_addr_to_str.diff
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |