Using and understanding the Valgrind core
--error-limit=<yes|no> [default:
yes]
When enabled, Valgrind stops reporting errors after 10,000,000 in total, or 1,000 different ones, have been seen. This
is to stop the error tracking machinery from becoming a huge performance overhead in programs with many errors.
--error-exitcode=<number> [default:
0]
Specifies an alternative exit code to return if Valgrind reported any errors in the run.
When set to the default value
(zero), the return value from Valgrind will always be the return value of the process being simulated. When set to a
nonzero value, that value is returned instead, if Valgrind detects any errors. This is useful for using Valgrind as part
of an automated test suite, since it makes it easy to detect test cases for which Valgrind has reported errors, just by
inspecting return codes.
--show-below-main=<yes|no> [default:
no]
By default, stack traces for errors do not show any functions that appear beneath
main
because most of the time it’s
uninteresting C library stuff and/or gobbledygook. Alternatively, if
main
is not present in the stack trace, stack traces
will not show any functions below
main
-like functions such as glibc’s
__libc_start_main
.
Furthermore, if
main
-like functions are present in the trace, they are normalised as
(below main)
, in order to make the output
more deterministic.
If this option is enabled, all stack trace entries will be shown and
main
-like functions will not be normalised.
--fullpath-after=<string> [default:
don’t show source paths]
By default Valgrind only shows the filenames in stack traces, but not full paths to source files.
When using
Valgrind in large projects where the sources reside in multiple different directories, this can be inconvenient.
--fullpath-after
provides a flexible solution to this problem.
When this option is present, the path to each
source file is shown, with the following all-important caveat: if
string
is found in the path, then the path up to and
including
string
is omitted, else the path is shown unmodified. Note that
string
is not required to be a prefix of
the path.
For
example,
consider
a
file
named
/home/janedoe/blah/src/foo/bar/xyzzy.c
.
Specify-
ing
--fullpath-after=/home/janedoe/blah/src/
will cause Valgrind to show the name as
foo/bar/xyzzy.c
.
Because the string is not required to be a prefix,
--fullpath-after=src/
will produce the same out-
put.
This is useful when the path contains arbitrary machine-generated characters.
For example,
the path
/my/build/dir/C32A1B47/blah/src/foo/xyzzy
can be pruned to
foo/xyzzy
using
--fullpath-after=/blah/src/
.
If you simply want to see the full path, just specify an empty string:
--fullpath-after=
. This isn’t a special
case, merely a logical consequence of the above rules.
Finally, you can use
--fullpath-after
multiple times.
Any appearance of it causes Valgrind to switch
to producing full paths and applying the above filtering rule.
Each produced path is compared against all the
--fullpath-after
-specified strings, in the order specified.
The first string to match causes the path to be
truncated as described above. If none match, the full path is shown. This facilitates chopping off prefixes when the
sources are drawn from a number of unrelated directories.
--suppressions=<filename> [default:
$PREFIX/lib/valgrind/default.supp]
Specifies an extra file from which to read descriptions of errors to suppress. You may use up to 100 extra suppression
files.
13