From 10e86dd77848e00024b5de420c18e13db9a103c9 Mon Sep 17 00:00:00 2001 From: Doug Evans Date: Mon, 21 Dec 2009 20:52:53 +0000 Subject: [PATCH] * configure.ac: Check for dladdr. * config.in: Regenerate. * configure: Regenerate. * thread-db.c (dladdr_to_soname): Only define ifdef HAVE_DLADDR. (try_thread_db_load): Update. --- gdb/gdbserver/ChangeLog | 6 ++++++ gdb/gdbserver/config.in | 3 +++ gdb/gdbserver/configure | 15 +++++++++++++++ gdb/gdbserver/configure.ac | 11 ++++++++++- gdb/gdbserver/thread-db.c | 6 ++++++ 5 files changed, 40 insertions(+), 1 deletion(-) diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index 0222594bd6b..6cd1b792a3c 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,5 +1,11 @@ 2009-12-21 Doug Evans + * configure.ac: Check for dladdr. + * config.in: Regenerate. + * configure: Regenerate. + * thread-db.c (dladdr_to_soname): Only define ifdef HAVE_DLADDR. + (try_thread_db_load): Update. + * linux-low.c (my_waitpid): Delete unnecessary prototype. 2009-12-18 Doug Evans diff --git a/gdb/gdbserver/config.in b/gdb/gdbserver/config.in index 7c8996631f6..2096cfab6bc 100644 --- a/gdb/gdbserver/config.in +++ b/gdb/gdbserver/config.in @@ -15,6 +15,9 @@ don't. */ #undef HAVE_DECL_STRERROR +/* Define to 1 if you have the `dladdr' function. */ +#undef HAVE_DLADDR + /* Define if has elf_fpregset_t. */ #undef HAVE_ELF_FPREGSET_T diff --git a/gdb/gdbserver/configure b/gdb/gdbserver/configure index 93aeb780d64..47bd81a1c40 100755 --- a/gdb/gdbserver/configure +++ b/gdb/gdbserver/configure @@ -3816,6 +3816,21 @@ done +old_LIBS="$LIBS" +LIBS="$LIBS -ldl" +for ac_func in dladdr +do : + ac_fn_c_check_func "$LINENO" "dladdr" "ac_cv_func_dladdr" +if test "x$ac_cv_func_dladdr" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_DLADDR 1 +_ACEOF + +fi +done + +LIBS="$old_LIBS" + have_errno=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for errno" >&5 $as_echo_n "checking for errno... " >&6; } diff --git a/gdb/gdbserver/configure.ac b/gdb/gdbserver/configure.ac index 215387dff4a..6fea6950a9d 100644 --- a/gdb/gdbserver/configure.ac +++ b/gdb/gdbserver/configure.ac @@ -1,5 +1,5 @@ dnl Autoconf configure script for GDB server. -dnl Copyright (C) 2000, 2002, 2003, 2004, 2005, 2006, 2007, 2008 +dnl Copyright (C) 2000, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 dnl Free Software Foundation, Inc. dnl dnl This file is part of GDB. @@ -45,6 +45,15 @@ AC_CHECK_HEADERS(sgtty.h termio.h termios.h sys/reg.h string.h dnl AC_CHECK_FUNCS(pread pwrite pread64) AC_REPLACE_FUNCS(memmem) +dnl dladdr is glibc-specific. It is used by thread-db.c but only for +dnl debugging messages. It lives in -ldl which is handled below so we don't +dnl use AC_CHECK_LIB (or AC_SEARCH_LIBS) here. Instead we just temporarily +dnl augment LIBS. +old_LIBS="$LIBS" +LIBS="$LIBS -ldl" +AC_CHECK_FUNCS(dladdr) +LIBS="$old_LIBS" + have_errno=no AC_MSG_CHECKING(for errno) AC_TRY_LINK([ diff --git a/gdb/gdbserver/thread-db.c b/gdb/gdbserver/thread-db.c index f27308263f4..e169a50f3e5 100644 --- a/gdb/gdbserver/thread-db.c +++ b/gdb/gdbserver/thread-db.c @@ -596,6 +596,8 @@ try_thread_db_load_1 (void *handle) return 1; } +#ifdef HAVE_DLADDR + /* Lookup a library in which given symbol resides. Note: this is looking in the GDBSERVER process, not in the inferior. Returns library name, or NULL. */ @@ -610,6 +612,8 @@ dladdr_to_soname (const void *addr) return NULL; } +#endif + static int try_thread_db_load (const char *library) { @@ -626,6 +630,7 @@ try_thread_db_load (const char *library) return 0; } +#ifdef HAVE_DLADDR if (debug_threads && strchr (library, '/') == NULL) { void *td_init; @@ -640,6 +645,7 @@ try_thread_db_load (const char *library) library, libpath); } } +#endif if (try_thread_db_load_1 (handle)) return 1; -- 2.30.2