I have a program which create many threads. I can check it using following command: 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 ?
-
Threads do not belong to any shared library, and that makes your question exceedingly unclear. What is it that you are actually trying to achieve?Employed Russian– Employed Russian2015-05-27 03:22:47 +00:00Commented May 27, 2015 at 3:22
-
Please consider following example: I can use a htop to check how many cpu usage has each thread within a process. That program (process) loads some shared libraries. I want to find out which shared library creates threads which take cpu time.Irbis– Irbis2015-05-27 19:30:22 +00:00Commented May 27, 2015 at 19:30
Add a comment
|
1 Answer
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. If you are using pthread library then function that goes right after start_thread() is your start routine.
1 Comment
Irbis
Thanks (I used just bt without options to see a whole bt) , it helped me to verify some threads, but sometimes the output was unclear (a function name which calls something from boost).