This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
how to debug a child process?
- From: Kai Zhu <kzhu at zhukai dot net>
- To: gdb at sources dot redhat dot com
- Date: Tue, 15 Jun 2004 22:36:20 -0700
- Subject: how to debug a child process?
- Reply-to: kzhu at zhukai dot net, kzhu at zhukai dot net
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