Using and understanding the Valgrind core
--vgdb-error=<number> [default:
999999999]
Use this option when the Valgrind gdbserver is enabled with
--vgdb=yes
or
--vgdb=full
. Tools that report
errors will wait for "
number
" errors to be reported before freezing the program and waiting for you to connect with
GDB. It follows that a value of zero will cause the gdbserver to be started before your program is executed. This is
typically used to insert GDB breakpoints before execution, and also works with tools that do not report errors, such as
Massif.
--track-fds=<yes|no> [default:
no]
When enabled, Valgrind will print out a list of open file descriptors on exit. Along with each file descriptor is printed
a stack backtrace of where the file was opened and any details relating to the file descriptor such as the file name or
socket details.
--time-stamp=<yes|no> [default:
no]
When enabled, each message is preceded with an indication of the elapsed wallclock time since startup, expressed as
days, hours, minutes, seconds and milliseconds.
--log-fd=<number> [default:
2, stderr]
Specifies that Valgrind should send all of its messages to the specified file descriptor. The default, 2, is the standard
error channel (stderr).
Note that this may interfere with the client’s own use of stderr, as Valgrind’s output will be
interleaved with any output that the client sends to stderr.
--log-file=<filename>
Specifies that Valgrind should send all of its messages to the specified file.
If the file name is empty, it causes an
abort. There are three special format specifiers that can be used in the file name.
%p
is replaced with the current process ID. This is very useful for program that invoke multiple processes. WARNING:
If you use
--trace-children=yes
and your program invokes multiple processes OR your program forks without
calling exec afterwards, and you don’t use this specifier (or the
%q
specifier below), the Valgrind output from all those
processes will go into one file, possibly jumbled up, and possibly incomplete.
%q{FOO}
is replaced with the contents of the environment variable
FOO
. If the
{FOO}
part is malformed, it causes an
abort. This specifier is rarely needed, but very useful in certain circumstances (eg. when running MPI programs). The
idea is that you specify a variable which will be set differently for each process in the job, for example
BPROC_RANK
or whatever is applicable in your MPI setup. If the named environment variable is not set, it causes an abort. Note
that in some shells, the
{
and
}
characters may need to be escaped with a backslash.
%%
is replaced with
%
.
If an
%
is followed by any other character, it causes an abort.
--log-socket=<ip-address:port-number>
Specifies that Valgrind should send all of its messages to the specified port at the specified IP address.
The port
may be omitted, in which case port 1500 is used.
If a connection cannot be made to the specified socket, Valgrind
falls back to writing output to the standard error (stderr). This option is intended to be used in conjunction with the
valgrind-listener
program. For further details, see
the commentary
in the manual.
2.6.3. Error-related Options
These options are used by all tools that can report errors, e.g. Memcheck, but not Cachegrind.
11