From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22180 invoked by alias); 21 Dec 2009 18:12:45 -0000 Received: (qmail 22169 invoked by uid 22791); 21 Dec 2009 18:12:44 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,HK_OBFDOM,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.44.51) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 21 Dec 2009 18:12:38 +0000 Received: from spaceape8.eur.corp.google.com (spaceape8.eur.corp.google.com [172.28.16.142]) by smtp-out.google.com with ESMTP id nBLICaUn020687 for ; Mon, 21 Dec 2009 10:12:36 -0800 Received: from ruffy.mtv.corp.google.com (ruffy.mtv.corp.google.com [172.18.118.116]) by spaceape8.eur.corp.google.com with ESMTP id nBLICYdg020801 for ; Mon, 21 Dec 2009 10:12:35 -0800 Received: by ruffy.mtv.corp.google.com (Postfix, from userid 67641) id 2CBBD84412; Mon, 21 Dec 2009 10:12:34 -0800 (PST) To: gdb-patches@sourceware.org Subject: [RFA] Check for dladdr in gdbserver Message-Id: <20091221181234.2CBBD84412@ruffy.mtv.corp.google.com> Date: Mon, 21 Dec 2009 18:12:00 -0000 From: dje@google.com (Doug Evans) X-System-Of-Record: true X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2009-12/txt/msg00312.txt.bz2 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 * 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;