How do you tell Valgrind to completely suppress a particular .so file?

Jonathan M Davis picture Jonathan M Davis · Mar 4, 2010 · Viewed 19.6k times · Source

I'm trying to use Valgrind on a program that I'm working on, but Valgrind generates a bunch of errors for one of the libraries that I'm using. I'd like to be able to tell it to suppress all errors which involve that library. The closest rule that I can come up with for the suppression file is

{
   rule name
   Memcheck:Cond
   ...
   obj:/path/to/library/thelibrary.so
}

This doesn't entirely do the job, however. I have to create one of these for every suppression type that comes up (Cond, Value4, Param, etc), and it seems to still miss some errors which have the library in the stack trace.

Is there a way to give Valgrind a single suppression rule to make it completely ignore a particular library? And even if there is no way to make such a rule which covers all suppression types, is there at least a way to create a rule which ignores all errors of a particular suppression type from a particular library?

Answer

BillTorpey picture BillTorpey · Nov 19, 2010

For most of the suppression types, you omit the wildcard, like so:

{
   name
   Memcheck:Cond
   obj:/path/to/lib/lib.so.10.1
}

{
   name
   Memcheck:Free
   obj:/path/to/lib/lib.so.10.1
}

{
   name
   Memcheck:Value8
   obj:/path/to/lib/lib.so.10.1
}

Note that you must list each type of error separately, you can't wildcard them. You must also list the entire pathname of the library (as shown by valgrind, with any "decorations" like version numbers).

Also, leaks are handled differently -- for those you need something that looks like this:

{
   name
   Memcheck:Leak
   fun:*alloc
   ...
   obj:/path/to/lib/lib.so.10.1
   ...
}