使用 gdb/dbx 调试线程进程
这可能是一个真正的问题,但我在这里问是因为当我在采访中被问到这个问题时我毫无头绪。
我们如何调试由另一个线程创建的线程? 假设有一个主进程,它调用函数 pthread_create 创建一个不可连接的线程进程,这意味着主进程和新创建的线程进程都将执行自己的任务,如果我们开始调试程序怎么办我们导航到创建的线程?
提前致谢。
This might be genuine question but i am asking here since i was out of any clue when i was asked this question in an interview.
how could we debug a thread which was created by another thread?
let's say there is a main process and it calles the function pthread_create to create a thread process which is not joinable and that means both teh main process and the newly created thread process will be eecuting their own tasks and if we start debugging the program how could we navigate to the thread that was created?.
thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将gdb附加到整个过程,然后使用gdb的 线程操作 在线程之间导航。当 pthread_create'ing 你想要调试的线程时,它可能有助于打印线程 ID。
You can attach gdb to the whole process, then use gdb's thread ops to navigate between threads. It might help to print the thread id when pthread_create'ing the thread you want to debug.