I have a application which forks a child process.
Child process does some work and somewhere in the middle it gives Segmentation fault. I used GDB to debug this, I used:
set follow-fork-mode child
I have also set a breakpoint to a function within the child. But GDB doesn't pause at my breakpoint.
Also the parent process handles the seg-fault so I had to ctrl-c to exit. Then when I use backtrace
to print the stack all I got is
No stack
Why is the breakpoint not being set and why didn't I get the stack?
gprof
is for profiling, not debugging. I'm (still) assuming you want to find out where you child process dies and not to profile it. To rebuild it in debug mode you should doexport CFLAGS=-g
in your shell (bash) before you doconfigure
(I am assuming you know how to build programs from sources). I did a lot of debugging of child processes, and I cannot recall even one situation whenfollow-fork-mode
in gdb worked as expected without giving me a headache, so I am trying to provide you with a workaround. – sirgeorge