Skip to content

Valgrind

Joe Edwards edited this page Apr 19, 2024 · 4 revisions

On a Linux machine with Valgrind installed, to run Valgrind on GAP there are three steps to follow:

Step 1: Configure GAP with --enable-valgrind

In a clean GAP directory:

./autogen.sh
./configure --enable-valgrind
make

If your CPU has multiple threads, you can speed this up by appending -j<number of threads> to make; for example, make -j8.

Step 2: Rebuild your packages

When GAP has been rebuilt, you need to also rebuild your packages. In most instances, this can be done by changing into the pkg directory of your GAP installation and running:

../bin/BuildPackages.sh [--parallel][name of packages to build]

If you don't specify any packages to rebuild, the script will attempt to rebuild every package in the pkg directory. This may be slow; consider passing the --parallel flag to speed things up.

If you are only intending to use Valgrind for the semigroups package, you should be able to just run:

../bin/BuildPackages.sh datastructures digraphs genss images IO orb

If you have packages in a directory other than gap/pkg, you will need to rebuild them separately. This is explained in slightly more detail on this page in the GAP reference manual.

Step 3: run Valgrind

If the previous two steps worked successfully, you should now be launch GAP with Valgrind with:

valgrind --trace-children=yes --leak-check=full gap

The flag trace-children indicates that you want to use Valgrind inside the actual GAP executable, not just in the script that starts it. The additional flag --leak-check=full checks for memory leaks. Then when you exit, Valgrind will show a list of any memory allocations that were not freed.

This should allow you to use Valgrind. The rest is just using the debugger as normal.

This page contains instructions for debugging with GDB if an error is found.

Clone this wiki locally