Problems debugging forked processes
Frank Schaefer
frank.schafer@setuza.cz
Fri Apr 19 00:45:00 GMT 2002
Hi there,
I've written a network daemon and client. The daemon forks to serve a
client request.
Everything runs fine outside of the debugger, but I want to trace the
code at least once, before I release it.
Here goes my problem:
# gdb daemon
GNU gdb 5.0
Copyright 2000 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 "i686-pc-linux-gnu"...
(gdb) b 13
Breakpoint 1 at 0x8048899: file daemon.c, line 13.
(gdb) show follow-fork-mode
Debugger response to a program call of fork or vfork is "parent".
(gdb) set follow-fork-mode child
(gdb) show follow-fork-mode
Debugger response to a program call of fork or vfork is "child".
(gdb) run
Starting program: /v_dsk/home/p10209/Tests/daemon
Breakpoint 1, main () at syncboot.c:15
15 int On = 1;
(gdb) n
...
(gdb) n
67 ChildPid = fork();
(gdb) n
69 sleep( 10 );
(gdb) print ChildPid
$1 = 3700
So it seems, I'm tracing the parent process - don't it? The same
happens, If I do:
(gdb) set follow-fork-mode ask
instead of child. I'm not asked anything and remain debugging the
parent.
If I use the attach method from a second instance of gdb ( there's the
sleep() above for ), the child process exits on exceptions ( mostly
segmentation fault and sometimes invalid operation ) on different
(random???) lines in the code. This happens everytime in the fixup()
from ld.linux.so.
I'm using gdb 5.0, my compiler is gcc 2.95.3 on a glibc-2.2.4
linux-2.4.16 system. I have Binutils 2.11 installed.
Furtheron I've attached reduced versions of the code, for which the
fault still occurs.
Any suggestions?
Regards
Frank
-------------- next part --------------
A non-text attachment was scrubbed...
Name: daemon.c
Type: text/x-c
Size: 2731 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/gdb/attachments/20020419/fe0daeab/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: client.c
Type: text/x-c
Size: 1401 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/gdb/attachments/20020419/fe0daeab/attachment-0001.bin>
More information about the Gdb
mailing list