gdb support for follow-fork
Dmitry Mikulin
dmitrym at juniper.net
Thu Apr 12 20:18:34 UTC 2012
Hi,
I implemented support for follow-fork mode in gdb and would like to submit it for a review. The feature allows users to specify which process to follow when the inferior does a fork(). The default mode is to stay with the parent. A gdb command is used to switch between following the child/parent:
set follow-fork-mode child
set follow-fork-mode parent
When gdb is set to follow the child, it detaches from the parent at the fork() point and continues to trace the newly created child.
Gdb uses support that has recently been implemented in the FreeBSD kernel. A new ptrace() request, PT_FOLLOW_FORK was added to generate a SIGTRAP at the point where a child process is created. This allows gdb switch from parent to child. PT_FOLLOW_EXEC was added to SIGTRAP on return from exit() to allow gdb to load a new binary for debugging.
I attached the patch here.
Please let me know if can provide additional info.
Thanks.
Dmitry.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gdb-6.1.1-follow-fork.patch
Type: text/x-patch
Size: 28267 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-toolchain/attachments/20120412/c2e21c5c/gdb-6.1.1-follow-fork.bin
More information about the freebsd-toolchain
mailing list