获取有关 gdb/ddd 中线程的信息
我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
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 toclone
...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 atclone
, 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 whatpthread_create
uses.在 pthread_create 处设置断点。
现在,当您运行它时,当下一次调用创建线程时,它将停止执行,您可以输入
where
来查看调用者是谁。Set a breakpoint at pthread_create.
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.