简体   繁体   English

如何在gdb控制台模式下捕获新线程?

[英]How to catch new thread in gdb console mode?

I am running my Qt app from gdb, and i want to stop when new threads creates. 我正在从gdb运行我的Qt应用程序,我想在创建新线程时停止。 (when gdb prints message [New Thread address (LPW number) ]. (当gdb打印消息[New Thread address (LPW number) ]时。

I have set breakpoint b __pthread_create_2_1 . 我已经设置了断点b __pthread_create_2_1 That allows me to catch most of new threads prints. 这使我可以捕获大多数新的线程打印。 but i still got few new threads that are not catched. 但是我仍然有一些新线程没有被抓住。 What else can i do to catch their creation? 我还能做些什么来捕捉他们的创作?

Probably what you want is catch syscall clone (see here https://sourceware.org/gdb/onlinedocs/gdb/Set-Catchpoints.html ) 可能您想要的是catch syscall clone (请参见此处https://sourceware.org/gdb/onlinedocs/gdb/Set-Catchpoints.html

Also by default gdb let other threads continue their execution if a breakpoint or catchpoint event occurs. 同样,默认情况下,如果发生断点或捕获点事件,则gdb允许其他线程继续执行。 So maybe you want to take a look at the All-Stop mode ( https://sourceware.org/gdb/onlinedocs/gdb/Thread-Stops.html ) 所以也许您想看看All-Stop模式( https://sourceware.org/gdb/onlinedocs/gdb/Thread-Stops.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM