gdb/
authorSanjoy Das <sanjoyd@sourceware.org>
Sun, 20 Nov 2011 08:59:56 +0000 (08:59 +0000)
committerSanjoy Das <sanjoyd@sourceware.org>
Sun, 20 Nov 2011 08:59:56 +0000 (08:59 +0000)
* Makefile.in: Add gdb-dlfcn.c and gdb-dlfcn.h to build system.
* config.in: Add new #define HAVE_LIBDL.
* configure.ac: Add check for -ldl.
* configure: Re-generated by autoconf.
* gdb-dlfcn.c: New file.
* gdb-dlfcn.h: New file.

gdb/ChangeLog
gdb/Makefile.in
gdb/config.in
gdb/configure
gdb/configure.ac
gdb/gdb-dlfcn.c [new file with mode: 0644]
gdb/gdb-dlfcn.h [new file with mode: 0644]

index bd217c04bf4ec7314baca4e817e6138d9b22ed4e..ff269ff0e92874737c6c96bcb61ca34ca83c71d8 100644 (file)
@@ -1,3 +1,12 @@
+2011-11-20  Sanjoy Das  <sdas@igalia.com>
+
+       * Makefile.in: Add gdb-dlfcn.c and gdb-dlfcn.h to build system.
+       * config.in: Add new #define HAVE_LIBDL.
+       * configure.ac: Add check for -ldl.
+       * configure: Re-generated by autoconf.
+       * gdb-dlfcn.c: New file.
+       * gdb-dlfcn.h: New file.
+
 2011-11-20  Sanjoy Das  <sdas@igalia.com>
 
        * config.in: Add new #defines: JIT_READER_DIR and
index ff5f2460a421c9aeb38b164306509619e05720b0..48221f2c2808a6333daad79dd867efbd379c56ef 100644 (file)
@@ -748,7 +748,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
 
@@ -829,7 +829,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 skip.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.
 
@@ -916,7 +916,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 skip.o \
-       common-utils.o buffer.o ptid.o
+       common-utils.o buffer.o ptid.o gdb-dlfcn.o
 
 TSOBS = inflow.o
 
index 27a4e2ce93c8d21e345e6d30bfe0d7bcce02f088..4af4e696265734c144b94b8bf1ed654c14e576e6 100644 (file)
 
 /* Define if JIT_READER_DIR should be relocated when GDB is moved.  */
 #undef JIT_READER_DIR_RELOCATABLE
+
+/* Define if the platform has dlfcn.h.  */
+#undef HAVE_DLFCN_H
index 78cd9e90f0d7b94c1551f14f04428fb10ed74098..f8d038c048c52c7f6754f85152b04ba3e38a16f3 100755 (executable)
 ac_config_files="$ac_config_files jit-reader.h:jit-reader.in"
 
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing dlopen" >&5
+$as_echo_n "checking for library containing dlopen... " >&6; }
+if test "${ac_cv_search_dlopen+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_func_search_save_LIBS=$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
+for ac_lib in '' dl; do
+  if test -z "$ac_lib"; then
+    ac_res="none required"
+  else
+    ac_res=-l$ac_lib
+    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
+  fi
+  if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_search_dlopen=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext
+  if test "${ac_cv_search_dlopen+set}" = set; then :
+  break
+fi
+done
+if test "${ac_cv_search_dlopen+set}" = set; then :
+
+else
+  ac_cv_search_dlopen=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_dlopen" >&5
+$as_echo "$ac_cv_search_dlopen" >&6; }
+ac_res=$ac_cv_search_dlopen
+if test "$ac_res" != no; then :
+  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+fi
+
+
 
 
 # Check whether --with-jit-reader-dir was given.
@@ -11607,7 +11664,8 @@ for ac_header in nlist.h machine/reg.h poll.h sys/poll.h proc_service.h \
                  sys/resource.h sys/procfs.h sys/ptrace.h ptrace.h \
                  sys/reg.h sys/debugreg.h sys/select.h sys/syscall.h \
                  sys/types.h sys/wait.h wait.h termios.h termio.h \
-                 sgtty.h unistd.h elf_hp.h ctype.h time.h locale.h
+                 sgtty.h unistd.h elf_hp.h ctype.h time.h locale.h \
+                  dlfcn.h
 do :
   as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
 ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
index 4ecb5c94e2b292f708658ace4833322d1c829401..cbbf647f3134d76c218a92a2f065da2acf240de5 100644 (file)
@@ -627,6 +627,8 @@ fi
 AC_SUBST(TARGET_PTR)
 AC_CONFIG_FILES([jit-reader.h:jit-reader.in])
 
+AC_SEARCH_LIBS(dlopen, dl)
+
 GDB_AC_WITH_DIR([JIT_READER_DIR], [jit-reader-dir],
                 [directory to load the JIT readers from],
                 [${libdir}/gdb])
@@ -981,7 +983,8 @@ AC_CHECK_HEADERS([nlist.h machine/reg.h poll.h sys/poll.h proc_service.h \
                  sys/resource.h sys/procfs.h sys/ptrace.h ptrace.h \
                  sys/reg.h sys/debugreg.h sys/select.h sys/syscall.h \
                  sys/types.h sys/wait.h wait.h termios.h termio.h \
-                 sgtty.h unistd.h elf_hp.h ctype.h time.h locale.h])
+                 sgtty.h unistd.h elf_hp.h ctype.h time.h locale.h \
+                 dlfcn.h])
 AC_CHECK_HEADERS(link.h, [], [],
 [#if HAVE_SYS_TYPES_H
 # include <sys/types.h>
diff --git a/gdb/gdb-dlfcn.c b/gdb/gdb-dlfcn.c
new file mode 100644 (file)
index 0000000..1caa9af
--- /dev/null
@@ -0,0 +1,139 @@
+/* Platform independent shared object routines for GDB.
+
+   Copyright (C) 2011 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include "defs.h"
+#include "gdb_assert.h"
+
+#include "gdb-dlfcn.h"
+
+#ifdef HAVE_DLFCN_H
+#include <dlfcn.h>
+#elif __MINGW32__
+#include <windows.h>
+#else
+/* Unsupported configuration. */
+#define NO_SHARED_LIB
+#endif
+
+#ifdef NO_SHARED_LIB
+
+void *
+gdb_dlopen (const char *filename)
+{
+  gdb_assert_not_reached ("gdb_dlopen should not be called on this platform.");
+}
+
+void *
+gdb_dlsym (void *handle, const char *symbol)
+{
+  gdb_assert_not_reached ("gdb_dlsym should not be called on this platform.");
+}
+
+struct cleanup *
+make_cleanup_dlclose (void *handle)
+{
+  gdb_assert_not_reached ("make_cleanup_dlclose should not be called on this "
+                          "platform.");
+}
+
+int
+gdb_dlclose (void *handle)
+{
+  gdb_assert_not_reached ("gdb_dlclose should not be called on this platform.");
+}
+
+int
+is_dl_available (void)
+{
+  return 0;
+}
+
+#else /* NO_SHARED_LIB */
+
+void *
+gdb_dlopen (const char *filename)
+{
+  void *result;
+#ifdef HAVE_DLFCN_H
+  result = dlopen (filename, RTLD_NOW);
+#elif __MINGW32__
+  result = (void *) LoadLibrary (filename);
+#endif
+  if (result != NULL)
+    return result;
+
+#ifdef HAVE_DLFCN_H
+  error (_("Could not load %s: %s"), filename, dlerror());
+#else
+  {
+    LPVOID buffer;
+    DWORD dw;
+
+    dw = GetLastError();
+
+    FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
+                   FORMAT_MESSAGE_IGNORE_INSERTS,
+                   NULL, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+                   (LPTSTR) &buffer
+                   0, NULL);
+
+    error (_("Could not load %s: %s"), filename, (char *) buffer);
+  }
+#endif
+}
+
+void *
+gdb_dlsym (void *handle, const char *symbol)
+{
+#ifdef HAVE_DLFCN_H
+  return dlsym (handle, symbol);
+#elif __MINGW32__
+  return (void *) GetProcAddress (handle, symbol);
+#endif
+}
+
+int
+gdb_dlclose (void *handle)
+{
+#ifdef HAVE_DLFCN_H
+  return dlclose (handle);
+#elif __MINGW32__
+  return !((int) FreeLibrary (handle));
+#endif
+}
+
+static void
+do_dlclose_cleanup (void *handle)
+{
+  gdb_dlclose (handle);
+}
+
+struct cleanup *
+make_cleanup_dlclose (void *handle)
+{
+  return make_cleanup (do_dlclose_cleanup, handle);
+}
+
+int
+is_dl_available (void)
+{
+  return 1;
+}
+
+#endif /* NO_SHARED_LIB */
diff --git a/gdb/gdb-dlfcn.h b/gdb/gdb-dlfcn.h
new file mode 100644 (file)
index 0000000..0a9d1eb
--- /dev/null
@@ -0,0 +1,51 @@
+/* Platform independent shared object routines for GDB.
+
+   Copyright (C) 2011 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#ifndef GDB_DLFCN_H
+#define GDB_DLFCN_H
+
+#include "defs.h"
+
+/* Load the dynamic library file named FILENAME, and return a handle
+   for that dynamic library.  Return NULL if the loading fails for any
+   reason.  */
+
+void *gdb_dlopen (const char *filename);
+
+/* Return the address of the symbol named SYMBOL inside the shared
+   library whose handle is HANDLE.  Return NULL when the symbol could
+   not be found.  */
+
+void *gdb_dlsym (void *handle, const char *symbol);
+
+/* Install a cleanup routine which closes the handle HANDLE.  */
+
+struct cleanup *make_cleanup_dlclose (void *handle);
+
+/* Cleanup the shared object pointed to by HANDLE. Return 0 on success
+   and nonzero on failure.  */
+
+int gdb_dlclose (void *handle);
+
+/* Return non-zero if the dynamic library functions are available on
+   this platform.  */
+
+int is_dl_available(void);
+
+#endif /* GDB_DLFCN_H */
This page took 0.038965 seconds and 4 git commands to generate.