- publishing free software manuals
Valgrind 3.3 - Advanced Debugging and Profiling for GNU/Linux applications
by J. Seward, N. Nethercote, J. Weidendorfer and the Valgrind Development Team
Paperback (6"x9"), 164 pages
ISBN 0954612051
RRP £12.95 ($19.95)

Get a printed copy>>>

3.5 Suppressing errors

The error-checking tools detect numerous problems in the base libraries, such as the GNU C library, and the X11 client libraries, which come pre-installed on your GNU/Linux system. You can't easily fix these, but you don't want to see these errors (and yes, there are many!) So Valgrind reads a list of errors to suppress at startup. A default suppression file is created by the ‘./configure’ script when the system is built.

You can modify and add to the suppressions file at your leisure, or, better, write your own. Multiple suppression files are allowed. This is useful if part of your project contains errors you can't or don't want to fix, yet you don't want to continuously be reminded of them.

Note: By far the easiest way to add suppressions is to use the --gen-suppressions=yes flag described in 3.6.

Each error to be suppressed is described very specifically, to minimise the possibility that a suppression-directive inadvertantly suppresses a bunch of similar errors which you did want to see. The suppression mechanism is designed to allow precise yet flexible specification of errors to suppress.

If you use the -v flag, at the end of execution, Valgrind prints out one line for each used suppression, giving its name and the number of times it got used. Here's the suppressions used by a run of ‘valgrind --tool=memcheck ls -l’:

--27579-- supp: 1 socketcall.connect(serv_addr)
--27579-- supp: 1 socketcall.connect(serv_addr)
--27579-- supp: 6 strrchr/_dl_map_object_from_fd

Multiple suppressions files are allowed. By default, Valgrind uses ‘$PREFIX/lib/valgrind/default.supp’. You can ask to add suppressions from another file, by specifying --suppressions=/path/to/file.supp.

If you want to understand more about suppressions, look at an existing suppressions file whilst reading the following documentation. The file ‘glibc-2.3.supp’, in the source distribution, provides some good examples.

Each suppression has the following components:

A suppression only suppresses an error when the error matches all the details in the suppression. Here's an example:


What it means is: for Memcheck only, suppress a use-of-uninitialised-value error, when the data size is 4, when it occurs in the function ‘__gconv_transform_ascii_internal’, when that is called from any function of name matching ‘__mbr*toc’, when that is called from ‘mbtowc’. It doesn't apply under any other circumstances. The string by which this suppression is identified to the user is ‘__gconv_transform_ascii_internal/__mbrtowc/mbtowc’.

(See 5.4 for more details on the specifics of Memcheck's suppression kinds.)

Another example, again for the Memcheck tool:


Suppress any size 4 uninitialised-value error which occurs anywhere in ‘libX11.so.6.2’, when called from anywhere in the same library, when called from anywhere in ‘libXaw.so.7.0’. The inexact specification of locations is regrettable, but is about all you can hope for, given that the X11 libraries shipped on the Linux distro on which this example was made have had their symbol tables removed.

Although the above two examples do not make this clear, you can freely mix ‘obj:’ and ‘fun:’ lines in a suppression.

ISBN 0954612051Valgrind 3.3 - Advanced Debugging and Profiling for GNU/Linux applicationsSee the print edition