Solution to valgrind: failed to start tool memcheck/callgrind

Background: I need to run memcheck/callgrind on a system without privilege to install software, so I build valgrind from source code.

Valgrind-3.12.0.tar.bz2 on Ubuntu 14.04 trusty
tar xf valgrind-3.12.0.tar.bz2
onegazhang@trusty:~/oss/valgrind-3.12.0$ VALGRIND_LIB=/home/onegazhang/oss/valgrind-3.12.0 coregrind/valgrind
valgrind: failed to start tool ‘memcheck’ for platform ‘amd64-linux’: No such file or directory

The solution is passing VALGRIND_LIB environment variable to valgrind.
onegazhang@trusty:~/oss/valgrind-3.12.0$ VALGRIND_LIB=/home/onegazhang/oss/valgrind-3.12.0/memcheck coregrind/valgrind
valgrind: no program specified
valgrind: Use –help for more information.

callgrind tool reported another error: ERROR: object ‘/home/onegazhang/oss/valgrind-3.12.0/callgrind/’ from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored. It is fixed by copying the library to desired location.

onegazhang@trusty:~/oss/valgrind-3.12.0$ cp -p /home/onegazhang/oss/valgrind-3.12.0/coregrind/ /home/onegazhang/oss/valgrind-3.12.0/callgrind

Then callgrind works in the same way as memcheck.

onegazhang@trusty:~/workspace$ VALGRIND_LIB=/home/onegazhang/oss/valgrind-3.12.0/callgrind /home/onegazhang/oss/valgrind-3.12.0/coregrind/valgrind –tool=callgrind ./memleak

Btw, the above procedure also worked on arm platform.

This entry was posted in CPP, debug, Open Source. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s