Irbis
Irbis

Reputation: 13369

gdb - multiple threads and shared libs

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 ?

Upvotes: 0

Views: 383

Answers (1)

ivaigult
ivaigult

Reputation: 6667

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.

Upvotes: 2

Related Questions