3
votes

I'm trying to debug a process that forks when processing a request.

I've set follow-fork-mode to child allow gdb to break in when hitting a breakpoint in a child. However, when I continue from the child, the parent detaches.

Lots of doc points to the option detach-on-fork, but if I try to set this option, I get:

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

The option is clearly linked from: http://sourceware.org/gdb/onlinedocs/gdb/Forks.html

Edit: system information

>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".

Edit #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.

I guess it was added sometime between 6.3 and 6.5. I didn't realize this box had such an old version of gdb. Thanks!

If anyone who commented wants to add an answer, I'll accept it!

1
What OS/kernel are you using, and what GDB version? - Nicholas Riley
CentOS 4.4, 2.6.9, GDB 6.3, edited more information into first post - rrhartjr
Does GDB 6.3 support the flag you're using? You may need to update to a later version. - Aaron Saarela
Sometimes you just need a public forum to get you to start checking the obvious. Switched to another machine with gdb 6.5 and the command is supported. - rrhartjr
Yeah, RHEL/CentOS has some incredibly old versions of software. It can be rather infuriating. - Nicholas Riley

1 Answers

2
votes

The detach-on-fork option was added in GDB 6.5. At the time it only worked on Linux; not sure if additional OS support has been added since then.