aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cagney <cagney@redhat.com>2003-09-04 21:03:37 +0000
committerAndrew Cagney <cagney@redhat.com>2003-09-04 21:03:37 +0000
commit5220ea4c1ed11cc3d7130c6f7928d80ee9d34b61 (patch)
tree32303a00aec5f704eb418b517e29ba0a4f9bd493
parent6e8c2c062782c2581649b5466b0796514783e864 (diff)
downloadgdb-5220ea4c1ed11cc3d7130c6f7928d80ee9d34b61.zip
gdb-5220ea4c1ed11cc3d7130c6f7928d80ee9d34b61.tar.gz
gdb-5220ea4c1ed11cc3d7130c6f7928d80ee9d34b61.tar.bz2
2003-09-04 Andrew Cagney <cagney@redhat.com>
* thread-db.c (verbose_dlsym): New function. (thread_db_load): Use verbose_dlsym (thread_db_new_objfile): Print that libthread_db was loaded, and that thread debugging was enabled.
-rw-r--r--gdb/ChangeLog7
-rw-r--r--gdb/thread-db.c57
2 files changed, 53 insertions, 11 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index ded24b5..221e4cf 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,12 @@
2003-09-04 Andrew Cagney <cagney@redhat.com>
+ * thread-db.c (verbose_dlsym): New function.
+ (thread_db_load): Use verbose_dlsym
+ (thread_db_new_objfile): Print that libthread_db was loaded, and
+ that thread debugging was enabled.
+
+2003-09-04 Andrew Cagney <cagney@redhat.com>
+
* configure.tgt: Add "mips64*-*-*" target. Delete
mips64*el-*-ecoff*, mips64*el-*-elf*, mips*el-*-ecoff*,
mips*el-*-elf*, mips*-*-lnews*, mips*-*-sysv*, mips*-*-riscos*,
diff --git a/gdb/thread-db.c b/gdb/thread-db.c
index a039ca2..efd0d33 100644
--- a/gdb/thread-db.c
+++ b/gdb/thread-db.c
@@ -375,6 +375,15 @@ thread_db_init (struct target_ops *target)
target_beneath = target;
}
+static void *
+verbose_dlsym (void *handle, const char *name)
+{
+ void *sym = dlsym (handle, name);
+ if (sym == NULL)
+ warning ("Symbol \"%s\" not found in libthread_db: %s", name, dlerror ());
+ return sym;
+}
+
static int
thread_db_load (void)
{
@@ -394,47 +403,47 @@ thread_db_load (void)
/* Initialize pointers to the dynamic library functions we will use.
Essential functions first. */
- td_init_p = dlsym (handle, "td_init");
+ td_init_p = verbose_dlsym (handle, "td_init");
if (td_init_p == NULL)
return 0;
- td_ta_new_p = dlsym (handle, "td_ta_new");
+ td_ta_new_p = verbose_dlsym (handle, "td_ta_new");
if (td_ta_new_p == NULL)
return 0;
- td_ta_map_id2thr_p = dlsym (handle, "td_ta_map_id2thr");
+ td_ta_map_id2thr_p = verbose_dlsym (handle, "td_ta_map_id2thr");
if (td_ta_map_id2thr_p == NULL)
return 0;
- td_ta_map_lwp2thr_p = dlsym (handle, "td_ta_map_lwp2thr");
+ td_ta_map_lwp2thr_p = verbose_dlsym (handle, "td_ta_map_lwp2thr");
if (td_ta_map_lwp2thr_p == NULL)
return 0;
- td_ta_thr_iter_p = dlsym (handle, "td_ta_thr_iter");
+ td_ta_thr_iter_p = verbose_dlsym (handle, "td_ta_thr_iter");
if (td_ta_thr_iter_p == NULL)
return 0;
- td_thr_validate_p = dlsym (handle, "td_thr_validate");
+ td_thr_validate_p = verbose_dlsym (handle, "td_thr_validate");
if (td_thr_validate_p == NULL)
return 0;
- td_thr_get_info_p = dlsym (handle, "td_thr_get_info");
+ td_thr_get_info_p = verbose_dlsym (handle, "td_thr_get_info");
if (td_thr_get_info_p == NULL)
return 0;
- td_thr_getfpregs_p = dlsym (handle, "td_thr_getfpregs");
+ td_thr_getfpregs_p = verbose_dlsym (handle, "td_thr_getfpregs");
if (td_thr_getfpregs_p == NULL)
return 0;
- td_thr_getgregs_p = dlsym (handle, "td_thr_getgregs");
+ td_thr_getgregs_p = verbose_dlsym (handle, "td_thr_getgregs");
if (td_thr_getgregs_p == NULL)
return 0;
- td_thr_setfpregs_p = dlsym (handle, "td_thr_setfpregs");
+ td_thr_setfpregs_p = verbose_dlsym (handle, "td_thr_setfpregs");
if (td_thr_setfpregs_p == NULL)
return 0;
- td_thr_setgregs_p = dlsym (handle, "td_thr_setgregs");
+ td_thr_setgregs_p = verbose_dlsym (handle, "td_thr_setgregs");
if (td_thr_setgregs_p == NULL)
return 0;
@@ -587,6 +596,30 @@ thread_db_new_objfile (struct objfile *objfile)
{
td_err_e err;
+ /* 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;
+ }
+ }
+
/* Don't attempt to use thread_db on targets which can not run
(core files). */
if (objfile == NULL || !target_has_execution)
@@ -624,6 +657,8 @@ thread_db_new_objfile (struct objfile *objfile)
break;
case TD_OK:
+ printf_unfiltered ("[Thread debugging using libthread_db enabled]\n");
+
/* The thread library was detected. Activate the thread_db target. */
push_target (&thread_db_ops);
using_thread_db = 1;