Note that there are some explanatory texts on larger screens.

plurals
  1. POHow does GDB know about threads
    primarykey
    data
    text
    <p>I am trying to understand more deeply how GDB knows about threads.</p> <ul> <li>How is it able to tell which one is the current thread ?</li> <li>How does it know all the context information relative to each thread ?</li> </ul> <p>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.</p> <p>I found the <a href="http://www.sourceware.org/gdb/onlinedocs/gdbint.html" rel="nofollow noreferrer">GDB internals documentation</a>, but the threads part is empty as for now.<br> 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.</p> <p>Edit :</p> <p>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.</p> <p>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 ?</p> <p>Every knowledge, useful links or documentations are welcomed.</p> <p>Thanks.</p> <hr> <p><strong>Update March 5 '14</strong></p> <p>I have looked into the libthread_db and found out that GDB allows providing a custom built library to debug threads (see <a href="https://sourceware.org/gdb/onlinedocs/gdb/Threads.html" rel="nofollow noreferrer">doc</a> for information) </p> <p>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 <code>td_thr_get_info</code> function defined in <code>gdb/common/gdb_thread_db.h</code>.</p> <p>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.</p> <p>Thanks.</p> <p>PS: <a href="https://stackoverflow.com/questions/19972568/teaching-gdb-to-understand-micro-threads-from-core-files#comment33599283_19972568">This question</a> seem to address the same questions but has unfortunately no directions too.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload