4

best methodology to debug a Linux daemon written in C++

view full story
linux-howto

http://www.linuxforums.org – Hi All, I have a bunch of C++ application which runs as daemons in Linux. Furthermore, since these daemons rely on each other, they use IPC (inter-process communication) to communicate with each other. These daemons are compiled with -g -O0 compiler flags, and started in right order using a shell script. These daemons seems to have buggy behaviour and "sometimes" crash. Another reason for it to crash might be corrupted input data that it processes. To find out about the real cause, I tried both gdb and Valgrind to debug it. I used --leak-check=yes and --log-file=foo.txt options with Valgrind. However, Valgrind did not report any invalid write/read or uninitialized variable errors which may have caused the crash. FAQ on Valgrind's official website says that this is the nature of Valgrind that you can not change such that it can not replicate the native execution environment. What is the best debugger options to use with Valgrind or gdb to debug a Linux daemon ? Should I attach Valgrind or gdb to already running process ? or Is it ok to start the daemon with Valgrind in shell script ? Thanks. (HowTos)