gdb:不要在fork上与父分离

时间:2011-04-08 20:12:52

标签: c gdb fork

我正在尝试调试处理请求时分叉的进程。

我已将follow-fork-mode设置为child允许gdb在命中子节点时遇到中断。但是,当我从孩子那里继续时,父母会分离。

很多文档指向选项detach-on-fork,但如果我尝试设置此选项,我会得到:

(gdb) set detach-on-fork on 
No symbol "detach" in current context.

该选项明确地与:http://sourceware.org/gdb/onlinedocs/gdb/Forks.html

相关联

编辑:系统信息

>uname -a
Linux localhost 2.6.9-78.0.22.ELsmp #1 SMP Thu Apr 30 19:14:39 EDT 2009 i686 i686 i386 GNU/Linux

>gdb -v
GNU gdb Red Hat Linux (6.3.0.0-1.132.EL4rh)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu".

编辑#2:

$ gdb -v
GNU gdb Red Hat Linux (6.5-16.el5rh)

(gdb) show detach-on-fork
Whether gdb will detach the child of a fork is on.

我猜它是在6.3到6.5之间添加的。我没有意识到这个盒子有这么老版本的gdb。谢谢!

如果评论的任何人想要添加答案,我会接受它!

1 个答案:

答案 0 :(得分:2)

detach-on-fork选项为added in GDB 6.5。当时它只适用于Linux;不确定自那时以来是否添加了额外的OS支持。