获取有关 gdb/ddd 中线程的信息

发布于 2024-10-12 00:41:55 字数 675 浏览 2 评论 0原文

我正在使用 ddd 调试多线程应用程序。

每秒同时我可以在 DDD console out 上看到一个新线程被创建

 [NewThread 0x455fc940 (LWP 27373)]

并在它之后立即被销毁。

 [Thread 0x455fc940  (LWP 27373) exited]

几分钟后,我得到了这个文本,

 [NewThread 0x455fc940 (LWP 27363)]
 [Thread 0x455fc940  (LWP 27363) exited]
 [NewThread 0x455fc940 (LWP 27367)]
 [Thread 0x455fc940  (LWP 27367) exited]
 [NewThread 0x455fc940 (LWP 27373)]
 [Thread 0x455fc940  (LWP 27373) exited]
 ...and so on..

并且 LWP 不断增加。

线程来来去去的速度太快,无法使用我单击“状态”->“线程”的窗口来显示。您能告诉我如何获取有关该线程的信息吗?

你知道为什么这个LWP一直在增加吗? 更重要的是如何获取进入该线程的函数?

谢谢大家 AFG

I am debugging a multi threaded application using ddd.

At the same time each second I can see on DDD console out that a new thread is created

 [NewThread 0x455fc940 (LWP 27373)]

and destroyed immediately after it.

 [Thread 0x455fc940  (LWP 27373) exited]

After few minutes I have this text out

 [NewThread 0x455fc940 (LWP 27363)]
 [Thread 0x455fc940  (LWP 27363) exited]
 [NewThread 0x455fc940 (LWP 27367)]
 [Thread 0x455fc940  (LWP 27367) exited]
 [NewThread 0x455fc940 (LWP 27373)]
 [Thread 0x455fc940  (LWP 27373) exited]
 ...and so on..

with this LWP increasing.

The threas comes and go too fast to be displayed using the window I got clicking on Status->Thread. Can you address me a bit about how to get information about that thread?

Do you know why this LWP is increasing all the time?
More important how to get the function that is lunched into that thread?

Thank you all
AFG

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

饮湿 2024-10-19 00:41:55

LWP 是缩写词,代表轻量级流程。它实际上是每个新生成的线程的线程 ID

关于如何处理那些产生和死亡的线程:您可以尝试在克隆处设置断点,这是系统调用(?我是否正确?),它在给定函数处启动一个新线程。

注意:在 clone 处中断时,您知道线程将从何处启动,但实际上并没有线程,但是您可以在作为 clone 参数给出的函数处设置断点...

也就是说,使用start命令从gdb或ddd启动程序,该命令在程序入口点(即main)设置一个临时断点),然后在clone处设置断点,继续看看会发生什么;)。

更新:在clone处设置断点对我有用......至少在我的测试中是这样。我应该补充一点,这是 Linux 特定的 - 并且实际上是 pthread_create 使用的。

LWP is an acronym and stands for Light Weight Process. It is in effect the thread ID of each newly spawned thread.

On what to do about those spawning and dying threads: you could try set a break point at clone, which is he system call (? am I correct?) which starts a new thread at a given function.

Note: When breaking at clone you know from where the thread will be started, but don't actually have a thread, you can then however set break points at the functions given as argument to clone...

That is, start your program from gdb or ddd with the start command, which sets a temporary break point at the program entry point (i.e. main), than set a break point at clone, continue and see what happens ;).

Update: setting a break point at clone works for me... at least in my test. I should add that this is linux specific - and is actually what pthread_create uses.

原来是傀儡 2024-10-19 00:41:55

在 pthread_create 处设置断点。

(gdb) break pthread_create
Breakpoint 1 at 0x20c49ba5cabf44

现在,当您运行它时,当下一次调用创建线程时,它将停止执行,您可以输入 where 来查看调用者是谁。

Set a breakpoint at pthread_create.

(gdb) break pthread_create
Breakpoint 1 at 0x20c49ba5cabf44

Now when you run it, it will stop execution when the next call to create a thread happens, and you can type where to see who the caller was.

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