In this example we'll debug a problem where sshd is hanging.
a. Find out your exit PID that is hanging by ps –ef | grep exit | egrep –v grep
b. Once you have that PID, type: dbx –a THAT_PID
c. This will bring you into the dbx command line.
d. Type in thread, you’ll see something similar to:
>$t1 run blocked 417997 k no pro _event_sleep
$t2 wait 0xf10002000101ca08 running 401633 k no pro _ptrgl
$t3 wait 0xf10002000101a208 running 438487 k no pro _ptrgl
e. If the PID has threaded, it will give you a list of TID’s (Thread ID’s).
f. You’ll want to look for threads that look abnormal I.E that are in a abnormal state, or in a WAIT or DEADLOCK condition.
g. To examine a thread, type: thread current and then the number right in front of the $t.
i. E.G: thread current 2
h. This will really do nothing, it just sets the attention to that thread.
i. Next type in x this will give you a thread dump, and you can sometimes see where it is hanging.
j. Next type in where this can also give you an idea of where it is hanging.
k. When you are done, type detach to exit out of the dbx session. If you type quit it will exit you out of the session but also kill the original PID.
I have used this to solve a lot of problems where things are hanging. Half of the time it’ll tell me EXACTLY where it is hanging. The one time I did this I found out the process was trying to read a file it didn’t have permission to and two threads were in a dead lock because of it.
If the PID of exit doesn’t work, try the parent ssh PID.