使用 gdb/dbx 调试线程进程

发布于 2024-08-10 12:21:32 字数 184 浏览 5 评论 0原文

这可能是一个真正的问题,但我在这里问是因为当我在采访中被问到这个问题时我毫无头绪。

我们如何调试由另一个线程创建的线程? 假设有一个主进程,它调用函数 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

慵挽 2024-08-17 12:21:32

您可以将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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文