This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[rfa:threads] Report when using libthread_db


Hello,

This modifies thread-db.c so that reports when libthread_db has been loaded and when it is being used vis:

The load ...

Loading libthread_db library "libthread_db.so.1"
GNU gdb 2003-08-05-cvs
Copyright 2003 Free Software Foundation, Inc.
GDB is free software, covered by the GNU ....
(gdb)

The use ...

(gdb) run
Starting program: /home/cagney/PENDING/2003-08-05-warn-thread-db/N-x86_64-unknow
n-linux-gnu/gdb/testsuite/gdb.threads/pthreads
Threaded debugging using libthread_db enabled.
[New Thread 182894192832 (LWP 23928)]
[Switching to Thread 182894192832 (LWP 23928)]


Thoughts?

Perhaphs the enabled message should be in []?
Should the "Loading" message come after the (C) notice, or the (C) put before the modules are initialized?
Anyone know of a way of finding the exact actual libthread_db version so that can be printed as well?


If that's resolved, ok for 6.0 or mainline?

Andrew
2003-08-05  Andrew Cagney  <cagney@redhat.com>

	* thread-db.c (verbose_dlsym): New function.
	(thread_db_load): Use verbose_dlsym.  Print that the libthread-db
	is being loaded.
	(thread_db_new_objfile): Print that thread debugging was enabled.

Index: thread-db.c
===================================================================
RCS file: /cvs/src/src/gdb/thread-db.c,v
retrieving revision 1.33
diff -u -r1.33 thread-db.c
--- thread-db.c	5 Jun 2003 18:22:02 -0000	1.33
+++ thread-db.c	5 Aug 2003 19:16:02 -0000
@@ -375,6 +375,15 @@
   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)
 {
@@ -390,51 +399,57 @@
 			"GDB will not be able to debug pthreads.\n\n");
       return 0;
     }
+  else
+    {
+      fprintf_unfiltered (gdb_stdlog, "Loading libthread_db library \"%s\"\n",
+			  LIBTHREAD_DB_SO);
+			  
+    }
 
   /* 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;
 
@@ -624,6 +639,8 @@
       break;
 
     case TD_OK:
+      fprintf_unfiltered (gdb_stdlog, "Threaded 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;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]