For debugging a child process on Linux, gdb has the ability to step into a child process after fork and exec. This behavior can be enabled with the follow-fork-mode child statement.
Put the statement
set follow-fork-mode child
in the .gdbinit file, located in the project work directory.
Now, setting some breakpoints in the code of the child process will cause gdb to halt execution.
Btw, I’ve looked for a corresponding GUI option in the debug dialog (CDT version 4.0.3), but I found none. So it seems that creating a .gdbinit file is currently the only solution for this.
Hello Dirk! I am working with Eclipse Juno and cannot find the location of the .gdbinit file. I looked in the project work directory as you indicated, but was not able to find the file. I did a search in the entire system and was able to find the file in /etc/gdb/gdbinit, added the statement, but was not able to save it. Can you please help me? I am trying to debug child processes. Thank you in advance,
Lourdes
Hi Lourdes,
changing /etc/gdb/gdbinit requires root privileges, but you shouldn’t change this file. Just copy the gdbinit file to your project work directory. I don’t know about Juno, but you might be able to set the path to the gdbinit file in Preferences->C/C++->Debug->GDB. Also check the eclipse community forums, http://www.eclipse.org/forums/index.php