Examine where my program got stuck using GDB
Could some one please tell me how to examine the last place where my program got stuck. Can it be done with gdb or any UNIX syscall that may work on that pro开发者_如何学Ccess. Here's the situation.
I have a TCP client server code with 6 clients and 6 servers processes.(There is a client and a server program and 6 copies of each are made to run in the experiment) What happens is that a few of the clients(2-4) get stuck in a non deterministic way. We have a sequential 'for' loop in each client that communicates randomly with one of the servers at a time. But after some iterations, at the end of the loop the client gets stuck. I have put displays but it tells me that the code simply refuses to go to the start of the next iteration, though it has completed the previous iteration. When I do a 'top -p ', this client shows 100% CPU usage and it stays so forever. About 98% usage is idle. Anyone has any idea with this :)
cheers... Raman
You can use strace
to see a live stream of all the syscalls that your program executes. If your program hangs on a system call, you will see which one is the culprit.
精彩评论