GDB如何知道线程 [英] How does GDB know about threads

查看:133
本文介绍了GDB如何知道线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




  • 它如何能够判断哪一个是当前线程?


  • $ b

    我的问题是如何知道每个线程相关的所有上下文信息?针对它在GDB内部的工作方式,我没有任何问题调试线程,这完全是关于GDB内部的。



    我发现了 GDB内部文档,但线程部分目前为空。

    全部我的其他研究让我对调试多线程程序产生疑问,而且我似乎无法挖掘出我正在寻找的确切信息。



    编辑:



    到目前为止,GDB似乎截获了信号(感谢ptrace?),并发现线程何时创建。但我想更确切地知道它是如何实际完成的。



    我还有一个特殊的体系结构,它带有一个配置了--enable-threads =单。然而,GDB能够列出当前的线程。这可能怎么样?



    欢迎您提供每种知识,有用的链接或文档。



    谢谢。

    >




    2014年3月5日更新



    我查看了libthread_db,发现GDB允许提供一个定制的库来调试线程(参见文档的信息)



    我试图做到这一点,并能够提供有关我的线程(ID,启动函数,堆栈等gdb信息)通过实现 gdb / common / gdb_thread_db.h 中定义的 td_thr_get_info 函数。



    我仍然无法向gdb提供关于我的线程上下文的任何信息,但仍然在寻找关于此问题的任何线索。



    谢谢。

    PS:这个问题似乎解决了相同的问题,但不幸的是没有方向了。

试试搜索有关 libthread_db


I am trying to understand more deeply how GDB knows about threads.

  • How is it able to tell which one is the current thread ?
  • How does it know all the context information relative to each thread ?

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.

解决方案

Try to search for information about libthread_db.

这篇关于GDB如何知道线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆