gdb/
* 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.
This commit is contained in:
parent
b8e0a31cb5
commit
a2d08b9eeb
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -988,3 +988,6 @@
|
||||
|
||||
/* 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
|
||||
|
60
gdb/configure
vendored
60
gdb/configure
vendored
@ -10011,6 +10011,63 @@ fi
|
||||
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"
|
||||
|
@ -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>
|
||||
|
139
gdb/gdb-dlfcn.c
Normal file
139
gdb/gdb-dlfcn.c
Normal file
@ -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 */
|
51
gdb/gdb-dlfcn.h
Normal file
51
gdb/gdb-dlfcn.h
Normal file
@ -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 */
|
Loading…
Reference in New Issue
Block a user