Vous avez juste besoin d'appeler gdb avec l'exécutable (peu importe si c'est le vôtre ou un tiers). Voici un exemple où je débogue la commande ls et définit un point d'arrêt dans la bibliothèque c (partagée). Cet exemple utilise gdb 6.8 qui prend en charge différée (en attente), qui fait des points d'arrêt aussi facile:
gdb /bin/ls
GNU gdb 6.8-debian
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu"...
(no debugging symbols found)
(gdb) b write
Function "write" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (write) pending.
(gdb) r
Starting program: /bin/ls
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
[Thread debugging using libthread_db enabled]
(no debugging symbols found)
(no debugging symbols found)
[New Thread 0x7f98d2d23780 (LWP 7029)]
[Switching to Thread 0x7f98d2d23780 (LWP 7029)]
Breakpoint 1, 0x00007f98d2264bb0 in write() from /lib/libc.so.6
(gdb)
Comme vous pouvez le voir gdb gère automatiquement tous les fils utilisés par l'exécutable. Vous n'avez rien à faire de spécial pour les threads. Le point d'arrêt fonctionnera dans n'importe quel thread.
Alternativement, si vous souhaitez joindre le débogueur à une application déjà en cours (j'utilise tail -f/tmp/ttt ici comme exemple):
ps ux | grep tail
lothar 8496 0.0 0.0 9352 804 pts/3 S+ 12:38 0:00 tail -f /tmp/ttt
lothar 8510 0.0 0.0 5164 840 pts/4 S+ 12:39 0:00 grep tail
gdb
GNU gdb 6.8-debian
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu"...
(no debugging symbols found)
(gdb) attach 8496
Attaching to program: /usr/bin/tail, process 8496
Reading symbols from /lib/librt.so.1...(no debugging symbols found)...done.
Loaded symbols for /lib/librt.so.1
Reading symbols from /lib/libc.so.6...(no debugging symbols found)...done.
Loaded symbols for /lib/libc.so.6
Reading symbols from /lib/libpthread.so.0...(no debugging symbols found)...done.
[Thread debugging using libthread_db enabled]
[New Thread 0x7f24853f56e0 (LWP 8496)]
Loaded symbols for /lib/libpthread.so.0
Reading symbols from /lib/ld-linux-x86-64.so.2...
(no debugging symbols found)...done.
Loaded symbols for /lib64/ld-linux-x86-64.so.2
(no debugging symbols found)
0x00007f2484d2bb50 in nanosleep() from /lib/libc.so.6
(gdb) b write
Breakpoint 1 at 0x7f2484d57bb0
(gdb) c
Continuing.
[Switching to Thread 0x7f24853f56e0 (LWP 8496)]
Breakpoint 1, 0x00007f2484d57bb0 in write() from /lib/libc.so.6
(gdb)
I utilisé dbx sur AIX. si vous dites que gdb peut le faire avec des applications filetées ..puis dbx suce beaucoup de temps .. et j'ai été un imbécile total pour l'utiliser tout ce temps. –
Sad gdb ne fonctionne pas correctement sur AIX ... AIX suce .. –
Je ne sais pas dbx, mais il devrait avoir des caractéristiques similaires – lothar