GDB- following child process with gdb
DEEPAK E P
deepak.embar@wipro.com
Tue Feb 27 04:22:00 GMT 2001
Hi ,
ÃÂ I have a red hat linux system. uname
-a Linux 2.2.14-12smp #1 SMP Tue Apr 25 12:58:06 EDT 2000 i686
unknown
ÃÂ
gdb --version GNU gdb 19991004 Copyright 1998
Free Software Foundation, Inc
ÃÂ ÃÂ I have not been able to follow the
child process after a fork call.
ÃÂ
ÃÂ Tried the following:
ÃÂ
(gdb) l 1ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ
main() 2ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ
{ 3ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ
int
j; 4ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ
printf("Hello world\n"); 5
6ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ
if (fork() == 0 )
{ 7ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ
printf("Chile
process\n"); 8ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ
} else
{ 9ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ
printf("Parent
process\n"); 10ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ
} (gdb) set follow-fork-mode child (gdb) show follow-fork-mode Debugger
response to a program call of fork or vfork is "child". (gdb) break
7 Breakpoint 1 at 0x804841e: file junk.c, line 7. (gdb) r Hello
world Parent process
ÃÂ
Program exited with code 017.
Note: I have compiled with -g option
: ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ gcc -g -o jk
junk.cÃÂ
Also tried : (gdb) break fork Breakpoint 1 at
0x804830c (gdb) r Starting program:
/home/deepakep/local/./jk Breakpoint 1 at 0x400abc90 Hello
world
ÃÂ
Breakpoint 1, 0x400abc90 in __libc_fork () from
/lib/libc.so.6 (gdb) return 0
ÃÂ
This also doesnt work.
Do i have to pick up a patch etc ??, or is it not
supported in the current version
of gdb i am using.
Thanks in advance for the help
dkÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ
More information about the Gdb
mailing list