Tracking pthreads in linux?

I did not find a tool created to track pthread threads in a linux process. I want something like strace / ltrace, is there something to view calls in real time? Thanks you

+8
c multithreading linux
source share
2 answers

strace also works for threads. Use strace -f to bind all threads.

To bind only a specific thread, you first need to find its tid (thread id). Themes have a thread id, which is really a pid (process id)

Once you know the pid of the stream, use strace -p the_pid to bind this stream.

The pit of all threads in the process can be found in /proc/<pid>/task/ , or the current thread ID can be found by calling gettid() C.

+14
source share

actually strace is not as good as perf.

use perf tool, you can get more information.

for example, if some of your threads freeze, and you want to know which functions cause freezes, use strace -p pid-id returns limited information, but perf top or perf -t tid returns more

0
source share

All Articles