Reputation: 1482
I am trying to understand more deeply how GDB knows about threads.
My question aims at how it works internally in GDB, I do not have any problem debugging threads, it is all really about GDB's internals.
I found the GDB internals documentation, but the threads part is empty as for now.
All my other research lead me to question about debugging multi-threaded programs and I cannot seem to dig the precise information I am looking for.
Edit :
So far it seems that GDB intercepts signals (thanks to ptrace?) and finds out when threads are created. But I would like to know more precisely how it is actually done.
I also have a particular architecture that comes with a GDB that was configured with --enable-threads=single. That GDB is however able to list the current threads. How is this possible ?
Every knowledge, useful links or documentations are welcomed.
Thanks.
Update March 5 '14
I have looked into the libthread_db and found out that GDB allows providing a custom built library to debug threads (see doc for information)
I have tried to do that and am able to provide gdb information about my thread (ID, start function, stack and such) by implementing the td_thr_get_info
function defined in gdb/common/gdb_thread_db.h
.
Still i am not able to give gdb any information about the context of my threads and still looking for any clue on that issue.
Thanks.
PS: This question seem to address the same questions but has unfortunately no directions too.
Upvotes: 1
Views: 490