Reputation: 335
I have a multi-threaded C process running under Linux. Occasionally, i.e.: few times a month, one of the threads hangs (it does not reach the sleep which is placed at the end of each thread).
How can I debug it? Is there a way to know what part of the code is executing when the thread gets stuck?
Upvotes: 1
Views: 1452
Reputation: 11
You can use GDB to debug coredumps.
#~ gdb <source binary> <coredump file>
In gdb process, call back trace to get the functions trace leads to crash.
gdb> bt
Upvotes: 0
Reputation: 22074
On Linux you can kill it with kill -11
and then look at the coredump. You can also attach a debugger and see what it's currently doing.
You can also add logging to see what it is doing.
Upvotes: 2