This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFA] Check for dladdr in gdbserver
- From: dje at google dot com (Doug Evans)
- To: gdb-patches at sourceware dot org
- Date: Mon, 21 Dec 2009 10:12:34 -0800 (PST)
- Subject: [RFA] Check for dladdr in gdbserver
Hi.
gdbserver uses dladdr which is glibc-specific which android doesn't have.
Ok to check in?
NOTE: There's similar code in gdb/linux-thread-db.c but it isn't
compiled for android (android is a cross target) so I didn't change it.
I can add a similar patch there if required.
2009-12-21 Doug Evans <dje@google.com>
* 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.
Index: configure.ac
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/configure.ac,v
retrieving revision 1.30
diff -u -p -r1.30 configure.ac
--- configure.ac 17 Nov 2009 17:58:15 -0000 1.30
+++ configure.ac 21 Dec 2009 18:00:44 -0000
@@ -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 termio
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([
Index: thread-db.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/thread-db.c,v
retrieving revision 1.30
diff -u -p -r1.30 thread-db.c
--- thread-db.c 19 Dec 2009 00:29:11 -0000 1.30
+++ thread-db.c 21 Dec 2009 18:00:44 -0000
@@ -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;