0

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 ?

2
  • 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? Commented 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. Commented May 27, 2015 at 19:30

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

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).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.