how to attach to gdb forked child?
Jeremy C. Reed
reed at reedmedia.net
Thu Feb 14 20:00:20 PST 2008
I am trying to figure out where an abort core dump in imake is coming
from, so I do:
gdb /build/reed/tmp/pkgsrc/devel/imake/work.reed/imake-1.0.2/imake
. ..
(gdb) break main
Breakpoint 1 at 0x8048eb7: file imake.c, line 405.
(gdb) run
Starting program:
/build/reed/tmp/pkgsrc/devel/imake/work.reed/imake-1.0.2/imake
Breakpoint 1, main (argc=1, argv=0x0) at imake.c:405
405 {
(gdb) n
. . n several times ...
(gdb) n
458 cppit(cleanedImakefile, Template, ImakefileC, tmpfd,
tmpMakefile);
(gdb) n
So now I have a new process id.
I run gdb in a new terminal and get:
(gdb) attach 7858
Attaching to program:
/build/reed/tmp/pkgsrc/devel/imake/work.reed/imake-1.0.2/imake, process
7858
ptrace: Device busy.
(gdb) n
The program is not being run.
Any pointers?
Now gdb bt of the core dump is:
(gdb) bt
#0 0x280c2978 in kill () from /usr/lib/libc.so.6
#1 0x28117adc in abort () from /usr/lib/libc.so.6
#2 0x0804a0bd in get_stackprotector (inFile=0x281389f4) at imake.c:1061
#3 0x0804a5fc in define_os_defaults (inFile=0x281389f4) at imake.c:1711
#4 0x0804a68b in cppit (imakefile=0x804b40a "Imakefile",
template=0x804b250 "Imake.tmpl", masterc=0x804b25b "Imakefile.c",
outfd=0x28138880, outfname=0x804b247 "Makefile") at imake.c:1726
#5 0x08049122 in main (argc=1, argv=0xbfbff97c) at imake.c:458
(gdb) quit
But I thought I'd fine more details by stepping through it.
Looking at source I see for its get_stackprotector:
1059 }
1060 if (pclose(fp))
1061 abort();
1062 }
imake assumes the cc -v output is several lines.
So I see where the problem is probably at -- but can someone teach me how
to find it with gdb itself?
Thanks,
Jeremy C. Reed
More information about the Users
mailing list