diff options
author | Paul Pluzhnikov <ppluzhnikov@google.com> | 2009-10-29 17:43:44 +0000 |
---|---|---|
committer | Paul Pluzhnikov <ppluzhnikov@google.com> | 2009-10-29 17:43:44 +0000 |
commit | 96f1593750e940f6aac4fd5fe29968bbfe1e7f5b (patch) | |
tree | e4498398b97b713b0e40010413bebb41afdd5002 /gdb | |
parent | 64c1b14eac6772851c5f3d56cbf6426e18492e82 (diff) | |
download | binutils-96f1593750e940f6aac4fd5fe29968bbfe1e7f5b.zip binutils-96f1593750e940f6aac4fd5fe29968bbfe1e7f5b.tar.gz binutils-96f1593750e940f6aac4fd5fe29968bbfe1e7f5b.tar.bz2 |
2009-10-29 Paul Pluzhnikov <ppluzhnikov@google.com>
* configure.ac: New --with-libthread-db option.
* thread-db.c: Allow direct dependence on libthread_db.
(thread_db_free): Adjust.
* config.in: Regenerate.
* configure: Likewise.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/gdbserver/ChangeLog | 8 | ||||
-rw-r--r-- | gdb/gdbserver/config.in | 3 | ||||
-rwxr-xr-x | gdb/gdbserver/configure | 15 | ||||
-rw-r--r-- | gdb/gdbserver/configure.ac | 7 | ||||
-rw-r--r-- | gdb/gdbserver/thread-db.c | 57 |
5 files changed, 90 insertions, 0 deletions
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index 77a5d19..fceb900 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,11 @@ +2009-10-29 Paul Pluzhnikov <ppluzhnikov@google.com> + + * configure.ac: New --with-libthread-db option. + * thread-db.c: Allow direct dependence on libthread_db. + (thread_db_free): Adjust. + * config.in: Regenerate. + * configure: Likewise. + 2009-10-28 Paul Pluzhnikov <ppluzhnikov@google.com> PR gdb/10757 diff --git a/gdb/gdbserver/config.in b/gdb/gdbserver/config.in index 7eb11b9..7c89966 100644 --- a/gdb/gdbserver/config.in +++ b/gdb/gdbserver/config.in @@ -175,6 +175,9 @@ /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS +/* Define if we should use libthread_db directly. */ +#undef USE_LIBTHREAD_DB_DIRECTLY + /* Enable extensions on AIX 3, Interix. */ #ifndef _ALL_SOURCE # undef _ALL_SOURCE diff --git a/gdb/gdbserver/configure b/gdb/gdbserver/configure index b88ed5b..687105a 100755 --- a/gdb/gdbserver/configure +++ b/gdb/gdbserver/configure @@ -668,6 +668,7 @@ ac_user_opts=' enable_option_checking with_pkgversion with_bugurl +with_libthread_db ' ac_precious_vars='build_alias host_alias @@ -1297,6 +1298,8 @@ Optional Packages: --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-pkgversion=PKG Use PKG in the version string in place of "GDB" --with-bugurl=URL Direct users to URL to report a bug + --with-libthread-db=PATH + use given libthread_db directly Some influential environment variables: CC C compiler command @@ -4268,6 +4271,18 @@ $as_echo "#define HAVE_TD_VERSION 1" >>confdefs.h fi fi + +# Check whether --with-libthread-db was given. +if test "${with_libthread_db+set}" = set; then : + withval=$with_libthread_db; srv_libthread_db_path="${withval}" + +$as_echo "#define USE_LIBTHREAD_DB_DIRECTLY 1" >>confdefs.h + + srv_libs="$srv_libthread_db_path" + +fi + + if test "$srv_xmlfiles" != ""; then srv_xmlbuiltin="xml-builtin.o" diff --git a/gdb/gdbserver/configure.ac b/gdb/gdbserver/configure.ac index a631c7e..2f2b2a3 100644 --- a/gdb/gdbserver/configure.ac +++ b/gdb/gdbserver/configure.ac @@ -158,6 +158,13 @@ if test "$srv_linux_thread_db" = "yes"; then fi fi +AC_ARG_WITH(libthread-db, +AS_HELP_STRING([--with-libthread-db=PATH], [use given libthread_db directly]), +[srv_libthread_db_path="${withval}" + AC_DEFINE(USE_LIBTHREAD_DB_DIRECTLY, 1, [Define if we should use libthread_db directly.]) + srv_libs="$srv_libthread_db_path" +]) + if test "$srv_xmlfiles" != ""; then srv_xmlbuiltin="xml-builtin.o" AC_DEFINE(USE_XML, 1, [Define if an XML target description is available.]) diff --git a/gdb/gdbserver/thread-db.c b/gdb/gdbserver/thread-db.c index 0fb8647..06dfe35 100644 --- a/gdb/gdbserver/thread-db.c +++ b/gdb/gdbserver/thread-db.c @@ -30,7 +30,10 @@ static int thread_db_use_events; #include "gdb_proc_service.h" #include "../gdb_thread_db.h" +#ifndef USE_LIBTHREAD_DB_DIRECTLY #include <dlfcn.h> +#endif + #include <stdint.h> #include <limits.h> #include <ctype.h> @@ -44,8 +47,10 @@ struct thread_db /* Connection to the libthread_db library. */ td_thragent_t *thread_agent; +#ifndef USE_LIBTHREAD_DB_DIRECTLY /* Handle of the libthread_db from dlopen. */ void *handle; +#endif /* Addresses of libthread_db functions. */ td_err_e (*td_ta_new_p) (struct ps_prochandle * ps, td_thragent_t **ta); @@ -484,6 +489,51 @@ thread_db_get_tls_address (struct thread_info *thread, CORE_ADDR offset, return err; } +#ifdef USE_LIBTHREAD_DB_DIRECTLY + +static int +thread_db_load_search (void) +{ + td_err_e err; + struct thread_db tdb; + struct process_info *proc = current_process (); + + if (proc->private->thread_db != NULL) + fatal ("unexpected: proc->private->thread_db != NULL"); + + tdb.td_ta_new_p = &td_ta_new; + + /* Attempt to open a connection to the thread library. */ + err = tdb.td_ta_new_p (&tdb.proc_handle, &tdb.thread_agent); + if (err != TD_OK) + { + if (debug_threads) + fprintf (stderr, "td_ta_new(): %s\n", thread_db_err_str (err)); + return 0; + } + + tdb.td_ta_map_lwp2thr_p = &td_ta_map_lwp2thr; + tdb.td_thr_get_info_p = &td_thr_get_info; + tdb.td_ta_thr_iter_p = &td_ta_thr_iter; + tdb.td_symbol_list_p = &td_symbol_list; + + /* This is required only when thread_db_use_events is on. */ + tdb.td_thr_event_enable_p = &td_thr_event_enable; + + /* These are not essential. */ + tdb.td_ta_event_addr_p = &td_ta_event_addr; + tdb.td_ta_set_event_p = &td_ta_set_event; + tdb.td_ta_event_getmsg_p = &td_ta_event_getmsg; + tdb.td_thr_tls_get_addr_p = &td_thr_tls_get_addr; + + proc->private->thread_db = xmalloc (sizeof (tdb)); + memcpy (proc->private->thread_db, &tdb, sizeof (tdb)); + + return 1; +} + +#else + static int try_thread_db_load_1 (void *handle) { @@ -662,6 +712,8 @@ thread_db_load_search (void) return rc; } +#endif /* USE_LIBTHREAD_DB_DIRECTLY */ + int thread_db_init (int use_events) { @@ -705,6 +757,7 @@ thread_db_free (struct process_info *proc) struct thread_db *thread_db = proc->private->thread_db; if (thread_db) { +#ifndef USE_LIBTHREAD_DB_DIRECTLY td_err_e (*td_ta_delete_p) (td_thragent_t *); td_ta_delete_p = dlsym (thread_db->handle, "td_ta_delete"); @@ -712,6 +765,10 @@ thread_db_free (struct process_info *proc) (*td_ta_delete_p) (thread_db->thread_agent); dlclose (thread_db->handle); +#else + td_ta_delete (thread_db->thread_agent); +#endif /* USE_LIBTHREAD_DB_DIRECTLY */ + free (thread_db); proc->private->thread_db = NULL; } |