How can I run valgrind on an embedded Linux box to find memory leaks in my main software?
In the rcS script, I am running like this:
./main_app
How can I associate the ./main_app program with valgrind? The main_app process never terminates.
I want to constantly log the data to file. Also, I want to access the log file without terminating the main_app process. I can do telnet and can access the log file. But the problem is until and unless the handler is closed, how can I open the file i.e. I don't quite understand which valgrind parameters control how memory leaks are logged to file. Please help!
解决方案
You can try to build it by your own for mips, here the steps:
download valgrind from here http://valgrind.org/downloads/ - I used Valgrind 3.8.1
unpack archive with valgrind and move to the valgrinds folder
execute:
./autogen.sh
./configure --host=mipsel-linux-gnu --prefix=/home/pub/valgrind CFLAGS="-mips32r2" CC=/opt/toolchains/mips-4.3/bin/mips-linux-gnu-gcc CXX=/opt/toolchains/mips-4.3/bin/mips-linux-gnu-c++
./make -j6
./make install
prefix - folder to install compiled binaries of valgrind;
CC and CXX - path to compilers;
CFLAGS - "-mips32r2" and "-mplt" flags should be passed to compilers if it older then gcc (GCC) 4.5.1
on target mips box export path to valgrind lib folder:
export VALGRIND_LIB=/mnt/nfs/lib/valgrind
Now you can use it as usual, for memory checking features you can look here http://valgrind.org/docs/manual/mc-manual.html
It works for me, good luck.