This is the mail archive of the gdb@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]

PATCH: Re: Thead problem with gdb 5.2 and glibc


On Thu, May 30, 2002 at 04:58:42PM -0700, H . J . Lu wrote:
> I have a strange thread problem with gdb 5.2 and glibc. I have a set of
>  DSOs, which are linked against linuxthreads. One of them has an
>  undefined symbol. With
> 
> int main(int argc, char **argv)
> {
>   void *one;
>   int (*f) ();
> 
>   printf ("Loading: %s: ", argv [1]);
>   one = dlopen (argv [1], RTLD_NOW);
>   if (!one)
>     {
>       printf ("Failed: %s\n", dlerror());
>       return 1;
>     }
> 
>   printf ("OK\n");
> 
> I got
> 
> # ./main plugin/foo.so
> Loading: plugin/foo.so: Failed: : shared object not open
> 
> Under gdb
> 
> GNU gdb 5.2-0.5 (5.2.0_2002-05-23-cvs)
> Copyright 2002 Free Software Foundation, Inc.
> GDB is free software, covered by the GNU General Public License, and you are
> welcome to change it and/or distribute copies of it under certain conditions.
> Type "show copying" to see the conditions.
> There is absolutely no warranty for GDB.  Type "show warranty" for details.
> This GDB was configured as "i386-redhat-linux"...
> Setting up the environment for debugging gdb.
> .gdbinit:5: Error in sourced command file:
> Function "internal_error" not defined.
> (gdb) r plugin/foo.so
> Starting program: /home/hjl/bugs/libc/dlopen6/main plugin/foo.so
> Error while reading shared library symbols:
> Cannot find new threads: generic error
> Cannot find user-level thread for LWP 4922: generic error
> (gdb) 
> 
> If I changed it to 
> 
>   one = dlopen (argv [1], RTLD_LAZY);
> 
> I got
> 
> # ./main plugin/foo.so
> Loading: plugin/foo.so: Failed: lib/libbucky.so.1: undefined symbol: fooooooo
> 
> (gdb) r plugin/foo.so
> Starting program: /home/hjl/bugs/libc/dlopen6/main plugin/foo.so
> [New Thread 1024 (LWP 5024)]
> Loading: plugin/foo.so: Failed: lib/libbucky.so.1: undefined symbol: fooooooo
> 
> I only did a dlopen. Why does RTLD_NOW make a difference for gdb?
> 
> 

This patch seems to work for me.


H.J.
2002-05-30  H.J. Lu  (hjl@gnu.org)

	* thread-db.c (thread_db_try_find_new_threads): New.
	(thread_db_new_objfile): Call thread_db_try_find_new_threads
	instead of thread_db_find_new_threads and check its return.
	(thread_db_find_new_threads): Use
	thread_db_try_find_new_threads.

--- gdb/thread-db.c.thread	Thu May 23 16:27:19 2002
+++ gdb/thread-db.c	Thu May 30 21:08:07 2002
@@ -122,6 +122,7 @@ static CORE_ADDR td_create_bp_addr;
 static CORE_ADDR td_death_bp_addr;
 
 /* Prototypes for local functions.  */
+static td_err_e thread_db_try_find_new_threads (void);
 static void thread_db_find_new_threads (void);
 
 
@@ -560,7 +561,11 @@ thread_db_new_objfile (struct objfile *o
       if (proc_handle.pid != 0)
 	{
 	  enable_thread_event_reporting ();
-	  thread_db_find_new_threads ();
+	  if (thread_db_try_find_new_threads () != TD_OK)
+	    {
+	      unpush_target (&thread_db_ops);
+	      using_thread_db = 0;
+	    }
 	}
       break;
 
@@ -973,14 +978,20 @@ thread_db_find_new_threads (void)
 {
   td_err_e err;
 
-  /* Iterate over all user-space threads to discover new threads.  */
-  err = td_ta_thr_iter_p (thread_agent, find_new_threads_callback, NULL,
-			  TD_THR_ANY_STATE, TD_THR_LOWEST_PRIORITY,
-			  TD_SIGNO_MASK, TD_THR_ANY_USER_FLAGS);
+  err = thread_db_try_find_new_threads ();
   if (err != TD_OK)
     error ("Cannot find new threads: %s", thread_db_err_str (err));
 }
 
+static td_err_e
+thread_db_try_find_new_threads (void)
+{
+  /* Iterate over all user-space threads to discover new threads.  */
+  return td_ta_thr_iter_p (thread_agent, find_new_threads_callback, NULL,
+			   TD_THR_ANY_STATE, TD_THR_LOWEST_PRIORITY,
+			   TD_SIGNO_MASK, TD_THR_ANY_USER_FLAGS);
+}
+
 static char *
 thread_db_pid_to_str (ptid_t ptid)
 {


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