How to debug with valgrind

From KratosWiki
Revision as of 11:45, 27 December 2013 by Roigcarlo (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Using the 'valgrind' program helps to recognize memory errors. To debug with valgrind using the command line while inside the example directory, execute the following line:

valgrind python >debugtest.out

The debug process for "" is saved in "debugtest.out". Several valgrind options are accesible by using the following command:

valgrind --help

So the following line could be a useful option for a thorough debug:

valgrind --leak-check=full python >debugtest.out

There are some cases in which valgrind gives a "Conditional jump or move depends on uninitialised value(s)" message where the origin of the error can be found some statements before. In those cases, the "--track-origins=yes" option can be very useful in finding the real source of error.

valgrind --track-origins=yes python >debugtest.out

Sometimes Valgrind outputs can be quite long and confusin. Using "--leak-resolution=high" and "--show-reachable=yes" can reduce the lenght of the report. Additionally a supression file can be used to hide python related issues "--suppressions=$PATH_TO_SUPP_FILE/valgrind-python.supp"

valgrind --leak-resolution=high --show-reachable=yes --suppressions=/usr/share/doc/python-devel-2.7.3/valgrind-python.supp >debugtest.out

If instead of using the command line, the commands are written in "emacs", reading the output files can be much easier.

Personal tools