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]

[PATCH 4/4] Adds platform agnostic dynamic loading code.


Adds gdb-dlfcn.h and gdb-dlfcn.c which implement gdb_dlopen, gdb_dlsym and gdb_dlclose for POSIX and windows systems differently. This provides a compatibility layer between the platforms.

gdb/ChangeLog
	* gdb-dlfcn.h, gdb-dlfcn.c: New.
	* Makefile.in: Add gdb_dlcfn.c and gdb_dlcfn.h to the build system.
	* configure.ac, config.in: Check for -ldl and accordingly define HAVE_LIBDL.
---
 gdb/ChangeLog    |    6 ++++++
 gdb/Makefile.in  |    6 +++---
 gdb/config.in    |    3 +++
 gdb/configure    |   45 +++++++++++++++++++++++++++++++++++++++++++++
 gdb/configure.ac |    1 +
 5 files changed, 58 insertions(+), 3 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 656a42d..a0ddab4 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,11 @@
 2011-07-24  Sanjoy Das  <sdas@igalia.com>
 
+	* gdb-dlfcn.h, gdb-dlfcn.c: New.
+	* Makefile.in: Add gdb_dlcfn.c and gdb_dlcfn.h to the build system.
+	* configure.ac, config.in: Check for -ldl and accordingly define HAVE_LIBDL.
+
+2011-07-24  Sanjoy Das  <sdas@igalia.com>
+
 	* gdb.texinfo: Some documentation about the new JIT debug info reader functionality.
 
 2011-07-24  Sanjoy Das  <sdas@igalia.com>
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 7ed6136..edbf0bc 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -739,7 +739,7 @@ SFILES = ada-exp.y ada-lang.c ada-typeprint.c ada-valprint.c ada-tasks.c \
 	annotate.c common/signals.c copying.c dfp.c gdb.c inf-child.c \
 	regset.c sol-thread.c windows-termcap.c \
 	common/common-utils.c common/xml-utils.c \
-	common/ptid.c common/buffer.c
+	common/ptid.c common/buffer.c gdb-dlfcn.c
 
 LINTFILES = $(SFILES) $(YYFILES) $(CONFIG_SRCS) init.c
 
@@ -820,7 +820,7 @@ solib-darwin.h solib-ia64-hpux.h solib-spu.h windows-nat.h xcoffread.h \
 gnulib/extra/arg-nonnull.h gnulib/extra/c++defs.h gnulib/extra/warn-on-use.h \
 gnulib/stddef.in.h inline-frame.h \
 common/common-utils.h common/xml-utils.h common/buffer.h common/ptid.h \
-common/linux-osdata.h
+common/linux-osdata.h gdb-dlfcn.h
 
 # Header files that already have srcdir in them, or which are in objdir.
 
@@ -907,7 +907,7 @@ COMMON_OBS = $(DEPFILES) $(CONFIG_OBS) $(YYOBJ) \
 	target-descriptions.o target-memory.o xml-tdesc.o xml-builtin.o \
 	inferior.o osdata.o gdb_usleep.o record.o gcore.o \
 	jit.o progspace.o \
-	common-utils.o buffer.o ptid.o
+	common-utils.o buffer.o ptid.o gdb-dlfcn.o
 
 TSOBS = inflow.o
 
diff --git a/gdb/config.in b/gdb/config.in
index 8862144..92dbb15 100644
--- a/gdb/config.in
+++ b/gdb/config.in
@@ -985,3 +985,6 @@
 
 /* The directory to search for JIT debug info reader plugins. */
 #undef GDB_JIT_READER_PATH
+
+/* Define if -ldl will work. */
+#undef HAVE_LIBDL
diff --git a/gdb/configure b/gdb/configure
index 3d984c7..ea84519 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -9935,6 +9935,51 @@ _ACEOF
 
 
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
+$as_echo_n "checking for dlopen in -ldl... " >&6; }
+if test "${ac_cv_lib_dl_dlopen+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dlopen ();
+int
+main ()
+{
+return dlopen ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_dl_dlopen=yes
+else
+  ac_cv_lib_dl_dlopen=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
+$as_echo "$ac_cv_lib_dl_dlopen" >&6; }
+if test "x$ac_cv_lib_dl_dlopen" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBDL 1
+_ACEOF
+
+  LIBS="-ldl $LIBS"
+
+fi
+
 ac_config_files="$ac_config_files jit-reader.h:jit-reader.h.in"
 
 
diff --git a/gdb/configure.ac b/gdb/configure.ac
index 19263c1..8e13cfe 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -598,6 +598,7 @@ AC_DEFINE_UNQUOTED(GDB_JIT_READER_PATH, "$GDB_JIT_READER_PATH",
                    [The directory to look for JIT debug info readers])
 
 AC_SUBST(HOST_U_64_BIT)
+AC_CHECK_LIB([dl], [dlopen], [], [], [])
 AC_CONFIG_FILES([jit-reader.h:jit-reader.h.in])
 
 AC_ARG_WITH(expat,
-- 
1.7.5.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]