how to debug a child process?

Kai Zhu kzhu@zhukai.net
Wed Jun 16 05:31:00 GMT 2004


Hello List,

This is my first time using GDB to debug a child process, although I 
used it for multi-threaded program before. I followed the manual: (1) 
setting a sleep in child right after fork(), then attach to the child 
(tried both with just this single GDB and with another GDB hooked to the 
parent). Now I observed two things

(1) sleep() immediately returns if I continue after the successful 
attachment
(2) if I set any breakpoint in the child then continue, then when the 
point is hit, the child *still* receives a SIGTRAP

I guess (1) is related to the ways GDB interrupts a running process, 
which is understandable; but for (2), the GDB session will switch to the 
parent process and I cannot debug the child process at all.

Any help will be appreciated,

Kai



More information about the Gdb mailing list