diff --git a/gdb/configure.ac b/gdb/configure.ac index e970234..8774309 100644 --- a/gdb/configure.ac +++ b/gdb/configure.ac @@ -1189,6 +1189,20 @@ if test $gdb_cv_printf_has_long_long = yes; then [Define to 1 if the "%ll" format works to print long longs.]) fi +# Check if the host is LLP64 (pointers are 64bits and "long" is only 32bits). + +AC_CACHE_CHECK([host is LLP64], + gdb_cv_host_is_llp64, + [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], +[[return !(sizeof (void *) == 8 && sizeof (long) == 4);]])], + gdb_cv_host_is_llp64=yes, + gdb_cv_host_is_llp64=no, + gdb_cv_host_is_llp64=no)]) +if test $gdb_cv_host_is_llp64 = yes; then + AC_DEFINE(HOST_IS_LLP64, 1, + [Define to 1 if host is LLP64 (pointers is 64bits and "long" is32bits)]) +fi + # Check if the compiler and runtime support printing decfloats. AC_CACHE_CHECK([for decfloat support in printf], diff --git a/gdb/utils.c b/gdb/utils.c index 2549a3c..d289509 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -3066,9 +3066,15 @@ 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. */ + way of knowing whether this host supports it. */ +#ifdef HOST_IS_LLP64 + /* On LLP64 hosts, longs are only 32bits whereas pointers are 64bit. + Use a "long long" to print our address. */ + sprintf (str, "0x%llx", (unsigned long long) addr); +#else + /* The following should work on the Alpha and on 32 bit machines. */ sprintf (str, "0x%lx", (unsigned long) addr); +#endif return str; }