简体   繁体   English

gdb-多个线程和共享库

[英]gdb - multiple threads and shared libs

I have a program which create many threads. 我有一个创建多个线程的程序。 I can check it using following command: ps -L pid . 我可以使用以下命令检查它: ps -L pid I also know that a process loads some shared libs. 我也知道一个进程会加载一些共享库。 I wonder if is possible to check which threads belong to a selected shared lib. 我想知道是否可以检查哪些线程属于选定的共享库。 That process contains debug symbols and I can attach to them using follwoing command: sudo gdb -p pid What's next ? 该过程包含调试符号,我可以使用follwoing命令将其附加到它们: sudo gdb -p pid接下来是什么?

Let we already attached to a process. 让我们已经附加了一个过程。

(gdb) info threads

Will display currently known threads. 将显示当前已知的线程。 The last column in the output shows function and library for the last stack frame for each thread. 输出的最后一列显示每个线程的最后堆栈帧的函数和库。

If you want to see threads start routines and the libraries they belong to, you may use: 如果要查看线程启动例程及其所属的库,可以使用:

(gdb) thread apply all bt -3

This command will show you 3 stack frames (from bottom) for each thread. 该命令将为您显示每个线程3个堆栈帧(从底部开始)。 If you are using pthread library then function that goes right after start_thread() is your start routine. 如果您使用的是pthread库,则start_thread()之后的函数就是您的启动例程。

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

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