Installing and Testing Valgrind on Linux

Valgrind is an instrumentation framework for building dynamic analysis tools. Which is a fancy way of saying that it's a debugging suite that automatically detects many memory management and threading bugs, which is a very good thing. Valgrind can handle dynamically generated code, so long as none of the generated code is later overwritten by other generated code. It can also perform detailed profiling to help speed up your programs. It comes with extensive documentation.

BTW, it's pronounced with a short 'i', named after the Nordic entrance hall to Valhalla. "Grin", as in smile, rather than "grind" as in what one does with coffee.

Installation and testing is very simple. Download the source from the site, extract in the usual place, run configure, make, and make install.

cd /usr/local/src/VALGRIND
tar xvjf valgrind-3.6.0.tar.bz2
cd valgrind-3.6.0
make install

The ../config file consists of;

./configure --prefix=/usr/local/$(basename $(pwd) | sed 's#-#/#')

Set the environment variables the usual way.

cd /usr/local/Modules/modulefiles
ln -s .base 3.6.0

If you don't have environment modules installed you should add the following to your appropriate path.

LD_LIBRARY_PATH /usr/local/valgrind/3.6.0/lib
MANPATH /usr/local/valgrind/3.6.0/man
PATH /usr/local/valgrind/3.6.0/bin

A short testing is achieved by running a usual program with a specified tool. Login a a normal user, load the environment variables and run the check.

module load valgrind/3.6.0
valgrind --tool=memcheck ./twelve