How to switch threads in gdb while a thread is being blocked

Alexandru Sutii
2011-03-28T20:45:06Z

Hello!

I am developing a GUI application that uses gdb. The purpose of the
application is
to give the user the chance to graphically see what happens when processes
communicate using IPC, or when a process blocks when taking a mutex, and so on.

I have a problem with processes that block waiting for another process
to take an action.
For instance, say I have the following situation: A process P creates
a child process C.
The child and the parent communicate through a pipe. After fork() the
parent waits for the
child to write something in the pipe. If debugging this in gdb the
parent blocks when waiting
for the child to write in the pipe. As a result gdb freezes and I
cannot switch to the child
process in order to make it write in the pipe, so the parent could
continue. I mention that
I set detach-on-fork off.

Is there a way to switch threads in gdb after the current
thread/process blocks? I have also
thought of setting detach-on-fork on and try to attache to the newly
created process with
another gdb instance, but I didn't manage to accomplish this. Any
advices are welcome.

Thanks in advance.
--Alex.