You can use ps for this. From man ps :
-L Show threads, possibly with LWP and NLWP columns.
So you can do:
$ ps -L <pid>
and he will show you something like this:
PID LWP TTY STAT TIME COMMAND 4112 4112 ? Sl 65:35 /usr/lib/firefox/firefox 4112 4116 ? Sl 0:04 /usr/lib/firefox/firefox
Each line of output corresponds to one stream. This, of course, only works for a specific point in time. Use strace to track thread spawning, as suggested by Jonathan Reinhart.
An alternative to strace is, of course, gdb . For more on thread management in gdb, see this question . You can also read the section of the gdb manual section . Brief introduction:
$ gdb /usr/lib/firefox/firefox <pid> [... initialization output ...] > info threads # lists threads > thread <nr> # switch to thread <nr>
Your comment:
How can I determine where to set the breakpoint at the instruction level if the program only takes seconds?
This answer may help you here, as it shows how to break up thread creation (using pthread_create ) using gdb. Therefore, every time a thread is created, execution stops and you can explore.
source share