I have Linux system, and I writing program use Clion IDE which using CMake. I have a part my in program where I would like to debug child process I read a few topic from this forum, but I still doesn't know how or where just I can turn on this function:
gdb debugging child process after fork (follow-fork-mode child configured)
How do I debug the child process after fork() in gdb?
I just have tryed to setup flag CMAKE_CXX_FLAGS_DEBUG
as set follow-fork-mode child
but CMake give me error.
Below screenshot with all flags which are uses to compile and dbug my program.
So what and where I must set this function.
..::EDIT::..
I believe that is good way. I think Your tip was useful, but I have some next problem. After using Your instructions my code is crash on line
pid_t newProcessForClient = fork();
Statement is:
(gdb) set follow-fork-mode child [New process 31667] warning: File "/lib32/libthread_db-1.0.so" auto-loading has been declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto-load". warning: Unable to find libthread_db matching inferior's thread library, thread debugging will not be available. [Switching to process 31667] Continuing with signal SIGABRT.
Program terminated with signal SIGABRT, Aborted. The program no longer exists.
The debugging settings have nothing to do with cmake. CMAKE_CXX_FLAGS_DEBUG states the debug flags for the compiler. However, you need to tell set follow-fork-mode child to the debugger. To do this, you need the following steps:
Set a break point at the beginning of your program (ie. the parent program, not the child program)
Start the program in the debugger.
The command set auto-load safe-path / is supposed to switch of the auto-load restrictions according to the documentation of gdb.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With