To debug multithreaded programs to in case of conditions such as deadlock or livelock, what are the useful utilities? I was wondering if gcore gives the stack dump of all running threds in the process or just the main thread. Also, does gcore suspend/kill the running process? Any information on debugging multithreaded programs will be very useful.
To debug multithreaded programs to in case of conditions such as deadlock or livelock,
Share
gdb has some nice features for working with threads. One of my favorites is
thread apply. This allows you to run the same command for multiple threads.For example, if you wanted to get a backtrace of all threads, you can use this:
To break this down, the command starts with
thread apply.Next is the list of threads. Here I used the keyword
allto apply this to every thread in the process. You can also use a space separated list of the gdb thread ids (thread apply 1 2 3 command).And finally comes the command to perform. I used
wherewhich shows you the call stack but you can use any command you want.