aboutsummaryrefslogtreecommitdiff
path: root/gdb/linux-thread-db.c
diff options
context:
space:
mode:
authorDaniel Jacobowitz <drow@false.org>2006-03-30 16:34:23 +0000
committerDaniel Jacobowitz <drow@false.org>2006-03-30 16:34:23 +0000
commit0ec9a092fd18d6b1c38ae330194bf90534a9b681 (patch)
tree93feedf6bfddc1622c45699c28bafaa000874e0c /gdb/linux-thread-db.c
parent6d820c5c12929725ad4fdc7e9e8b3b02af1df932 (diff)
downloadgdb-0ec9a092fd18d6b1c38ae330194bf90534a9b681.zip
gdb-0ec9a092fd18d6b1c38ae330194bf90534a9b681.tar.gz
gdb-0ec9a092fd18d6b1c38ae330194bf90534a9b681.tar.bz2
* linux-thread-db.c: Include "linux-nat.h".
(check_for_thread_db): New function, split out from thread_db_new_objfile. Remove dead check for active thread_db on inapplicable targets. (thread_db_new_objfile): Call check_for_thread_db. * Makefile.in (linux-thread-db.o): Update. * linux-nat.c (child_post_attach): Call check_for_thread_db. (linux_child_post_startup_inferior): Likewise. (lin_lwp_attach_lwp): Call target_post_attach instead of child_post_attach. * linux-nat.h (check_for_thread_db): New prototype.
Diffstat (limited to 'gdb/linux-thread-db.c')
-rw-r--r--gdb/linux-thread-db.c77
1 files changed, 37 insertions, 40 deletions
diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c
index 1291480..981bc06 100644
--- a/gdb/linux-thread-db.c
+++ b/gdb/linux-thread-db.c
@@ -37,6 +37,7 @@
#include "regcache.h"
#include "solib-svr4.h"
#include "gdbcore.h"
+#include "linux-nat.h"
#ifdef HAVE_GNU_LIBC_VERSION_H
#include <gnu/libc-version.h>
@@ -626,59 +627,49 @@ check_thread_signals (void)
#endif
}
-static void
-thread_db_new_objfile (struct objfile *objfile)
+/* Check whether thread_db is usable. This function is called when
+ an inferior is created (or otherwise acquired, e.g. attached to)
+ and when new shared libraries are loaded into a running process. */
+
+void
+check_for_thread_db (void)
{
td_err_e err;
+ static int already_loaded;
/* First time through, report that libthread_db was successfuly
loaded. Can't print this in in thread_db_load as, at that stage,
- the interpreter and it's console haven't started. The real
- problem here is that libthread_db is loaded too early - it should
- only be loaded when there is a program to debug. */
- {
- static int dejavu;
- if (!dejavu)
- {
- Dl_info info;
- const char *library = NULL;
- /* Try dladdr. */
- if (dladdr ((*td_ta_new_p), &info) != 0)
- library = info.dli_fname;
- /* Try dlinfo? */
- if (library == NULL)
- /* Paranoid - don't let a NULL path slip through. */
- library = LIBTHREAD_DB_SO;
- printf_unfiltered (_("Using host libthread_db library \"%s\".\n"),
- library);
- dejavu = 1;
- }
- }
+ the interpreter and it's console haven't started. */
- /* Don't attempt to use thread_db on targets which can not run
- (core files). */
- if (objfile == NULL || !target_has_execution)
+ if (!already_loaded)
{
- /* All symbols have been discarded. If the thread_db target is
- active, deactivate it now. */
- if (using_thread_db)
- {
- gdb_assert (proc_handle.pid == 0);
- unpush_target (&thread_db_ops);
- using_thread_db = 0;
- }
+ Dl_info info;
+ const char *library = NULL;
+ if (dladdr ((*td_ta_new_p), &info) != 0)
+ library = info.dli_fname;
+
+ /* Try dlinfo? */
+
+ if (library == NULL)
+ /* Paranoid - don't let a NULL path slip through. */
+ library = LIBTHREAD_DB_SO;
- goto quit;
+ printf_unfiltered (_("Using host libthread_db library \"%s\".\n"),
+ library);
+ already_loaded = 1;
}
if (using_thread_db)
/* Nothing to do. The thread library was already detected and the
target vector was already activated. */
- goto quit;
+ return;
- /* Initialize the structure that identifies the child process. Note
- that at this point there is no guarantee that we actually have a
- child process. */
+ /* Don't attempt to use thread_db on targets which can not run
+ (executables not running yet, core files) for now. */
+ if (!target_has_execution)
+ return;
+
+ /* Initialize the structure that identifies the child process. */
proc_handle.pid = GET_PID (inferior_ptid);
/* Now attempt to open a connection to the thread library. */
@@ -705,8 +696,14 @@ thread_db_new_objfile (struct objfile *objfile)
thread_db_err_str (err));
break;
}
+}
+
+static void
+thread_db_new_objfile (struct objfile *objfile)
+{
+ if (objfile != NULL)
+ check_for_thread_db ();
-quit:
if (target_new_objfile_chain)
target_new_objfile_chain (objfile);
}