GDB problem - unable to debug multi-threaded application

GDB problem - unable to debug multi-threaded application

Post by lnxdevelop » Wed, 09 Mar 2005 08:17:52


Reposting this as me earlier attempt seems to not have appeared in the
list.
Using white dwarf linux based on a 2.4.24 kernel. GCC 3.2.3 and glibc
2.2.5

Downloaded gdb 6.3 and built it for the platform. Able to debug
normally on a single thread by attaching with LWP PID.
BUt when i start the multi-threaded app under GDB, the de *** does
not report the spawinging of new threads but instead breaks reporting a
signal - real time event32. I have to issue cmd continue. Also "info
threads" displays nothing so I cant switch between threads.

Did I build GDB incorrectly? Do I need to enable any specific option?
Anyone know why this could be happening?

TIA
 
 
 

GDB problem - unable to debug multi-threaded application

Post by Nix » Fri, 11 Mar 2005 02:18:50

On 7 Mar 2005, lnxdeveloper said:

It sounds like GDB hasn't realised that your program is threaded:
LinuxThreads uses real-time signals internally:

,----[ glibc-2.3.4/linuxthreads/pthread.c ]
| /* Signal numbers used for the communication.
| In these variables we keep track of the used variables. If the
| platform does not support any real-time signals we will define the
| values to some unreasonable value which will signal failing of all
| the functions below. */
| int __pthread_sig_restart = __SIGRTMIN;
| int __pthread_sig_cancel = __SIGRTMIN + 1;
| int __pthread_sig_debug = __SIGRTMIN + 2;
`----

(This is true of glibc-2.2.5 as well, if I remember correctly).


You might want to see what's going on by adding some debugging printfs
to gdb-6.3/gdb/linux-nat.c:linux_nat_wait(); probably around line 1914
you could try printing out the values of `threaded' and `num_lwps'.

Printing out those variables in `add_lwp' and `delete_lwp' in the
same file might be interesting too.

--
What we need these days is a stable, fast, anti-aliased root beer
with dynamic shading. Not that you can let just anybody have root.
--- John M. Ford

 
 
 

GDB problem - unable to debug multi-threaded application

Post by Paul Pluzh » Fri, 11 Mar 2005 13:46:21


Most likely.


No.


The "gdb" by itself does not know how to decode the internal structures
of the libpthread.so.0 (which is required to e.g. enumerate all threads
in the process), and these structures change from one version of glibc
to the next.

To solve that problem, gdb uses services of libthread_db.so.1, which is
part of the glibc itself, and should be updated whenever libpthread.so.0
is updated.

Chances are, your libpthread_db.so.1 is either missing, or does not
match your version of glibc.

Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.
 
 
 

GDB problem - unable to debug multi-threaded application

Post by lnxdevelop » Sat, 12 Mar 2005 03:49:33

Thx for the replies... 2 further questions

1. what is the means of checking compatibility between libpthread_db.so
and glibs?. How do I determine compatibility?.

2. Is there a document somewhere that list what module versions are
compatible with what?
 
 
 

GDB problem - unable to debug multi-threaded application

Post by Paul Pluzh » Sat, 12 Mar 2005 12:41:08


You verify they came from the same package, e.g.

$ rpm -qf /lib/tls/libthread_db.so.1
glibc-2.3.2-11.9
$ rpm -qf /lib/tls/libpthread.so.0
glibc-2.3.2-11.9
$ rpm -V glibc-2.3.2-11.9
..?..... /usr/sbin/glibc_post_upgrade


Glibc comes as a package, including libc.so, ld-linux.so, libpthread.so,
libthread_db.so, and many other things (use "rpm -ql glibc" to see what
the rest of them are).

They *all* must match *exactly*, there are no compatibility guarantees
between e.g. glibc-2.3.2-11.9 libpthread.so and glibc-2.3.2-11.25
ld-linux.so

Cheers,