blob: ee9e5b625a8a6dbdf058519a4c23bc98eab1a615 [file] [log] [blame]
Elliott Hughesa0664b92017-04-18 17:46:52 -07001'\" t
2.\" Title: VALGRIND
3.\" Author: [see the "Author" section]
Elliott Hughesed398002017-06-21 14:41:24 -07004.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
5.\" Date: 06/15/2017
6.\" Manual: Release 3.13.0
7.\" Source: Release 3.13.0
Elliott Hughesa0664b92017-04-18 17:46:52 -07008.\" Language: English
9.\"
Elliott Hughesed398002017-06-21 14:41:24 -070010.TH "VALGRIND" "1" "06/15/2017" "Release 3.13.0" "Release 3.13.0"
Elliott Hughesa0664b92017-04-18 17:46:52 -070011.\" -----------------------------------------------------------------
12.\" * Define some portability stuff
13.\" -----------------------------------------------------------------
14.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15.\" http://bugs.debian.org/507673
16.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18.ie \n(.g .ds Aq \(aq
19.el .ds Aq '
20.\" -----------------------------------------------------------------
21.\" * set default formatting
22.\" -----------------------------------------------------------------
23.\" disable hyphenation
24.nh
25.\" disable justification (adjust text to left margin only)
26.ad l
27.\" -----------------------------------------------------------------
28.\" * MAIN CONTENT STARTS HERE *
29.\" -----------------------------------------------------------------
30.SH "NAME"
31valgrind \- a suite of tools for debugging and profiling programs
32.SH "SYNOPSIS"
33.HP \w'\fBvalgrind\fR\ 'u
34\fBvalgrind\fR [\fIvalgrind\-options\fR] [\fByour\-program\fR] [\fIyour\-program\-options\fR]
35.SH "DESCRIPTION"
36.PP
37\fBValgrind\fR
38is a flexible program for debugging and profiling Linux executables\&. It consists of a core, which provides a synthetic CPU in software, and a series of debugging and profiling tools\&. The architecture is modular, so that new tools can be created easily and without disturbing the existing structure\&.
39.PP
40Some of the options described below work with all Valgrind tools, and some only work with a few or one\&. The section MEMCHECK OPTIONS and those below it describe tool\-specific options\&.
41.PP
42This manual page covers only basic usage and options\&. For more comprehensive information, please see the HTML documentation on your system:
43$INSTALL/share/doc/valgrind/html/index\&.html, or online:
44http://www\&.valgrind\&.org/docs/manual/index\&.html\&.
45.SH "TOOL SELECTION OPTIONS"
46.PP
47The single most important option\&.
48.PP
49\fB\-\-tool=<toolname> [default: memcheck] \fR
50.RS 4
51Run the Valgrind tool called
52\fItoolname\fR, e\&.g\&. memcheck, cachegrind, callgrind, helgrind, drd, massif, lackey, none, exp\-sgcheck, exp\-bbv, exp\-dhat, etc\&.
53.RE
54.SH "BASIC OPTIONS"
55.PP
56These options work with all tools\&.
57.PP
58\fB\-h \-\-help\fR
59.RS 4
60Show help for all options, both for the core and for the selected tool\&. If the option is repeated it is equivalent to giving
61\fB\-\-help\-debug\fR\&.
62.RE
63.PP
64\fB\-\-help\-debug\fR
65.RS 4
66Same as
67\fB\-\-help\fR, but also lists debugging options which usually are only of use to Valgrind\*(Aqs developers\&.
68.RE
69.PP
70\fB\-\-version\fR
71.RS 4
72Show the version number of the Valgrind core\&. Tools can have their own version numbers\&. There is a scheme in place to ensure that tools only execute when the core version is one they are known to work with\&. This was done to minimise the chances of strange problems arising from tool\-vs\-core version incompatibilities\&.
73.RE
74.PP
75\fB\-q\fR, \fB\-\-quiet\fR
76.RS 4
77Run silently, and only print error messages\&. Useful if you are running regression tests or have some other automated test machinery\&.
78.RE
79.PP
80\fB\-v\fR, \fB\-\-verbose\fR
81.RS 4
82Be more verbose\&. Gives extra information on various aspects of your program, such as: the shared objects loaded, the suppressions used, the progress of the instrumentation and execution engines, and warnings about unusual behaviour\&. Repeating the option increases the verbosity level\&.
83.RE
84.PP
85\fB\-\-trace\-children=<yes|no> [default: no] \fR
86.RS 4
87When enabled, Valgrind will trace into sub\-processes initiated via the
88\fIexec\fR
89system call\&. This is necessary for multi\-process programs\&.
90.sp
91Note that Valgrind does trace into the child of a
92\fIfork\fR
93(it would be difficult not to, since
94\fIfork\fR
95makes an identical copy of a process), so this option is arguably badly named\&. However, most children of
96\fIfork\fR
97calls immediately call
98\fIexec\fR
99anyway\&.
100.RE
101.PP
102\fB\-\-trace\-children\-skip=patt1,patt2,\&.\&.\&. \fR
103.RS 4
104This option only has an effect when
105\fB\-\-trace\-children=yes\fR
106is specified\&. It allows for some children to be skipped\&. The option takes a comma separated list of patterns for the names of child executables that Valgrind should not trace into\&. Patterns may include the metacharacters
107?
108and
109*, which have the usual meaning\&.
110.sp
111This can be useful for pruning uninteresting branches from a tree of processes being run on Valgrind\&. But you should be careful when using it\&. When Valgrind skips tracing into an executable, it doesn\*(Aqt just skip tracing that executable, it also skips tracing any of that executable\*(Aqs child processes\&. In other words, the flag doesn\*(Aqt merely cause tracing to stop at the specified executables \-\- it skips tracing of entire process subtrees rooted at any of the specified executables\&.
112.RE
113.PP
114\fB\-\-trace\-children\-skip\-by\-arg=patt1,patt2,\&.\&.\&. \fR
115.RS 4
116This is the same as
117\fB\-\-trace\-children\-skip\fR, with one difference: the decision as to whether to trace into a child process is made by examining the arguments to the child process, rather than the name of its executable\&.
118.RE
119.PP
120\fB\-\-child\-silent\-after\-fork=<yes|no> [default: no] \fR
121.RS 4
122When enabled, Valgrind will not show any debugging or logging output for the child process resulting from a
123\fIfork\fR
124call\&. This can make the output less confusing (although more misleading) when dealing with processes that create children\&. It is particularly useful in conjunction with
125\fI\-\-trace\-children=\fR\&. Use of this option is also strongly recommended if you are requesting XML output (\fI\-\-xml=yes\fR), since otherwise the XML from child and parent may become mixed up, which usually makes it useless\&.
126.RE
127.PP
128\fB\-\-vgdb=<no|yes|full> [default: yes] \fR
129.RS 4
130Valgrind will provide "gdbserver" functionality when
131\fB\-\-vgdb=yes\fR
132or
133\fB\-\-vgdb=full\fR
134is specified\&. This allows an external GNU GDB debugger to control and debug your program when it runs on Valgrind\&.
135\fB\-\-vgdb=full\fR
136incurs significant performance overheads, but provides more precise breakpoints and watchpoints\&. See
137Debugging your program using Valgrind's gdbserver and GDB
138for a detailed description\&.
139.sp
140If the embedded gdbserver is enabled but no gdb is currently being used, the
141vgdb
142command line utility can send "monitor commands" to Valgrind from a shell\&. The Valgrind core provides a set of
143Valgrind monitor commands\&. A tool can optionally provide tool specific monitor commands, which are documented in the tool specific chapter\&.
144.RE
145.PP
146\fB\-\-vgdb\-error=<number> [default: 999999999] \fR
147.RS 4
148Use this option when the Valgrind gdbserver is enabled with
149\fB\-\-vgdb=yes\fR
150or
151\fB\-\-vgdb=full\fR\&. 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\&.
152.RE
153.PP
154\fB\-\-vgdb\-stop\-at=<set> [default: none] \fR
155.RS 4
156Use this option when the Valgrind gdbserver is enabled with
157\fB\-\-vgdb=yes\fR
158or
159\fB\-\-vgdb=full\fR\&. The Valgrind gdbserver will be invoked for each error after
160\fB\-\-vgdb\-error\fR
161have been reported\&. You can additionally ask the Valgrind gdbserver to be invoked for other events, specified in one of the following ways:
162.sp
163.RS 4
164.ie n \{\
165\h'-04'\(bu\h'+03'\c
166.\}
167.el \{\
168.sp -1
169.IP \(bu 2.3
170.\}
171a comma separated list of one or more of
172\fBstartup exit valgrindabexit\fR\&.
173.sp
174The values
Elliott Hughesed398002017-06-21 14:41:24 -0700175\fBstartup\fR
176\fBexit\fR
177\fBvalgrindabexit\fR
Elliott Hughesa0664b92017-04-18 17:46:52 -0700178respectively indicate to invoke gdbserver before your program is executed, after the last instruction of your program, on Valgrind abnormal exit (e\&.g\&. internal error, out of memory, \&.\&.\&.)\&.
179.sp
180Note:
181\fBstartup\fR
182and
183\fB\-\-vgdb\-error=0\fR
184will both cause Valgrind gdbserver to be invoked before your program is executed\&. The
185\fB\-\-vgdb\-error=0\fR
186will in addition cause your program to stop on all subsequent errors\&.
187.RE
188.sp
189.RS 4
190.ie n \{\
191\h'-04'\(bu\h'+03'\c
192.\}
193.el \{\
194.sp -1
195.IP \(bu 2.3
196.\}
197\fBall\fR
198to specify the complete set\&. It is equivalent to
199\fB\-\-vgdb\-stop\-at=startup,exit,valgrindabexit\fR\&.
200.RE
201.sp
202.RS 4
203.ie n \{\
204\h'-04'\(bu\h'+03'\c
205.\}
206.el \{\
207.sp -1
208.IP \(bu 2.3
209.\}
210\fBnone\fR
211for the empty set\&.
212.RE
213.RE
214.PP
215\fB\-\-track\-fds=<yes|no> [default: no] \fR
216.RS 4
217When enabled, Valgrind will print out a list of open file descriptors on exit or on request, via the gdbserver monitor command
218\fIv\&.info open_fds\fR\&. 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\&.
219.RE
220.PP
221\fB\-\-time\-stamp=<yes|no> [default: no] \fR
222.RS 4
223When enabled, each message is preceded with an indication of the elapsed wallclock time since startup, expressed as days, hours, minutes, seconds and milliseconds\&.
224.RE
225.PP
226\fB\-\-log\-fd=<number> [default: 2, stderr] \fR
227.RS 4
228Specifies 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\*(Aqs own use of stderr, as Valgrind\*(Aqs output will be interleaved with any output that the client sends to stderr\&.
229.RE
230.PP
231\fB\-\-log\-file=<filename> \fR
232.RS 4
233Specifies 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\&.
234.sp
235\fB%p\fR
236is replaced with the current process ID\&. This is very useful for program that invoke multiple processes\&. WARNING: If you use
237\fB\-\-trace\-children=yes\fR
238and your program invokes multiple processes OR your program forks without calling exec afterwards, and you don\*(Aqt use this specifier (or the
239\fB%q\fR
Elliott Hughesed398002017-06-21 14:41:24 -0700240specifier below), the Valgrind output from all those processes will go into one file, possibly jumbled up, and possibly incomplete\&. Note: If the program forks and calls exec afterwards, Valgrind output of the child from the period between fork and exec will be lost\&. Fortunately this gap is really tiny for most programs; and modern programs use
241posix_spawn
242anyway\&.
243.sp
244\fB%n\fR
245is replaced with a file sequence number unique for this process\&. This is useful for processes that produces several files from the same filename template\&.
Elliott Hughesa0664b92017-04-18 17:46:52 -0700246.sp
247\fB%q{FOO}\fR
248is replaced with the contents of the environment variable
249\fIFOO\fR\&. If the
250\fB{FOO}\fR
251part 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
252BPROC_RANK
253or 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
254\fB{\fR
255and
256\fB}\fR
257characters may need to be escaped with a backslash\&.
258.sp
259\fB%%\fR
260is replaced with
261\fB%\fR\&.
262.sp
263If an
264\fB%\fR
265is followed by any other character, it causes an abort\&.
266.sp
Elliott Hughesed398002017-06-21 14:41:24 -0700267If the file name specifies a relative file name, it is put in the program\*(Aqs initial working directory: this is the current directory when the program started its execution after the fork or after the exec\&. If it specifies an absolute file name (ie\&. starts with \*(Aq/\*(Aq) then it is put there\&.
Elliott Hughesa0664b92017-04-18 17:46:52 -0700268.RE
269.PP
270\fB\-\-log\-socket=<ip\-address:port\-number> \fR
271.RS 4
272Specifies 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
273valgrind\-listener
274program\&. For further details, see
275the commentary
276in the manual\&.
277.RE
Elliott Hughesed398002017-06-21 14:41:24 -0700278.SH "ERROR\-RELATED OPTIONS"
Elliott Hughesa0664b92017-04-18 17:46:52 -0700279.PP
280These options are used by all tools that can report errors, e\&.g\&. Memcheck, but not Cachegrind\&.
281.PP
282\fB\-\-xml=<yes|no> [default: no] \fR
283.RS 4
284When enabled, the important parts of the output (e\&.g\&. tool error messages) will be in XML format rather than plain text\&. Furthermore, the XML output will be sent to a different output channel than the plain text output\&. Therefore, you also must use one of
285\fB\-\-xml\-fd\fR,
286\fB\-\-xml\-file\fR
287or
288\fB\-\-xml\-socket\fR
289to specify where the XML is to be sent\&.
290.sp
291Less important messages will still be printed in plain text, but because the XML output and plain text output are sent to different output channels (the destination of the plain text output is still controlled by
292\fB\-\-log\-fd\fR,
293\fB\-\-log\-file\fR
294and
295\fB\-\-log\-socket\fR) this should not cause problems\&.
296.sp
297This option is aimed at making life easier for tools that consume Valgrind\*(Aqs output as input, such as GUI front ends\&. Currently this option works with Memcheck, Helgrind, DRD and SGcheck\&. The output format is specified in the file
298docs/internals/xml\-output\-protocol4\&.txt
299in the source tree for Valgrind 3\&.5\&.0 or later\&.
300.sp
301The recommended options for a GUI to pass, when requesting XML output, are:
302\fB\-\-xml=yes\fR
303to enable XML output,
304\fB\-\-xml\-file\fR
305to send the XML output to a (presumably GUI\-selected) file,
306\fB\-\-log\-file\fR
307to send the plain text output to a second GUI\-selected file,
308\fB\-\-child\-silent\-after\-fork=yes\fR, and
309\fB\-q\fR
310to restrict the plain text output to critical error messages created by Valgrind itself\&. For example, failure to read a specified suppressions file counts as a critical error message\&. In this way, for a successful run the text output file will be empty\&. But if it isn\*(Aqt empty, then it will contain important information which the GUI user should be made aware of\&.
311.RE
312.PP
313\fB\-\-xml\-fd=<number> [default: \-1, disabled] \fR
314.RS 4
315Specifies that Valgrind should send its XML output to the specified file descriptor\&. It must be used in conjunction with
316\fB\-\-xml=yes\fR\&.
317.RE
318.PP
319\fB\-\-xml\-file=<filename> \fR
320.RS 4
321Specifies that Valgrind should send its XML output to the specified file\&. It must be used in conjunction with
322\fB\-\-xml=yes\fR\&. Any
323\fB%p\fR
324or
325\fB%q\fR
326sequences appearing in the filename are expanded in exactly the same way as they are for
327\fB\-\-log\-file\fR\&. See the description of
Elliott Hughesed398002017-06-21 14:41:24 -0700328--log-file
Elliott Hughesa0664b92017-04-18 17:46:52 -0700329for details\&.
330.RE
331.PP
332\fB\-\-xml\-socket=<ip\-address:port\-number> \fR
333.RS 4
334Specifies that Valgrind should send its XML output the specified port at the specified IP address\&. It must be used in conjunction with
335\fB\-\-xml=yes\fR\&. The form of the argument is the same as that used by
336\fB\-\-log\-socket\fR\&. See the description of
337\fB\-\-log\-socket\fR
338for further details\&.
339.RE
340.PP
341\fB\-\-xml\-user\-comment=<string> \fR
342.RS 4
343Embeds an extra user comment string at the start of the XML output\&. Only works when
344\fB\-\-xml=yes\fR
345is specified; ignored otherwise\&.
346.RE
347.PP
348\fB\-\-demangle=<yes|no> [default: yes] \fR
349.RS 4
350Enable/disable automatic demangling (decoding) of C++ names\&. Enabled by default\&. When enabled, Valgrind will attempt to translate encoded C++ names back to something approaching the original\&. The demangler handles symbols mangled by g++ versions 2\&.X, 3\&.X and 4\&.X\&.
351.sp
352An important fact about demangling is that function names mentioned in suppressions files should be in their mangled form\&. Valgrind does not demangle function names when searching for applicable suppressions, because to do otherwise would make suppression file contents dependent on the state of Valgrind\*(Aqs demangling machinery, and also slow down suppression matching\&.
353.RE
354.PP
355\fB\-\-num\-callers=<number> [default: 12] \fR
356.RS 4
357Specifies the maximum number of entries shown in stack traces that identify program locations\&. Note that errors are commoned up using only the top four function locations (the place in the current function, and that of its three immediate callers)\&. So this doesn\*(Aqt affect the total number of errors reported\&.
358.sp
359The maximum value for this is 500\&. Note that higher settings will make Valgrind run a bit more slowly and take a bit more memory, but can be useful when working with programs with deeply\-nested call chains\&.
360.RE
361.PP
362\fB\-\-unw\-stack\-scan\-thresh=<number> [default: 0] \fR, \fB\-\-unw\-stack\-scan\-frames=<number> [default: 5] \fR
363.RS 4
364Stack\-scanning support is available only on ARM targets\&.
365.sp
366These flags enable and control stack unwinding by stack scanning\&. When the normal stack unwinding mechanisms \-\- usage of Dwarf CFI records, and frame\-pointer following \-\- fail, stack scanning may be able to recover a stack trace\&.
367.sp
368Note that stack scanning is an imprecise, heuristic mechanism that may give very misleading results, or none at all\&. It should be used only in emergencies, when normal unwinding fails, and it is important to nevertheless have stack traces\&.
369.sp
370Stack scanning is a simple technique: the unwinder reads words from the stack, and tries to guess which of them might be return addresses, by checking to see if they point just after ARM or Thumb call instructions\&. If so, the word is added to the backtrace\&.
371.sp
372The main danger occurs when a function call returns, leaving its return address exposed, and a new function is called, but the new function does not overwrite the old address\&. The result of this is that the backtrace may contain entries for functions which have already returned, and so be very confusing\&.
373.sp
374A second limitation of this implementation is that it will scan only the page (4KB, normally) containing the starting stack pointer\&. If the stack frames are large, this may result in only a few (or not even any) being present in the trace\&. Also, if you are unlucky and have an initial stack pointer near the end of its containing page, the scan may miss all interesting frames\&.
375.sp
376By default stack scanning is disabled\&. The normal use case is to ask for it when a stack trace would otherwise be very short\&. So, to enable it, use
377\-\-unw\-stack\-scan\-thresh=number\&. This requests Valgrind to try using stack scanning to "extend" stack traces which contain fewer than
378number
379frames\&.
380.sp
381If stack scanning does take place, it will only generate at most the number of frames specified by
382\-\-unw\-stack\-scan\-frames\&. Typically, stack scanning generates so many garbage entries that this value is set to a low value (5) by default\&. In no case will a stack trace larger than the value specified by
383\-\-num\-callers
384be created\&.
385.RE
386.PP
387\fB\-\-error\-limit=<yes|no> [default: yes] \fR
388.RS 4
389When 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\&.
390.RE
391.PP
392\fB\-\-error\-exitcode=<number> [default: 0] \fR
393.RS 4
394Specifies 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\&.
395.RE
396.PP
397\fB\-\-error\-markers=<begin>,<end> [default: none]\fR
398.RS 4
399When errors are output as plain text (i\&.e\&. XML not used),
400\fB\-\-error\-markers\fR
401instructs to output a line containing the
402\fBbegin\fR
403(\fBend\fR) string before (after) each error\&.
404.sp
405Such marker lines facilitate searching for errors and/or extracting errors in an output file that contain valgrind errors mixed with the program output\&.
406.sp
407Note that empty markers are accepted\&. So, only using a begin (or an end) marker is possible\&.
408.RE
409.PP
410\fB\-\-sigill\-diagnostics=<yes|no> [default: yes] \fR
411.RS 4
412Enable/disable printing of illegal instruction diagnostics\&. Enabled by default, but defaults to disabled when
413\fB\-\-quiet\fR
414is given\&. The default can always be explicitly overridden by giving this option\&.
415.sp
416When enabled, a warning message will be printed, along with some diagnostics, whenever an instruction is encountered that Valgrind cannot decode or translate, before the program is given a SIGILL signal\&. Often an illegal instruction indicates a bug in the program or missing support for the particular instruction in Valgrind\&. But some programs do deliberately try to execute an instruction that might be missing and trap the SIGILL signal to detect processor features\&. Using this flag makes it possible to avoid the diagnostic output that you would otherwise get in such cases\&.
417.RE
418.PP
419\fB\-\-show\-below\-main=<yes|no> [default: no] \fR
420.RS 4
421By default, stack traces for errors do not show any functions that appear beneath
422\fBmain\fR
423because most of the time it\*(Aqs uninteresting C library stuff and/or gobbledygook\&. Alternatively, if
424\fBmain\fR
425is not present in the stack trace, stack traces will not show any functions below
426\fBmain\fR\-like functions such as glibc\*(Aqs
427\fB__libc_start_main\fR\&. Furthermore, if
428\fBmain\fR\-like functions are present in the trace, they are normalised as
429\fB(below main)\fR, in order to make the output more deterministic\&.
430.sp
431If this option is enabled, all stack trace entries will be shown and
432\fBmain\fR\-like functions will not be normalised\&.
433.RE
434.PP
435\fB\-\-fullpath\-after=<string> [default: don\*(Aqt show source paths] \fR
436.RS 4
437By 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\&.
438\fB\-\-fullpath\-after\fR
439provides 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
440\fBstring\fR
441is found in the path, then the path up to and including
442\fBstring\fR
443is omitted, else the path is shown unmodified\&. Note that
444\fBstring\fR
445is not required to be a prefix of the path\&.
446.sp
447For example, consider a file named
448/home/janedoe/blah/src/foo/bar/xyzzy\&.c\&. Specifying
449\fB\-\-fullpath\-after=/home/janedoe/blah/src/\fR
450will cause Valgrind to show the name as
451foo/bar/xyzzy\&.c\&.
452.sp
453Because the string is not required to be a prefix,
454\fB\-\-fullpath\-after=src/\fR
455will produce the same output\&. This is useful when the path contains arbitrary machine\-generated characters\&. For example, the path
456/my/build/dir/C32A1B47/blah/src/foo/xyzzy
457can be pruned to
458foo/xyzzy
459using
460\fB\-\-fullpath\-after=/blah/src/\fR\&.
461.sp
462If you simply want to see the full path, just specify an empty string:
463\fB\-\-fullpath\-after=\fR\&. This isn\*(Aqt a special case, merely a logical consequence of the above rules\&.
464.sp
465Finally, you can use
466\fB\-\-fullpath\-after\fR
467multiple 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
468\fB\-\-fullpath\-after\fR\-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\&.
469.RE
470.PP
471\fB\-\-extra\-debuginfo\-path=<path> [default: undefined and unused] \fR
472.RS 4
473By default Valgrind searches in several well\-known paths for debug objects, such as
474/usr/lib/debug/\&.
475.sp
476However, there may be scenarios where you may wish to put debug objects at an arbitrary location, such as external storage when running Valgrind on a mobile device with limited local storage\&. Another example might be a situation where you do not have permission to install debug object packages on the system where you are running Valgrind\&.
477.sp
478In these scenarios, you may provide an absolute path as an extra, final place for Valgrind to search for debug objects by specifying
479\fB\-\-extra\-debuginfo\-path=/path/to/debug/objects\fR\&. The given path will be prepended to the absolute path name of the searched\-for object\&. For example, if Valgrind is looking for the debuginfo for
480/w/x/y/zz\&.so
481and
482\fB\-\-extra\-debuginfo\-path=/a/b/c\fR
483is specified, it will look for a debug object at
484/a/b/c/w/x/y/zz\&.so\&.
485.sp
486This flag should only be specified once\&. If it is specified multiple times, only the last instance is honoured\&.
487.RE
488.PP
489\fB\-\-debuginfo\-server=ipaddr:port [default: undefined and unused]\fR
490.RS 4
491This is a new, experimental, feature introduced in version 3\&.9\&.0\&.
492.sp
493In some scenarios it may be convenient to read debuginfo from objects stored on a different machine\&. With this flag, Valgrind will query a debuginfo server running on
494ipaddr
495and listening on port
496port, if it cannot find the debuginfo object in the local filesystem\&.
497.sp
498The debuginfo server must accept TCP connections on port
499port\&. The debuginfo server is contained in the source file
500auxprogs/valgrind\-di\-server\&.c\&. It will only serve from the directory it is started in\&.
501port
502defaults to 1500 in both client and server if not specified\&.
503.sp
504If Valgrind looks for the debuginfo for
505/w/x/y/zz\&.so
506by using the debuginfo server, it will strip the pathname components and merely request
507zz\&.so
508on the server\&. That in turn will look only in its current working directory for a matching debuginfo object\&.
509.sp
510The debuginfo data is transmitted in small fragments (8 KB) as requested by Valgrind\&. Each block is compressed using LZO to reduce transmission time\&. The implementation has been tuned for best performance over a single\-stage 802\&.11g (WiFi) network link\&.
511.sp
512Note that checks for matching primary vs debug objects, using GNU debuglink CRC scheme, are performed even when using the debuginfo server\&. To disable such checking, you need to also specify
513\-\-allow\-mismatched\-debuginfo=yes\&.
514.sp
515By default the Valgrind build system will build
516valgrind\-di\-server
517for the target platform, which is almost certainly not what you want\&. So far we have been unable to find out how to get automake/autoconf to build it for the build platform\&. If you want to use it, you will have to recompile it by hand using the command shown at the top of
518auxprogs/valgrind\-di\-server\&.c\&.
519.RE
520.PP
521\fB\-\-allow\-mismatched\-debuginfo=no|yes [no] \fR
522.RS 4
523When reading debuginfo from separate debuginfo objects, Valgrind will by default check that the main and debuginfo objects match, using the GNU debuglink mechanism\&. This guarantees that it does not read debuginfo from out of date debuginfo objects, and also ensures that Valgrind can\*(Aqt crash as a result of mismatches\&.
524.sp
525This check can be overridden using
526\-\-allow\-mismatched\-debuginfo=yes\&. This may be useful when the debuginfo and main objects have not been split in the proper way\&. Be careful when using this, though: it disables all consistency checking, and Valgrind has been observed to crash when the main and debuginfo objects don\*(Aqt match\&.
527.RE
528.PP
529\fB\-\-suppressions=<filename> [default: $PREFIX/lib/valgrind/default\&.supp] \fR
530.RS 4
531Specifies an extra file from which to read descriptions of errors to suppress\&. You may use up to 100 extra suppression files\&.
532.RE
533.PP
534\fB\-\-gen\-suppressions=<yes|no|all> [default: no] \fR
535.RS 4
536When set to
537\fIyes\fR, Valgrind will pause after every error shown and print the line:
538.sp
539.if n \{\
540.RS 4
541.\}
542.nf
543 \-\-\-\- Print suppression ? \-\-\- [Return/N/n/Y/y/C/c] \-\-\-\-
544.fi
545.if n \{\
546.RE
547.\}
548.sp
549Pressing
550\fIRet\fR, or
551\fIN Ret\fR
552or
553\fIn Ret\fR, causes Valgrind continue execution without printing a suppression for this error\&.
554.sp
555Pressing
556\fIY Ret\fR
557or
558\fIy Ret\fR
559causes Valgrind to write a suppression for this error\&. You can then cut and paste it into a suppression file if you don\*(Aqt want to hear about the error in the future\&.
560.sp
561When set to
562\fIall\fR, Valgrind will print a suppression for every reported error, without querying the user\&.
563.sp
564This option is particularly useful with C++ programs, as it prints out the suppressions with mangled names, as required\&.
565.sp
566Note that the suppressions printed are as specific as possible\&. You may want to common up similar ones, by adding wildcards to function names, and by using frame\-level wildcards\&. The wildcarding facilities are powerful yet flexible, and with a bit of careful editing, you may be able to suppress a whole family of related errors with only a few suppressions\&.
567.sp
568Sometimes two different errors are suppressed by the same suppression, in which case Valgrind will output the suppression more than once, but you only need to have one copy in your suppression file (but having more than one won\*(Aqt cause problems)\&. Also, the suppression name is given as
569<insert a suppression name here>; the name doesn\*(Aqt really matter, it\*(Aqs only used with the
570\fB\-v\fR
571option which prints out all used suppression records\&.
572.RE
573.PP
574\fB\-\-input\-fd=<number> [default: 0, stdin] \fR
575.RS 4
576When using
577\fB\-\-gen\-suppressions=yes\fR, Valgrind will stop so as to read keyboard input from you when each error occurs\&. By default it reads from the standard input (stdin), which is problematic for programs which close stdin\&. This option allows you to specify an alternative file descriptor from which to read input\&.
578.RE
579.PP
580\fB\-\-dsymutil=no|yes [yes] \fR
581.RS 4
582This option is only relevant when running Valgrind on Mac OS X\&.
583.sp
584Mac OS X uses a deferred debug information (debuginfo) linking scheme\&. When object files containing debuginfo are linked into a
585\&.dylib
586or an executable, the debuginfo is not copied into the final file\&. Instead, the debuginfo must be linked manually by running
587dsymutil, a system\-provided utility, on the executable or
588\&.dylib\&. The resulting combined debuginfo is placed in a directory alongside the executable or
589\&.dylib, but with the extension
590\&.dSYM\&.
591.sp
592With
593\fB\-\-dsymutil=no\fR, Valgrind will detect cases where the
594\&.dSYM
595directory is either missing, or is present but does not appear to match the associated executable or
596\&.dylib, most likely because it is out of date\&. In these cases, Valgrind will print a warning message but take no further action\&.
597.sp
598With
599\fB\-\-dsymutil=yes\fR, Valgrind will, in such cases, automatically run
600dsymutil
601as necessary to bring the debuginfo up to date\&. For all practical purposes, if you always use
602\fB\-\-dsymutil=yes\fR, then there is never any need to run
603dsymutil
604manually or as part of your applications\*(Aqs build system, since Valgrind will run it as necessary\&.
605.sp
606Valgrind will not attempt to run
607dsymutil
608on any executable or library in
609/usr/,
610/bin/,
611/sbin/,
612/opt/,
613/sw/,
614/System/,
615/Library/
616or
617/Applications/
618since
619dsymutil
620will always fail in such situations\&. It fails both because the debuginfo for such pre\-installed system components is not available anywhere, and also because it would require write privileges in those directories\&.
621.sp
622Be careful when using
623\fB\-\-dsymutil=yes\fR, since it will cause pre\-existing
624\&.dSYM
625directories to be silently deleted and re\-created\&. Also note that
626dsymutil
627is quite slow, sometimes excessively so\&.
628.RE
629.PP
630\fB\-\-max\-stackframe=<number> [default: 2000000] \fR
631.RS 4
632The maximum size of a stack frame\&. If the stack pointer moves by more than this amount then Valgrind will assume that the program is switching to a different stack\&.
633.sp
634You may need to use this option if your program has large stack\-allocated arrays\&. Valgrind keeps track of your program\*(Aqs stack pointer\&. If it changes by more than the threshold amount, Valgrind assumes your program is switching to a different stack, and Memcheck behaves differently than it would for a stack pointer change smaller than the threshold\&. Usually this heuristic works well\&. However, if your program allocates large structures on the stack, this heuristic will be fooled, and Memcheck will subsequently report large numbers of invalid stack accesses\&. This option allows you to change the threshold to a different value\&.
635.sp
636You should only consider use of this option if Valgrind\*(Aqs debug output directs you to do so\&. In that case it will tell you the new threshold you should specify\&.
637.sp
638In general, allocating large structures on the stack is a bad idea, because you can easily run out of stack space, especially on systems with limited memory or which expect to support large numbers of threads each with a small stack, and also because the error checking performed by Memcheck is more effective for heap\-allocated data than for stack\-allocated data\&. If you have to use this option, you may wish to consider rewriting your code to allocate on the heap rather than on the stack\&.
639.RE
640.PP
641\fB\-\-main\-stacksize=<number> [default: use current \*(Aqulimit\*(Aq value] \fR
642.RS 4
643Specifies the size of the main thread\*(Aqs stack\&.
644.sp
645To simplify its memory management, Valgrind reserves all required space for the main thread\*(Aqs stack at startup\&. That means it needs to know the required stack size at startup\&.
646.sp
647By default, Valgrind uses the current "ulimit" value for the stack size, or 16 MB, whichever is lower\&. In many cases this gives a stack size in the range 8 to 16 MB, which almost never overflows for most applications\&.
648.sp
649If you need a larger total stack size, use
650\fB\-\-main\-stacksize\fR
651to specify it\&. Only set it as high as you need, since reserving far more space than you need (that is, hundreds of megabytes more than you need) constrains Valgrind\*(Aqs memory allocators and may reduce the total amount of memory that Valgrind can use\&. This is only really of significance on 32\-bit machines\&.
652.sp
653On Linux, you may request a stack of size up to 2GB\&. Valgrind will stop with a diagnostic message if the stack cannot be allocated\&.
654.sp
655\fB\-\-main\-stacksize\fR
656only affects the stack size for the program\*(Aqs initial thread\&. It has no bearing on the size of thread stacks, as Valgrind does not allocate those\&.
657.sp
658You may need to use both
659\fB\-\-main\-stacksize\fR
660and
661\fB\-\-max\-stackframe\fR
662together\&. It is important to understand that
663\fB\-\-main\-stacksize\fR
664sets the maximum total stack size, whilst
665\fB\-\-max\-stackframe\fR
666specifies the largest size of any one stack frame\&. You will have to work out the
667\fB\-\-main\-stacksize\fR
668value for yourself (usually, if your applications segfaults)\&. But Valgrind will tell you the needed
669\fB\-\-max\-stackframe\fR
670size, if necessary\&.
671.sp
672As discussed further in the description of
673\fB\-\-max\-stackframe\fR, a requirement for a large stack is a sign of potential portability problems\&. You are best advised to place all large data in heap\-allocated memory\&.
674.RE
675.PP
676\fB\-\-max\-threads=<number> [default: 500] \fR
677.RS 4
678By default, Valgrind can handle to up to 500 threads\&. Occasionally, that number is too small\&. Use this option to provide a different limit\&. E\&.g\&.
679\-\-max\-threads=3000\&.
680.RE
Elliott Hughesed398002017-06-21 14:41:24 -0700681.SH "MALLOC()\-RELATED OPTIONS"
Elliott Hughesa0664b92017-04-18 17:46:52 -0700682.PP
683For tools that use their own version of
684malloc
685(e\&.g\&. Memcheck, Massif, Helgrind, DRD), the following options apply\&.
686.PP
687\fB\-\-alignment=<number> [default: 8 or 16, depending on the platform] \fR
688.RS 4
689By default Valgrind\*(Aqs
690\fBmalloc\fR,
691\fBrealloc\fR, etc, return a block whose starting address is 8\-byte aligned or 16\-byte aligned (the value depends on the platform and matches the platform default)\&. This option allows you to specify a different alignment\&. The supplied value must be greater than or equal to the default, less than or equal to 4096, and must be a power of two\&.
692.RE
693.PP
694\fB\-\-redzone\-size=<number> [default: depends on the tool] \fR
695.RS 4
696Valgrind\*(Aqs
697\fBmalloc, realloc,\fR
698etc, add padding blocks before and after each heap block allocated by the program being run\&. Such padding blocks are called redzones\&. The default value for the redzone size depends on the tool\&. For example, Memcheck adds and protects a minimum of 16 bytes before and after each block allocated by the client\&. This allows it to detect block underruns or overruns of up to 16 bytes\&.
699.sp
700Increasing the redzone size makes it possible to detect overruns of larger distances, but increases the amount of memory used by Valgrind\&. Decreasing the redzone size will reduce the memory needed by Valgrind but also reduces the chances of detecting over/underruns, so is not recommended\&.
701.RE
Elliott Hughesed398002017-06-21 14:41:24 -0700702.PP
703\fB\-\-xtree\-memory=none|allocs|full [none] \fR
704.RS 4
705Tools replacing Valgrind\*(Aqs
706\fBmalloc, realloc,\fR
707etc, can optionally produce an execution tree detailing which piece of code is responsible for heap memory usage\&. See
708???
709for a detailed explanation about execution trees\&.
710.sp
711When set to
712\fInone\fR, no memory execution tree is produced\&.
713.sp
714When set to
715\fIallocs\fR, the memory execution tree gives the current number of allocated bytes and the current number of allocated blocks\&.
716.sp
717When set to
718\fIfull\fR, the memory execution tree gives 6 different measurements : the current number of allocated bytes and blocks (same values as for
719\fIallocs\fR), the total number of allocated bytes and blocks, the total number of freed bytes and blocks\&.
720.sp
721Note that the overhead in cpu and memory to produce an xtree depends on the tool\&. The overhead in cpu is small for the value
722\fIallocs\fR, as the information needed to produce this report is maintained in any case by the tool\&. For massif and helgrind, specifying
723\fIfull\fR
724implies to capture a stack trace for each free operation, while normally these tools only capture an allocation stack trace\&. For memcheck, the cpu overhead for the value
725\fIfull\fR
726is small, as this can only be used in combination with
727\fB\-\-keep\-stacktraces=alloc\-and\-free\fR
728or
729\fB\-\-keep\-stacktraces=alloc\-then\-free\fR, which already records a stack trace for each free operation\&. The memory overhead varies between 5 and 10 words per unique stacktrace in the xtree, plus the memory needed to record the stack trace for the free operations, if needed specifically for the xtree\&.
730.RE
731.PP
732\fB\-\-xtree\-memory\-file=<filename> [default: xtmemory\&.kcg\&.%p] \fR
733.RS 4
734Specifies that Valgrind should produce the xtree memory report in the specified file\&. Any
735\fB%p\fR
736or
737\fB%q\fR
738sequences appearing in the filename are expanded in exactly the same way as they are for
739\fB\-\-log\-file\fR\&. See the description of
740--log-file
741for details\&.
742.sp
743If the filename contains the extension
744\fB\&.ms\fR, then the produced file format will be a massif output file format\&. If the filename contains the extension
745\fB\&.kcg\fR
746or no extension is provided or recognised, then the produced file format will be a callgrind output format\&.
747.sp
748See
749???
750for a detailed explanation about execution trees formats\&.
751.RE
Elliott Hughesa0664b92017-04-18 17:46:52 -0700752.SH "UNCOMMON OPTIONS"
753.PP
754These options apply to all tools, as they affect certain obscure workings of the Valgrind core\&. Most people won\*(Aqt need to use them\&.
755.PP
756\fB\-\-smc\-check=<none|stack|all|all\-non\-file> [default: all\-non\-file for x86/amd64/s390x, stack for other archs] \fR
757.RS 4
758This option controls Valgrind\*(Aqs detection of self\-modifying code\&. If no checking is done, when a program executes some code, then overwrites it with new code, and executes the new code, Valgrind will continue to execute the translations it made for the old code\&. This will likely lead to incorrect behaviour and/or crashes\&.
759.sp
760For "modern" architectures \-\- anything that\*(Aqs not x86, amd64 or s390x \-\- the default is
761\fIstack\fR\&. This is because a correct program must take explicit action to reestablish D\-I cache coherence following code modification\&. Valgrind observes and honours such actions, with the result that self\-modifying code is transparently handled with zero extra cost\&.
762.sp
763For x86, amd64 and s390x, the program is not required to notify the hardware of required D\-I coherence syncing\&. Hence the default is
764\fIall\-non\-file\fR, which covers the normal case of generating code into an anonymous (non\-file\-backed) mmap\*(Aqd area\&.
765.sp
766The meanings of the four available settings are as follows\&. No detection (\fInone\fR), detect self\-modifying code on the stack (which is used by GCC to implement nested functions) (\fIstack\fR), detect self\-modifying code everywhere (\fIall\fR), and detect self\-modifying code everywhere except in file\-backed mappings (\fIall\-non\-file\fR)\&.
767.sp
768Running with
769\fIall\fR
770will slow Valgrind down noticeably\&. Running with
771\fInone\fR
772will rarely speed things up, since very little code gets dynamically generated in most programs\&. The
773\fBVALGRIND_DISCARD_TRANSLATIONS\fR
774client request is an alternative to
775\fB\-\-smc\-check=all\fR
776and
777\fB\-\-smc\-check=all\-non\-file\fR
778that requires more programmer effort but allows Valgrind to run your program faster, by telling it precisely when translations need to be re\-made\&.
779.sp
780\fB\-\-smc\-check=all\-non\-file\fR
781provides a cheaper but more limited version of
782\fB\-\-smc\-check=all\fR\&. It adds checks to any translations that do not originate from file\-backed memory mappings\&. Typical applications that generate code, for example JITs in web browsers, generate code into anonymous mmaped areas, whereas the "fixed" code of the browser always lives in file\-backed mappings\&.
783\fB\-\-smc\-check=all\-non\-file\fR
784takes advantage of this observation, limiting the overhead of checking to code which is likely to be JIT generated\&.
785.RE
786.PP
787\fB\-\-read\-inline\-info=<yes|no> [default: see below] \fR
788.RS 4
789When enabled, Valgrind will read information about inlined function calls from DWARF3 debug info\&. This slows Valgrind startup and makes it use more memory (typically for each inlined piece of code, 6 words and space for the function name), but it results in more descriptive stacktraces\&. For the 3\&.10\&.0 release, this functionality is enabled by default only for Linux, Android and Solaris targets and only for the tools Memcheck, Helgrind and DRD\&. Here is an example of some stacktraces with
790\fB\-\-read\-inline\-info=no\fR:
791.sp
792.if n \{\
793.RS 4
794.\}
795.nf
796==15380== Conditional jump or move depends on uninitialised value(s)
797==15380== at 0x80484EA: main (inlinfo\&.c:6)
798==15380==
799==15380== Conditional jump or move depends on uninitialised value(s)
800==15380== at 0x8048550: fun_noninline (inlinfo\&.c:6)
801==15380== by 0x804850E: main (inlinfo\&.c:34)
802==15380==
803==15380== Conditional jump or move depends on uninitialised value(s)
804==15380== at 0x8048520: main (inlinfo\&.c:6)
805.fi
806.if n \{\
807.RE
808.\}
809.sp
810And here are the same errors with
811\fB\-\-read\-inline\-info=yes\fR:
812.sp
813.if n \{\
814.RS 4
815.\}
816.nf
817==15377== Conditional jump or move depends on uninitialised value(s)
818==15377== at 0x80484EA: fun_d (inlinfo\&.c:6)
819==15377== by 0x80484EA: fun_c (inlinfo\&.c:14)
820==15377== by 0x80484EA: fun_b (inlinfo\&.c:20)
821==15377== by 0x80484EA: fun_a (inlinfo\&.c:26)
822==15377== by 0x80484EA: main (inlinfo\&.c:33)
823==15377==
824==15377== Conditional jump or move depends on uninitialised value(s)
825==15377== at 0x8048550: fun_d (inlinfo\&.c:6)
826==15377== by 0x8048550: fun_noninline (inlinfo\&.c:41)
827==15377== by 0x804850E: main (inlinfo\&.c:34)
828==15377==
829==15377== Conditional jump or move depends on uninitialised value(s)
830==15377== at 0x8048520: fun_d (inlinfo\&.c:6)
831==15377== by 0x8048520: main (inlinfo\&.c:35)
832.fi
833.if n \{\
834.RE
835.\}
836.RE
837.PP
838\fB\-\-read\-var\-info=<yes|no> [default: no] \fR
839.RS 4
840When enabled, Valgrind will read information about variable types and locations from DWARF3 debug info\&. This slows Valgrind startup significantly and makes it use significantly more memory, but for the tools that can take advantage of it (Memcheck, Helgrind, DRD) it can result in more precise error messages\&. For example, here are some standard errors issued by Memcheck:
841.sp
842.if n \{\
843.RS 4
844.\}
845.nf
846==15363== Uninitialised byte(s) found during client check request
847==15363== at 0x80484A9: croak (varinfo1\&.c:28)
848==15363== by 0x8048544: main (varinfo1\&.c:55)
849==15363== Address 0x80497f7 is 7 bytes inside data symbol "global_i2"
850==15363==
851==15363== Uninitialised byte(s) found during client check request
852==15363== at 0x80484A9: croak (varinfo1\&.c:28)
853==15363== by 0x8048550: main (varinfo1\&.c:56)
854==15363== Address 0xbea0d0cc is on thread 1\*(Aqs stack
855==15363== in frame #1, created by main (varinfo1\&.c:45)
856.fi
857.if n \{\
858.RE
859.\}
860.sp
861And here are the same errors with
862\fB\-\-read\-var\-info=yes\fR:
863.sp
864.if n \{\
865.RS 4
866.\}
867.nf
868==15370== Uninitialised byte(s) found during client check request
869==15370== at 0x80484A9: croak (varinfo1\&.c:28)
870==15370== by 0x8048544: main (varinfo1\&.c:55)
871==15370== Location 0x80497f7 is 0 bytes inside global_i2[7],
872==15370== a global variable declared at varinfo1\&.c:41
873==15370==
874==15370== Uninitialised byte(s) found during client check request
875==15370== at 0x80484A9: croak (varinfo1\&.c:28)
876==15370== by 0x8048550: main (varinfo1\&.c:56)
877==15370== Location 0xbeb4a0cc is 0 bytes inside local var "local"
878==15370== declared at varinfo1\&.c:46, in frame #1 of thread 1
879.fi
880.if n \{\
881.RE
882.\}
883.RE
884.PP
885\fB\-\-vgdb\-poll=<number> [default: 5000] \fR
886.RS 4
887As part of its main loop, the Valgrind scheduler will poll to check if some activity (such as an external command or some input from a gdb) has to be handled by gdbserver\&. This activity poll will be done after having run the given number of basic blocks (or slightly more than the given number of basic blocks)\&. This poll is quite cheap so the default value is set relatively low\&. You might further decrease this value if vgdb cannot use ptrace system call to interrupt Valgrind if all threads are (most of the time) blocked in a system call\&.
888.RE
889.PP
890\fB\-\-vgdb\-shadow\-registers=no|yes [default: no] \fR
891.RS 4
892When activated, gdbserver will expose the Valgrind shadow registers to GDB\&. With this, the value of the Valgrind shadow registers can be examined or changed using GDB\&. Exposing shadow registers only works with GDB version 7\&.1 or later\&.
893.RE
894.PP
895\fB\-\-vgdb\-prefix=<prefix> [default: /tmp/vgdb\-pipe] \fR
896.RS 4
897To communicate with gdb/vgdb, the Valgrind gdbserver creates 3 files (2 named FIFOs and a mmap shared memory file)\&. The prefix option controls the directory and prefix for the creation of these files\&.
898.RE
899.PP
900\fB\-\-run\-libc\-freeres=<yes|no> [default: yes] \fR
901.RS 4
902This option is only relevant when running Valgrind on Linux\&.
903.sp
904The GNU C library (\fBlibc\&.so\fR), which is used by all programs, may allocate memory for its own uses\&. Usually it doesn\*(Aqt bother to free that memory when the program ends\(emthere would be no point, since the Linux kernel reclaims all process resources when a process exits anyway, so it would just slow things down\&.
905.sp
906The glibc authors realised that this behaviour causes leak checkers, such as Valgrind, to falsely report leaks in glibc, when a leak check is done at exit\&. In order to avoid this, they provided a routine called
907\fB__libc_freeres\fR
908specifically to make glibc release all memory it has allocated\&. Memcheck therefore tries to run
909\fB__libc_freeres\fR
910at exit\&.
911.sp
912Unfortunately, in some very old versions of glibc,
913\fB__libc_freeres\fR
914is sufficiently buggy to cause segmentation faults\&. This was particularly noticeable on Red Hat 7\&.1\&. So this option is provided in order to inhibit the run of
915\fB__libc_freeres\fR\&. If your program seems to run fine on Valgrind, but segfaults at exit, you may find that
916\fB\-\-run\-libc\-freeres=no\fR
917fixes that, although at the cost of possibly falsely reporting space leaks in
918libc\&.so\&.
919.RE
920.PP
921\fB\-\-run\-cxx\-freeres=<yes|no> [default: yes] \fR
922.RS 4
923This option is only relevant when running Valgrind on Linux or Solaris C++ programs\&.
924.sp
925The GNU Standard C++ library (\fBlibstdc++\&.so\fR), which is used by all C++ programs compiled with g++, may allocate memory for its own uses\&. Usually it doesn\*(Aqt bother to free that memory when the program ends\(emthere would be no point, since the kernel reclaims all process resources when a process exits anyway, so it would just slow things down\&.
926.sp
927The gcc authors realised that this behaviour causes leak checkers, such as Valgrind, to falsely report leaks in libstdc++, when a leak check is done at exit\&. In order to avoid this, they provided a routine called
928\fB__gnu_cxx::__freeres\fR
929specifically to make libstdc++ release all memory it has allocated\&. Memcheck therefore tries to run
930\fB__gnu_cxx::__freeres\fR
931at exit\&.
932.sp
933For the sake of flexibility and unforeseen problems with
934\fB__gnu_cxx::__freeres\fR, option
935\fB\-\-run\-cxx\-freeres=no\fR
936exists, although at the cost of possibly falsely reporting space leaks in
937libstdc++\&.so\&.
938.RE
939.PP
940\fB\-\-sim\-hints=hint1,hint2,\&.\&.\&. \fR
941.RS 4
942Pass miscellaneous hints to Valgrind which slightly modify the simulated behaviour in nonstandard or dangerous ways, possibly to help the simulation of strange features\&. By default no hints are enabled\&. Use with caution! Currently known hints are:
943.sp
944.RS 4
945.ie n \{\
946\h'-04'\(bu\h'+03'\c
947.\}
948.el \{\
949.sp -1
950.IP \(bu 2.3
951.\}
952\fBlax\-ioctls: \fR
953Be very lax about ioctl handling; the only assumption is that the size is correct\&. Doesn\*(Aqt require the full buffer to be initialised when writing\&. Without this, using some device drivers with a large number of strange ioctl commands becomes very tiresome\&.
954.RE
955.sp
956.RS 4
957.ie n \{\
958\h'-04'\(bu\h'+03'\c
959.\}
960.el \{\
961.sp -1
962.IP \(bu 2.3
963.\}
964\fBfuse\-compatible: \fR
965Enable special handling for certain system calls that may block in a FUSE file\-system\&. This may be necessary when running Valgrind on a multi\-threaded program that uses one thread to manage a FUSE file\-system and another thread to access that file\-system\&.
966.RE
967.sp
968.RS 4
969.ie n \{\
970\h'-04'\(bu\h'+03'\c
971.\}
972.el \{\
973.sp -1
974.IP \(bu 2.3
975.\}
976\fBenable\-outer: \fR
977Enable some special magic needed when the program being run is itself Valgrind\&.
978.RE
979.sp
980.RS 4
981.ie n \{\
982\h'-04'\(bu\h'+03'\c
983.\}
984.el \{\
985.sp -1
986.IP \(bu 2.3
987.\}
988\fBno\-inner\-prefix: \fR
989Disable printing a prefix
990\fB>\fR
991in front of each stdout or stderr output line in an inner Valgrind being run by an outer Valgrind\&. This is useful when running Valgrind regression tests in an outer/inner setup\&. Note that the prefix
992\fB>\fR
993will always be printed in front of the inner debug logging lines\&.
994.RE
995.sp
996.RS 4
997.ie n \{\
998\h'-04'\(bu\h'+03'\c
999.\}
1000.el \{\
1001.sp -1
1002.IP \(bu 2.3
1003.\}
1004\fBno\-nptl\-pthread\-stackcache: \fR
1005This hint is only relevant when running Valgrind on Linux\&.
1006.sp
1007The GNU glibc pthread library (\fBlibpthread\&.so\fR), which is used by pthread programs, maintains a cache of pthread stacks\&. When a pthread terminates, the memory used for the pthread stack and some thread local storage related data structure are not always directly released\&. This memory is kept in a cache (up to a certain size), and is re\-used if a new thread is started\&.
1008.sp
1009This cache causes the helgrind tool to report some false positive race condition errors on this cached memory, as helgrind does not understand the internal glibc cache synchronisation primitives\&. So, when using helgrind, disabling the cache helps to avoid false positive race conditions, in particular when using thread local storage variables (e\&.g\&. variables using the
1010\fB__thread\fR
1011qualifier)\&.
1012.sp
1013When using the memcheck tool, disabling the cache ensures the memory used by glibc to handle __thread variables is directly released when a thread terminates\&.
1014.sp
Elliott Hughesed398002017-06-21 14:41:24 -07001015Note: Valgrind disables the cache using some internal knowledge of the glibc stack cache implementation and by examining the debug information of the pthread library\&. This technique is thus somewhat fragile and might not work for all glibc versions\&. This has been successfully tested with various glibc versions (e\&.g\&. 2\&.11, 2\&.16, 2\&.18) on various platforms\&.
Elliott Hughesa0664b92017-04-18 17:46:52 -07001016.RE
1017.sp
1018.RS 4
1019.ie n \{\
1020\h'-04'\(bu\h'+03'\c
1021.\}
1022.el \{\
1023.sp -1
1024.IP \(bu 2.3
1025.\}
1026\fBlax\-doors: \fR
1027(Solaris only) Be very lax about door syscall handling over unrecognised door file descriptors\&. Does not require that full buffer is initialised when writing\&. Without this, programs using libdoor(3LIB) functionality with completely proprietary semantics may report large number of false positives\&.
1028.RE
Elliott Hughesed398002017-06-21 14:41:24 -07001029.sp
1030.RS 4
1031.ie n \{\
1032\h'-04'\(bu\h'+03'\c
1033.\}
1034.el \{\
1035.sp -1
1036.IP \(bu 2.3
1037.\}
1038\fBfallback\-llsc: \fR(MIPS and ARM64 only): Enables an alternative implementation of Load\-Linked (LL) and Store\-Conditional (SC) instructions\&. The standard implementation gives more correct behaviour, but can cause indefinite looping on certain processor implementations that are intolerant of extra memory references between LL and SC\&. So far this is known only to happen on Cavium 3 cores\&. You should not need to use this flag, since the relevant cores are detected at startup and the alternative implementation is automatically enabled if necessary\&. There is no equivalent anti\-flag: you cannot force\-disable the alternative implementation, if it is automatically enabled\&. The underlying problem exists because the "standard" implementation of LL and SC is done by copying through LL and SC instructions into the instrumented code\&. However, tools may insert extra instrumentation memory references in between the LL and SC instructions\&. These memory references are not present in the original uninstrumented code, and their presence in the instrumented code can cause the SC instructions to persistently fail, leading to indefinite looping in LL\-SC blocks\&. The alternative implementation gives correct behaviour of LL and SC instructions between threads in a process, up to and including the ABA scenario\&. It also gives correct behaviour between a Valgrinded thread and a non\-Valgrinded thread running in a different process, that communicate via shared memory, but only up to and including correct CAS behaviour \-\- in this case the ABA scenario may not be correctly handled\&.
1039.RE
Elliott Hughesa0664b92017-04-18 17:46:52 -07001040.RE
1041.PP
1042\fB\-\-fair\-sched=<no|yes|try> [default: no] \fR
1043.RS 4
1044The
1045\fB\-\-fair\-sched\fR
1046option controls the locking mechanism used by Valgrind to serialise thread execution\&. The locking mechanism controls the way the threads are scheduled, and different settings give different trade\-offs between fairness and performance\&. For more details about the Valgrind thread serialisation scheme and its impact on performance and thread scheduling, see
1047Scheduling and Multi-Thread Performance\&.
1048.sp
1049.RS 4
1050.ie n \{\
1051\h'-04'\(bu\h'+03'\c
1052.\}
1053.el \{\
1054.sp -1
1055.IP \(bu 2.3
1056.\}
1057The value
1058\fB\-\-fair\-sched=yes\fR
1059activates a fair scheduler\&. In short, if multiple threads are ready to run, the threads will be scheduled in a round robin fashion\&. This mechanism is not available on all platforms or Linux versions\&. If not available, using
1060\fB\-\-fair\-sched=yes\fR
1061will cause Valgrind to terminate with an error\&.
1062.sp
1063You may find this setting improves overall responsiveness if you are running an interactive multithreaded program, for example a web browser, on Valgrind\&.
1064.RE
1065.sp
1066.RS 4
1067.ie n \{\
1068\h'-04'\(bu\h'+03'\c
1069.\}
1070.el \{\
1071.sp -1
1072.IP \(bu 2.3
1073.\}
1074The value
1075\fB\-\-fair\-sched=try\fR
1076activates fair scheduling if available on the platform\&. Otherwise, it will automatically fall back to
1077\fB\-\-fair\-sched=no\fR\&.
1078.RE
1079.sp
1080.RS 4
1081.ie n \{\
1082\h'-04'\(bu\h'+03'\c
1083.\}
1084.el \{\
1085.sp -1
1086.IP \(bu 2.3
1087.\}
1088The value
1089\fB\-\-fair\-sched=no\fR
1090activates a scheduler which does not guarantee fairness between threads ready to run, but which in general gives the highest performance\&.
1091.RE
1092.RE
1093.PP
1094\fB\-\-kernel\-variant=variant1,variant2,\&.\&.\&.\fR
1095.RS 4
1096Handle system calls and ioctls arising from minor variants of the default kernel for this platform\&. This is useful for running on hacked kernels or with kernel modules which support nonstandard ioctls, for example\&. Use with caution\&. If you don\*(Aqt understand what this option does then you almost certainly don\*(Aqt need it\&. Currently known variants are:
1097.sp
1098.RS 4
1099.ie n \{\
1100\h'-04'\(bu\h'+03'\c
1101.\}
1102.el \{\
1103.sp -1
1104.IP \(bu 2.3
1105.\}
1106\fBbproc\fR: support the
1107\fBsys_broc\fR
1108system call on x86\&. This is for running on BProc, which is a minor variant of standard Linux which is sometimes used for building clusters\&.
1109.RE
1110.sp
1111.RS 4
1112.ie n \{\
1113\h'-04'\(bu\h'+03'\c
1114.\}
1115.el \{\
1116.sp -1
1117.IP \(bu 2.3
1118.\}
1119\fBandroid\-no\-hw\-tls\fR: some versions of the Android emulator for ARM do not provide a hardware TLS (thread\-local state) register, and Valgrind crashes at startup\&. Use this variant to select software support for TLS\&.
1120.RE
1121.sp
1122.RS 4
1123.ie n \{\
1124\h'-04'\(bu\h'+03'\c
1125.\}
1126.el \{\
1127.sp -1
1128.IP \(bu 2.3
1129.\}
1130\fBandroid\-gpu\-sgx5xx\fR: use this to support handling of proprietary ioctls for the PowerVR SGX 5XX series of GPUs on Android devices\&. Failure to select this does not cause stability problems, but may cause Memcheck to report false errors after the program performs GPU\-specific ioctls\&.
1131.RE
1132.sp
1133.RS 4
1134.ie n \{\
1135\h'-04'\(bu\h'+03'\c
1136.\}
1137.el \{\
1138.sp -1
1139.IP \(bu 2.3
1140.\}
1141\fBandroid\-gpu\-adreno3xx\fR: similarly, use this to support handling of proprietary ioctls for the Qualcomm Adreno 3XX series of GPUs on Android devices\&.
1142.RE
1143.RE
1144.PP
1145\fB\-\-merge\-recursive\-frames=<number> [default: 0] \fR
1146.RS 4
1147Some recursive algorithms, for example balanced binary tree implementations, create many different stack traces, each containing cycles of calls\&. A cycle is defined as two identical program counter values separated by zero or more other program counter values\&. Valgrind may then use a lot of memory to store all these stack traces\&. This is a poor use of memory considering that such stack traces contain repeated uninteresting recursive calls instead of more interesting information such as the function that has initiated the recursive call\&.
1148.sp
1149The option
1150\fB\-\-merge\-recursive\-frames=<number>\fR
1151instructs Valgrind to detect and merge recursive call cycles having a size of up to
1152\fB<number>\fR
1153frames\&. When such a cycle is detected, Valgrind records the cycle in the stack trace as a unique program counter\&.
1154.sp
1155The value 0 (the default) causes no recursive call merging\&. A value of 1 will cause stack traces of simple recursive algorithms (for example, a factorial implementation) to be collapsed\&. A value of 2 will usually be needed to collapse stack traces produced by recursive algorithms such as binary trees, quick sort, etc\&. Higher values might be needed for more complex recursive algorithms\&.
1156.sp
1157Note: recursive calls are detected by analysis of program counter values\&. They are not detected by looking at function names\&.
1158.RE
1159.PP
1160\fB\-\-num\-transtab\-sectors=<number> [default: 6 for Android platforms, 16 for all others] \fR
1161.RS 4
1162Valgrind translates and instruments your program\*(Aqs machine code in small fragments (basic blocks)\&. The translations are stored in a translation cache that is divided into a number of sections (sectors)\&. If the cache is full, the sector containing the oldest translations is emptied and reused\&. If these old translations are needed again, Valgrind must re\-translate and re\-instrument the corresponding machine code, which is expensive\&. If the "executed instructions" working set of a program is big, increasing the number of sectors may improve performance by reducing the number of re\-translations needed\&. Sectors are allocated on demand\&. Once allocated, a sector can never be freed, and occupies considerable space, depending on the tool and the value of
1163\fB\-\-avg\-transtab\-entry\-size\fR
1164(about 40 MB per sector for Memcheck)\&. Use the option
1165\fB\-\-stats=yes\fR
1166to obtain precise information about the memory used by a sector and the allocation and recycling of sectors\&.
1167.RE
1168.PP
1169\fB\-\-avg\-transtab\-entry\-size=<number> [default: 0, meaning use tool provided default] \fR
1170.RS 4
1171Average size of translated basic block\&. This average size is used to dimension the size of a sector\&. Each tool provides a default value to be used\&. If this default value is too small, the translation sectors will become full too quickly\&. If this default value is too big, a significant part of the translation sector memory will be unused\&. Note that the average size of a basic block translation depends on the tool, and might depend on tool options\&. For example, the memcheck option
1172\fB\-\-track\-origins=yes\fR
1173increases the size of the basic block translations\&. Use
1174\fB\-\-avg\-transtab\-entry\-size\fR
1175to tune the size of the sectors, either to gain memory or to avoid too many retranslations\&.
1176.RE
1177.PP
1178\fB\-\-aspace\-minaddr=<address> [default: depends on the platform] \fR
1179.RS 4
1180To avoid potential conflicts with some system libraries, Valgrind does not use the address space below
1181\fB\-\-aspace\-minaddr\fR
1182value, keeping it reserved in case a library specifically requests memory in this region\&. So, some "pessimistic" value is guessed by Valgrind depending on the platform\&. On linux, by default, Valgrind avoids using the first 64MB even if typically there is no conflict in this complete zone\&. You can use the option
1183\fB\-\-aspace\-minaddr\fR
1184to have your memory hungry application benefitting from more of this lower memory\&. On the other hand, if you encounter a conflict, increasing aspace\-minaddr value might solve it\&. Conflicts will typically manifest themselves with mmap failures in the low range of the address space\&. The provided
1185address
1186must be page aligned and must be equal or bigger to 0x1000 (4KB)\&. To find the default value on your platform, do something such as
1187valgrind \-d \-d date 2>&1 | grep \-i minaddr\&. Values lower than 0x10000 (64KB) are known to create problems on some distributions\&.
1188.RE
1189.PP
1190\fB\-\-valgrind\-stacksize=<number> [default: 1MB] \fR
1191.RS 4
1192For each thread, Valgrind needs its own \*(Aqprivate\*(Aq stack\&. The default size for these stacks is largely dimensioned, and so should be sufficient in most cases\&. In case the size is too small, Valgrind will segfault\&. Before segfaulting, a warning might be produced by Valgrind when approaching the limit\&.
1193.sp
1194Use the option
1195\fB\-\-valgrind\-stacksize\fR
1196if such an (unlikely) warning is produced, or Valgrind dies due to a segmentation violation\&. Such segmentation violations have been seen when demangling huge C++ symbols\&.
1197.sp
1198If your application uses many threads and needs a lot of memory, you can gain some memory by reducing the size of these Valgrind stacks using the option
1199\fB\-\-valgrind\-stacksize\fR\&.
1200.RE
1201.PP
1202\fB\-\-show\-emwarns=<yes|no> [default: no] \fR
1203.RS 4
1204When enabled, Valgrind will emit warnings about its CPU emulation in certain cases\&. These are usually not interesting\&.
1205.RE
1206.PP
1207\fB\-\-require\-text\-symbol=:sonamepatt:fnnamepatt\fR
1208.RS 4
1209When a shared object whose soname matches
1210\fIsonamepatt\fR
1211is loaded into the process, examine all the text symbols it exports\&. If none of those match
1212\fIfnnamepatt\fR, print an error message and abandon the run\&. This makes it possible to ensure that the run does not continue unless a given shared object contains a particular function name\&.
1213.sp
1214Both
1215\fIsonamepatt\fR
1216and
1217\fIfnnamepatt\fR
1218can be written using the usual
1219\fI?\fR
1220and
1221\fI*\fR
1222wildcards\&. For example:
1223\fI":*libc\&.so*:foo?bar"\fR\&. You may use characters other than a colon to separate the two patterns\&. It is only important that the first character and the separator character are the same\&. For example, the above example could also be written
1224\fI"Q*libc\&.so*Qfoo?bar"\fR\&. Multiple
1225\fI \-\-require\-text\-symbol\fR
1226flags are allowed, in which case shared objects that are loaded into the process will be checked against all of them\&.
1227.sp
1228The purpose of this is to support reliable usage of marked\-up libraries\&. For example, suppose we have a version of GCC\*(Aqs
1229\fIlibgomp\&.so\fR
1230which has been marked up with annotations to support Helgrind\&. It is only too easy and confusing to load the wrong, un\-annotated
1231\fIlibgomp\&.so\fR
1232into the application\&. So the idea is: add a text symbol in the marked\-up library, for example
1233\fIannotated_for_helgrind_3_6\fR, and then give the flag
1234\fI\-\-require\-text\-symbol=:*libgomp*so*:annotated_for_helgrind_3_6\fR
1235so that when
1236\fIlibgomp\&.so\fR
1237is loaded, Valgrind scans its symbol table, and if the symbol isn\*(Aqt present the run is aborted, rather than continuing silently with the un\-marked\-up library\&. Note that you should put the entire flag in quotes to stop shells expanding up the
1238\fI*\fR
1239and
1240\fI?\fR
1241wildcards\&.
1242.RE
1243.PP
1244\fB\-\-soname\-synonyms=syn1=pattern1,syn2=pattern2,\&.\&.\&.\fR
1245.RS 4
1246When a shared library is loaded, Valgrind checks for functions in the library that must be replaced or wrapped\&. For example, Memcheck replaces some string and memory functions (strchr, strlen, strcpy, memchr, memcpy, memmove, etc\&.) with its own versions\&. Such replacements are normally done only in shared libraries whose soname matches a predefined soname pattern (e\&.g\&.
1247\fIlibc\&.so*\fR
1248on linux)\&. By default, no replacement is done for a statically linked binary or for alternative libraries, except for the allocation functions (malloc, free, calloc, memalign, realloc, operator new, operator delete, etc\&.) Such allocation functions are intercepted by default in any shared library or in the executable if they are exported as global symbols\&. This means that if a replacement allocation library such as tcmalloc is found, its functions are also intercepted by default\&. In some cases, the replacements allow
1249\fB\-\-soname\-synonyms\fR
1250to specify one additional synonym pattern, giving flexibility in the replacement\&. Or to prevent interception of all public allocation symbols\&.
1251.sp
1252Currently, this flexibility is only allowed for the malloc related functions, using the synonym
1253\fIsomalloc\fR\&. This synonym is usable for all tools doing standard replacement of malloc related functions (e\&.g\&. memcheck, massif, drd, helgrind, exp\-dhat, exp\-sgcheck)\&.
1254.sp
1255.RS 4
1256.ie n \{\
1257\h'-04'\(bu\h'+03'\c
1258.\}
1259.el \{\
1260.sp -1
1261.IP \(bu 2.3
1262.\}
1263Alternate malloc library: to replace the malloc related functions in a specific alternate library with soname
1264\fImymalloclib\&.so\fR
1265(and not in any others), give the option
1266\fB\-\-soname\-synonyms=somalloc=mymalloclib\&.so\fR\&. A pattern can be used to match multiple libraries sonames\&. For example,
1267\fB\-\-soname\-synonyms=somalloc=*tcmalloc*\fR
1268will match the soname of all variants of the tcmalloc library (native, debug, profiled, \&.\&.\&. tcmalloc variants)\&.
1269.sp
1270Note: the soname of a elf shared library can be retrieved using the readelf utility\&.
1271.RE
1272.sp
1273.RS 4
1274.ie n \{\
1275\h'-04'\(bu\h'+03'\c
1276.\}
1277.el \{\
1278.sp -1
1279.IP \(bu 2.3
1280.\}
1281Replacements in a statically linked library are done by using the
1282\fINONE\fR
1283pattern\&. For example, if you link with
1284\fIlibtcmalloc\&.a\fR, and only want to intercept the malloc related functions in the executable (and standard libraries) themselves, but not any other shared libraries, you can give the option
1285\fB\-\-soname\-synonyms=somalloc=NONE\fR\&. Note that a NONE pattern will match the main executable and any shared library having no soname\&.
1286.RE
1287.sp
1288.RS 4
1289.ie n \{\
1290\h'-04'\(bu\h'+03'\c
1291.\}
1292.el \{\
1293.sp -1
1294.IP \(bu 2.3
1295.\}
1296To run a "default" Firefox build for Linux, in which JEMalloc is linked in to the main executable, use
1297\fB\-\-soname\-synonyms=somalloc=NONE\fR\&.
1298.RE
1299.sp
1300.RS 4
1301.ie n \{\
1302\h'-04'\(bu\h'+03'\c
1303.\}
1304.el \{\
1305.sp -1
1306.IP \(bu 2.3
1307.\}
1308To only intercept allocation symbols in the default system libraries, but not in any other shared library or the executable defining public malloc or operator new related functions use a non\-existing library name like
1309\fB\-\-soname\-synonyms=somalloc=nouserintercepts\fR
1310(where
1311\fInouserintercepts\fR
1312can be any non\-existing library name)\&.
1313.RE
1314.sp
1315.RS 4
1316.ie n \{\
1317\h'-04'\(bu\h'+03'\c
1318.\}
1319.el \{\
1320.sp -1
1321.IP \(bu 2.3
1322.\}
1323Shared library of the dynamic (runtime) linker is excluded from searching for global public symbols, such as those for the malloc related functions (identified by
1324\fIsomalloc\fR
1325synonym)\&.
1326.RE
1327.RE
1328.SH "DEBUGGING VALGRIND OPTIONS"
1329.PP
1330There are also some options for debugging Valgrind itself\&. You shouldn\*(Aqt need to use them in the normal run of things\&. If you wish to see the list, use the
1331\fB\-\-help\-debug\fR
1332option\&.
1333.SH "MEMCHECK OPTIONS"
1334.PP
1335\fB\-\-leak\-check=<no|summary|yes|full> [default: summary] \fR
1336.RS 4
1337When enabled, search for memory leaks when the client program finishes\&. If set to
1338\fIsummary\fR, it says how many leaks occurred\&. If set to
1339\fIfull\fR
1340or
1341\fIyes\fR, each individual leak will be shown in detail and/or counted as an error, as specified by the options
1342\fB\-\-show\-leak\-kinds\fR
1343and
1344\fB\-\-errors\-for\-leak\-kinds\fR\&.
1345.RE
1346.PP
1347\fB\-\-leak\-resolution=<low|med|high> [default: high] \fR
1348.RS 4
1349When doing leak checking, determines how willing Memcheck is to consider different backtraces to be the same for the purposes of merging multiple leaks into a single leak report\&. When set to
1350\fIlow\fR, only the first two entries need match\&. When
1351\fImed\fR, four entries have to match\&. When
1352\fIhigh\fR, all entries need to match\&.
1353.sp
1354For hardcore leak debugging, you probably want to use
1355\fB\-\-leak\-resolution=high\fR
1356together with
1357\fB\-\-num\-callers=40\fR
1358or some such large number\&.
1359.sp
1360Note that the
1361\fB\-\-leak\-resolution\fR
1362setting does not affect Memcheck\*(Aqs ability to find leaks\&. It only changes how the results are presented\&.
1363.RE
1364.PP
1365\fB\-\-show\-leak\-kinds=<set> [default: definite,possible] \fR
1366.RS 4
1367Specifies the leak kinds to show in a
1368\fIfull\fR
1369leak search, in one of the following ways:
1370.sp
1371.RS 4
1372.ie n \{\
1373\h'-04'\(bu\h'+03'\c
1374.\}
1375.el \{\
1376.sp -1
1377.IP \(bu 2.3
1378.\}
1379a comma separated list of one or more of
1380\fBdefinite indirect possible reachable\fR\&.
1381.RE
1382.sp
1383.RS 4
1384.ie n \{\
1385\h'-04'\(bu\h'+03'\c
1386.\}
1387.el \{\
1388.sp -1
1389.IP \(bu 2.3
1390.\}
1391\fBall\fR
1392to specify the complete set (all leak kinds)\&. It is equivalent to
1393\fB\-\-show\-leak\-kinds=definite,indirect,possible,reachable\fR\&.
1394.RE
1395.sp
1396.RS 4
1397.ie n \{\
1398\h'-04'\(bu\h'+03'\c
1399.\}
1400.el \{\
1401.sp -1
1402.IP \(bu 2.3
1403.\}
1404\fBnone\fR
1405for the empty set\&.
1406.RE
1407.RE
1408.PP
1409\fB\-\-errors\-for\-leak\-kinds=<set> [default: definite,possible] \fR
1410.RS 4
1411Specifies the leak kinds to count as errors in a
1412\fIfull\fR
1413leak search\&. The
1414\fB<set>\fR
1415is specified similarly to
1416\fB\-\-show\-leak\-kinds\fR
1417.RE
1418.PP
1419\fB\-\-leak\-check\-heuristics=<set> [default: all] \fR
1420.RS 4
1421Specifies the set of leak check heuristics to be used during leak searches\&. The heuristics control which interior pointers to a block cause it to be considered as reachable\&. The heuristic set is specified in one of the following ways:
1422.sp
1423.RS 4
1424.ie n \{\
1425\h'-04'\(bu\h'+03'\c
1426.\}
1427.el \{\
1428.sp -1
1429.IP \(bu 2.3
1430.\}
1431a comma separated list of one or more of
1432\fBstdstring length64 newarray multipleinheritance\fR\&.
1433.RE
1434.sp
1435.RS 4
1436.ie n \{\
1437\h'-04'\(bu\h'+03'\c
1438.\}
1439.el \{\
1440.sp -1
1441.IP \(bu 2.3
1442.\}
1443\fBall\fR
1444to activate the complete set of heuristics\&. It is equivalent to
1445\fB\-\-leak\-check\-heuristics=stdstring,length64,newarray,multipleinheritance\fR\&.
1446.RE
1447.sp
1448.RS 4
1449.ie n \{\
1450\h'-04'\(bu\h'+03'\c
1451.\}
1452.el \{\
1453.sp -1
1454.IP \(bu 2.3
1455.\}
1456\fBnone\fR
1457for the empty set\&.
1458.RE
1459.PP
1460Note that these heuristics are dependent on the layout of the objects produced by the C++ compiler\&. They have been tested with some gcc versions (e\&.g\&. 4\&.4 and 4\&.7)\&. They might not work properly with other C++ compilers\&.
1461.RE
1462.PP
1463\fB\-\-show\-reachable=<yes|no> \fR, \fB\-\-show\-possibly\-lost=<yes|no> \fR
1464.RS 4
1465These options provide an alternative way to specify the leak kinds to show:
1466.sp
1467.RS 4
1468.ie n \{\
1469\h'-04'\(bu\h'+03'\c
1470.\}
1471.el \{\
1472.sp -1
1473.IP \(bu 2.3
1474.\}
1475\fB\-\-show\-reachable=no \-\-show\-possibly\-lost=yes\fR
1476is equivalent to
1477\fB\-\-show\-leak\-kinds=definite,possible\fR\&.
1478.RE
1479.sp
1480.RS 4
1481.ie n \{\
1482\h'-04'\(bu\h'+03'\c
1483.\}
1484.el \{\
1485.sp -1
1486.IP \(bu 2.3
1487.\}
1488\fB\-\-show\-reachable=no \-\-show\-possibly\-lost=no\fR
1489is equivalent to
1490\fB\-\-show\-leak\-kinds=definite\fR\&.
1491.RE
1492.sp
1493.RS 4
1494.ie n \{\
1495\h'-04'\(bu\h'+03'\c
1496.\}
1497.el \{\
1498.sp -1
1499.IP \(bu 2.3
1500.\}
1501\fB\-\-show\-reachable=yes\fR
1502is equivalent to
1503\fB\-\-show\-leak\-kinds=all\fR\&.
1504.RE
1505.PP
1506Note that
1507\fB\-\-show\-possibly\-lost=no\fR
1508has no effect if
1509\fB\-\-show\-reachable=yes\fR
1510is specified\&.
1511.RE
1512.PP
Elliott Hughesed398002017-06-21 14:41:24 -07001513\fB\-\-xtree\-leak=<no|yes> [no] \fR
1514.RS 4
1515If set to yes, the results for the leak search done at exit will be output in a \*(AqCallgrind Format\*(Aq execution tree file\&. Note that this automatically sets the option
1516\fB\-\-leak\-check=full\fR\&. The produced file will contain the following events:
1517.sp
1518.RS 4
1519.ie n \{\
1520\h'-04'\(bu\h'+03'\c
1521.\}
1522.el \{\
1523.sp -1
1524.IP \(bu 2.3
1525.\}
1526\fBRB\fR
1527: Reachable Bytes
1528.RE
1529.sp
1530.RS 4
1531.ie n \{\
1532\h'-04'\(bu\h'+03'\c
1533.\}
1534.el \{\
1535.sp -1
1536.IP \(bu 2.3
1537.\}
1538\fBPB\fR
1539: Possibly lost Bytes
1540.RE
1541.sp
1542.RS 4
1543.ie n \{\
1544\h'-04'\(bu\h'+03'\c
1545.\}
1546.el \{\
1547.sp -1
1548.IP \(bu 2.3
1549.\}
1550\fBIB\fR
1551: Indirectly lost Bytes
1552.RE
1553.sp
1554.RS 4
1555.ie n \{\
1556\h'-04'\(bu\h'+03'\c
1557.\}
1558.el \{\
1559.sp -1
1560.IP \(bu 2.3
1561.\}
1562\fBDB\fR
1563: Definitely lost Bytes (direct plus indirect)
1564.RE
1565.sp
1566.RS 4
1567.ie n \{\
1568\h'-04'\(bu\h'+03'\c
1569.\}
1570.el \{\
1571.sp -1
1572.IP \(bu 2.3
1573.\}
1574\fBDIB\fR
1575: Definitely Indirectly lost Bytes (subset of DB)
1576.RE
1577.sp
1578.RS 4
1579.ie n \{\
1580\h'-04'\(bu\h'+03'\c
1581.\}
1582.el \{\
1583.sp -1
1584.IP \(bu 2.3
1585.\}
1586\fBRBk\fR
1587: reachable Blocks
1588.RE
1589.sp
1590.RS 4
1591.ie n \{\
1592\h'-04'\(bu\h'+03'\c
1593.\}
1594.el \{\
1595.sp -1
1596.IP \(bu 2.3
1597.\}
1598\fBPBk\fR
1599: Possibly lost Blocks
1600.RE
1601.sp
1602.RS 4
1603.ie n \{\
1604\h'-04'\(bu\h'+03'\c
1605.\}
1606.el \{\
1607.sp -1
1608.IP \(bu 2.3
1609.\}
1610\fBIBk\fR
1611: Indirectly lost Blocks
1612.RE
1613.sp
1614.RS 4
1615.ie n \{\
1616\h'-04'\(bu\h'+03'\c
1617.\}
1618.el \{\
1619.sp -1
1620.IP \(bu 2.3
1621.\}
1622\fBDBk\fR
1623: Definitely lost Blocks
1624.RE
1625.sp
1626The increase or decrease for all events above will also be output in the file to provide the delta (increase or decreaseà between 2 successive leak searches\&. For example,
1627\fBiRB\fR
1628is the increase of the
1629\fBRB\fR
1630event,
1631\fBdPBk\fR
1632is the decrease of
1633\fBPBk\fR
1634event\&. The values for the increase and decrease events will be zero for the first leak search done\&.
1635.sp
1636See
1637???
1638for a detailed explanation about execution trees\&.
1639.RE
1640.PP
1641\fB\-\-xtree\-leak\-file=<filename> [default: xtleak\&.kcg\&.%p] \fR
1642.RS 4
1643Specifies that Valgrind should produce the xtree leak report in the specified file\&. Any
1644\fB%p\fR,
1645\fB%q\fR
1646or
1647\fB%n\fR
1648sequences appearing in the filename are expanded in exactly the same way as they are for
1649\fB\-\-log\-file\fR\&. See the description of
1650--log-file
1651for details\&.
1652.sp
1653See
1654???
1655for a detailed explanation about execution trees formats\&.
1656.RE
1657.PP
Elliott Hughesa0664b92017-04-18 17:46:52 -07001658\fB\-\-undef\-value\-errors=<yes|no> [default: yes] \fR
1659.RS 4
1660Controls whether Memcheck reports uses of undefined value errors\&. Set this to
1661\fIno\fR
1662if you don\*(Aqt want to see undefined value errors\&. It also has the side effect of speeding up Memcheck somewhat\&.
1663.RE
1664.PP
1665\fB\-\-track\-origins=<yes|no> [default: no] \fR
1666.RS 4
1667Controls whether Memcheck tracks the origin of uninitialised values\&. By default, it does not, which means that although it can tell you that an uninitialised value is being used in a dangerous way, it cannot tell you where the uninitialised value came from\&. This often makes it difficult to track down the root problem\&.
1668.sp
1669When set to
1670\fIyes\fR, Memcheck keeps track of the origins of all uninitialised values\&. Then, when an uninitialised value error is reported, Memcheck will try to show the origin of the value\&. An origin can be one of the following four places: a heap block, a stack allocation, a client request, or miscellaneous other sources (eg, a call to
1671\fIbrk\fR)\&.
1672.sp
1673For uninitialised values originating from a heap block, Memcheck shows where the block was allocated\&. For uninitialised values originating from a stack allocation, Memcheck can tell you which function allocated the value, but no more than that \-\- typically it shows you the source location of the opening brace of the function\&. So you should carefully check that all of the function\*(Aqs local variables are initialised properly\&.
1674.sp
1675Performance overhead: origin tracking is expensive\&. It halves Memcheck\*(Aqs speed and increases memory use by a minimum of 100MB, and possibly more\&. Nevertheless it can drastically reduce the effort required to identify the root cause of uninitialised value errors, and so is often a programmer productivity win, despite running more slowly\&.
1676.sp
1677Accuracy: Memcheck tracks origins quite accurately\&. To avoid very large space and time overheads, some approximations are made\&. It is possible, although unlikely, that Memcheck will report an incorrect origin, or not be able to identify any origin\&.
1678.sp
1679Note that the combination
1680\fB\-\-track\-origins=yes\fR
1681and
1682\fB\-\-undef\-value\-errors=no\fR
1683is nonsensical\&. Memcheck checks for and rejects this combination at startup\&.
1684.RE
1685.PP
1686\fB\-\-partial\-loads\-ok=<yes|no> [default: yes] \fR
1687.RS 4
1688Controls how Memcheck handles 32\-, 64\-, 128\- and 256\-bit naturally aligned loads from addresses for which some bytes are addressable and others are not\&. When
1689\fIyes\fR, such loads do not produce an address error\&. Instead, loaded bytes originating from illegal addresses are marked as uninitialised, and those corresponding to legal addresses are handled in the normal way\&.
1690.sp
1691When
1692\fIno\fR, loads from partially invalid addresses are treated the same as loads from completely invalid addresses: an illegal\-address error is issued, and the resulting bytes are marked as initialised\&.
1693.sp
1694Note that code that behaves in this way is in violation of the ISO C/C++ standards, and should be considered broken\&. If at all possible, such code should be fixed\&.
1695.RE
1696.PP
1697\fB\-\-expensive\-definedness\-checks=<yes|no> [default: no] \fR
1698.RS 4
1699Controls whether Memcheck should employ more precise but also more expensive (time consuming) algorithms when checking the definedness of a value\&. The default setting is not to do that and it is usually sufficient\&. However, for highly optimised code valgrind may sometimes incorrectly complain\&. Invoking valgrind with
1700\fB\-\-expensive\-definedness\-checks=yes\fR
1701helps but comes at a performance cost\&. Runtime degradation of 25% have been observed but the extra cost depends a lot on the application at hand\&.
1702.RE
1703.PP
1704\fB\-\-keep\-stacktraces=alloc|free|alloc\-and\-free|alloc\-then\-free|none [default: alloc\-and\-free] \fR
1705.RS 4
1706Controls which stack trace(s) to keep for malloc\*(Aqd and/or free\*(Aqd blocks\&.
1707.sp
1708With
1709\fIalloc\-then\-free\fR, a stack trace is recorded at allocation time, and is associated with the block\&. When the block is freed, a second stack trace is recorded, and this replaces the allocation stack trace\&. As a result, any "use after free" errors relating to this block can only show a stack trace for where the block was freed\&.
1710.sp
1711With
1712\fIalloc\-and\-free\fR, both allocation and the deallocation stack traces for the block are stored\&. Hence a "use after free" error will show both, which may make the error easier to diagnose\&. Compared to
1713\fIalloc\-then\-free\fR, this setting slightly increases Valgrind\*(Aqs memory use as the block contains two references instead of one\&.
1714.sp
1715With
1716\fIalloc\fR, only the allocation stack trace is recorded (and reported)\&. With
1717\fIfree\fR, only the deallocation stack trace is recorded (and reported)\&. These values somewhat decrease Valgrind\*(Aqs memory and cpu usage\&. They can be useful depending on the error types you are searching for and the level of detail you need to analyse them\&. For example, if you are only interested in memory leak errors, it is sufficient to record the allocation stack traces\&.
1718.sp
1719With
1720\fInone\fR, no stack traces are recorded for malloc and free operations\&. If your program allocates a lot of blocks and/or allocates/frees from many different stack traces, this can significantly decrease cpu and/or memory required\&. Of course, few details will be reported for errors related to heap blocks\&.
1721.sp
1722Note that once a stack trace is recorded, Valgrind keeps the stack trace in memory even if it is not referenced by any block\&. Some programs (for example, recursive algorithms) can generate a huge number of stack traces\&. If Valgrind uses too much memory in such circumstances, you can reduce the memory required with the options
1723\fI\-\-keep\-stacktraces\fR
1724and/or by using a smaller value for the option
1725\fI\-\-num\-callers\fR\&.
Elliott Hughesed398002017-06-21 14:41:24 -07001726.sp
1727If you want to use
1728\-\-xtree\-memory=full
1729memory profiling (see
1730???
1731), then you cannot specify
1732\fI\-\-keep\-stacktraces=free\fR
1733or
1734\fI\-\-keep\-stacktraces=none\fR\&.
Elliott Hughesa0664b92017-04-18 17:46:52 -07001735.RE
1736.PP
1737\fB\-\-freelist\-vol=<number> [default: 20000000] \fR
1738.RS 4
1739When the client program releases memory using
1740\fBfree\fR
1741(in
1742C) or
1743delete
1744(C++), that memory is not immediately made available for re\-allocation\&. Instead, it is marked inaccessible and placed in a queue of freed blocks\&. The purpose is to defer as long as possible the point at which freed\-up memory comes back into circulation\&. This increases the chance that Memcheck will be able to detect invalid accesses to blocks for some significant period of time after they have been freed\&.
1745.sp
1746This option specifies the maximum total size, in bytes, of the blocks in the queue\&. The default value is twenty million bytes\&. Increasing this increases the total amount of memory used by Memcheck but may detect invalid uses of freed blocks which would otherwise go undetected\&.
1747.RE
1748.PP
1749\fB\-\-freelist\-big\-blocks=<number> [default: 1000000] \fR
1750.RS 4
1751When making blocks from the queue of freed blocks available for re\-allocation, Memcheck will in priority re\-circulate the blocks with a size greater or equal to
1752\fB\-\-freelist\-big\-blocks\fR\&. This ensures that freeing big blocks (in particular freeing blocks bigger than
1753\fB\-\-freelist\-vol\fR) does not immediately lead to a re\-circulation of all (or a lot of) the small blocks in the free list\&. In other words, this option increases the likelihood to discover dangling pointers for the "small" blocks, even when big blocks are freed\&.
1754.sp
1755Setting a value of 0 means that all the blocks are re\-circulated in a FIFO order\&.
1756.RE
1757.PP
1758\fB\-\-workaround\-gcc296\-bugs=<yes|no> [default: no] \fR
1759.RS 4
1760When enabled, assume that reads and writes some small distance below the stack pointer are due to bugs in GCC 2\&.96, and does not report them\&. The "small distance" is 256 bytes by default\&. Note that GCC 2\&.96 is the default compiler on some ancient Linux distributions (RedHat 7\&.X) and so you may need to use this option\&. Do not use it if you do not have to, as it can cause real errors to be overlooked\&. A better alternative is to use a more recent GCC in which this bug is fixed\&.
1761.sp
1762You may also need to use this option when working with GCC 3\&.X or 4\&.X on 32\-bit PowerPC Linux\&. This is because GCC generates code which occasionally accesses below the stack pointer, particularly for floating\-point to/from integer conversions\&. This is in violation of the 32\-bit PowerPC ELF specification, which makes no provision for locations below the stack pointer to be accessible\&.
1763.sp
1764This option is deprecated as of version 3\&.12 and may be removed from future versions\&. You should instead use
1765\fB\-\-ignore\-range\-below\-sp\fR
1766to specify the exact range of offsets below the stack pointer that should be ignored\&. A suitable equivalent is
1767\fB\-\-ignore\-range\-below\-sp=1024\-1\fR\&.
1768.RE
1769.PP
1770\fB\-\-ignore\-range\-below\-sp=<number>\-<number> \fR
1771.RS 4
1772This is a more general replacement for the deprecated
1773\fB\-\-workaround\-gcc296\-bugs\fR
1774option\&. When specified, it causes Memcheck not to report errors for accesses at the specified offsets below the stack pointer\&. The two offsets must be positive decimal numbers and \-\- somewhat counterintuitively \-\- the first one must be larger, in order to imply a non\-wraparound address range to ignore\&. For example, to ignore 4 byte accesses at 8192 bytes below the stack pointer, use
1775\fB\-\-ignore\-range\-below\-sp=8192\-8189\fR\&. Only one range may be specified\&.
1776.RE
1777.PP
1778\fB\-\-show\-mismatched\-frees=<yes|no> [default: yes] \fR
1779.RS 4
1780When enabled, Memcheck checks that heap blocks are deallocated using a function that matches the allocating function\&. That is, it expects
1781\fIfree\fR
1782to be used to deallocate blocks allocated by
1783\fImalloc\fR,
1784\fIdelete\fR
1785for blocks allocated by
1786\fInew\fR, and
1787\fIdelete[]\fR
1788for blocks allocated by
1789\fInew[]\fR\&. If a mismatch is detected, an error is reported\&. This is in general important because in some environments, freeing with a non\-matching function can cause crashes\&.
1790.sp
1791There is however a scenario where such mismatches cannot be avoided\&. That is when the user provides implementations of
1792\fInew\fR/\fInew[]\fR
1793that call
1794\fImalloc\fR
1795and of
1796\fIdelete\fR/\fIdelete[]\fR
1797that call
1798\fIfree\fR, and these functions are asymmetrically inlined\&. For example, imagine that
1799\fIdelete[]\fR
1800is inlined but
1801\fInew[]\fR
1802is not\&. The result is that Memcheck "sees" all
1803\fIdelete[]\fR
1804calls as direct calls to
1805\fIfree\fR, even when the program source contains no mismatched calls\&.
1806.sp
1807This causes a lot of confusing and irrelevant error reports\&.
1808\fI\-\-show\-mismatched\-frees=no\fR
1809disables these checks\&. It is not generally advisable to disable them, though, because you may miss real errors as a result\&.
1810.RE
1811.PP
1812\fB\-\-ignore\-ranges=0xPP\-0xQQ[,0xRR\-0xSS] \fR
1813.RS 4
1814Any ranges listed in this option (and multiple ranges can be specified, separated by commas) will be ignored by Memcheck\*(Aqs addressability checking\&.
1815.RE
1816.PP
1817\fB\-\-malloc\-fill=<hexnumber> \fR
1818.RS 4
1819Fills blocks allocated by
1820malloc,
1821new, etc, but not by
1822calloc, with the specified byte\&. This can be useful when trying to shake out obscure memory corruption problems\&. The allocated area is still regarded by Memcheck as undefined \-\- this option only affects its contents\&. Note that
1823\fB\-\-malloc\-fill\fR
1824does not affect a block of memory when it is used as argument to client requests VALGRIND_MEMPOOL_ALLOC or VALGRIND_MALLOCLIKE_BLOCK\&.
1825.RE
1826.PP
1827\fB\-\-free\-fill=<hexnumber> \fR
1828.RS 4
1829Fills blocks freed by
1830free,
1831delete, etc, with the specified byte value\&. This can be useful when trying to shake out obscure memory corruption problems\&. The freed area is still regarded by Memcheck as not valid for access \-\- this option only affects its contents\&. Note that
1832\fB\-\-free\-fill\fR
1833does not affect a block of memory when it is used as argument to client requests VALGRIND_MEMPOOL_FREE or VALGRIND_FREELIKE_BLOCK\&.
1834.RE
1835.SH "CACHEGRIND OPTIONS"
1836.PP
1837\fB\-\-I1=<size>,<associativity>,<line size> \fR
1838.RS 4
1839Specify the size, associativity and line size of the level 1 instruction cache\&.
1840.RE
1841.PP
1842\fB\-\-D1=<size>,<associativity>,<line size> \fR
1843.RS 4
1844Specify the size, associativity and line size of the level 1 data cache\&.
1845.RE
1846.PP
1847\fB\-\-LL=<size>,<associativity>,<line size> \fR
1848.RS 4
1849Specify the size, associativity and line size of the last\-level cache\&.
1850.RE
1851.PP
1852\fB\-\-cache\-sim=no|yes [yes] \fR
1853.RS 4
1854Enables or disables collection of cache access and miss counts\&.
1855.RE
1856.PP
1857\fB\-\-branch\-sim=no|yes [no] \fR
1858.RS 4
1859Enables or disables collection of branch instruction and misprediction counts\&. By default this is disabled as it slows Cachegrind down by approximately 25%\&. Note that you cannot specify
1860\fB\-\-cache\-sim=no\fR
1861and
1862\fB\-\-branch\-sim=no\fR
1863together, as that would leave Cachegrind with no information to collect\&.
1864.RE
1865.PP
1866\fB\-\-cachegrind\-out\-file=<file> \fR
1867.RS 4
1868Write the profile data to
1869file
1870rather than to the default output file,
1871cachegrind\&.out\&.<pid>\&. The
1872\fB%p\fR
1873and
1874\fB%q\fR
1875format specifiers can be used to embed the process ID and/or the contents of an environment variable in the name, as is the case for the core option
1876\fB--log-file\fR\&.
1877.RE
1878.SH "CALLGRIND OPTIONS"
1879.PP
1880\fB\-\-callgrind\-out\-file=<file> \fR
1881.RS 4
1882Write the profile data to
1883file
1884rather than to the default output file,
1885callgrind\&.out\&.<pid>\&. The
1886\fB%p\fR
1887and
1888\fB%q\fR
1889format specifiers can be used to embed the process ID and/or the contents of an environment variable in the name, as is the case for the core option
1890\fB--log-file\fR\&. When multiple dumps are made, the file name is modified further; see below\&.
1891.RE
1892.PP
1893\fB\-\-dump\-line=<no|yes> [default: yes] \fR
1894.RS 4
1895This specifies that event counting should be performed at source line granularity\&. This allows source annotation for sources which are compiled with debug information (\fB\-g\fR)\&.
1896.RE
1897.PP
1898\fB\-\-dump\-instr=<no|yes> [default: no] \fR
1899.RS 4
1900This specifies that event counting should be performed at per\-instruction granularity\&. This allows for assembly code annotation\&. Currently the results can only be displayed by KCachegrind\&.
1901.RE
1902.PP
1903\fB\-\-compress\-strings=<no|yes> [default: yes] \fR
1904.RS 4
1905This option influences the output format of the profile data\&. It specifies whether strings (file and function names) should be identified by numbers\&. This shrinks the file, but makes it more difficult for humans to read (which is not recommended in any case)\&.
1906.RE
1907.PP
1908\fB\-\-compress\-pos=<no|yes> [default: yes] \fR
1909.RS 4
1910This option influences the output format of the profile data\&. It specifies whether numerical positions are always specified as absolute values or are allowed to be relative to previous numbers\&. This shrinks the file size\&.
1911.RE
1912.PP
1913\fB\-\-combine\-dumps=<no|yes> [default: no] \fR
1914.RS 4
1915When enabled, when multiple profile data parts are to be generated these parts are appended to the same output file\&. Not recommended\&.
1916.RE
1917.PP
1918\fB\-\-dump\-every\-bb=<count> [default: 0, never] \fR
1919.RS 4
1920Dump profile data every
1921\fBcount\fR
1922basic blocks\&. Whether a dump is needed is only checked when Valgrind\*(Aqs internal scheduler is run\&. Therefore, the minimum setting useful is about 100000\&. The count is a 64\-bit value to make long dump periods possible\&.
1923.RE
1924.PP
1925\fB\-\-dump\-before=<function> \fR
1926.RS 4
1927Dump when entering
1928\fBfunction\fR\&.
1929.RE
1930.PP
1931\fB\-\-zero\-before=<function> \fR
1932.RS 4
1933Zero all costs when entering
1934\fBfunction\fR\&.
1935.RE
1936.PP
1937\fB\-\-dump\-after=<function> \fR
1938.RS 4
1939Dump when leaving
1940\fBfunction\fR\&.
1941.RE
1942.PP
1943\fB\-\-instr\-atstart=<yes|no> [default: yes] \fR
1944.RS 4
1945Specify if you want Callgrind to start simulation and profiling from the beginning of the program\&. When set to
1946no, Callgrind will not be able to collect any information, including calls, but it will have at most a slowdown of around 4, which is the minimum Valgrind overhead\&. Instrumentation can be interactively enabled via
1947callgrind_control \-i on\&.
1948.sp
1949Note that the resulting call graph will most probably not contain
1950\fBmain\fR, but will contain all the functions executed after instrumentation was enabled\&. Instrumentation can also programatically enabled/disabled\&. See the Callgrind include file
1951callgrind\&.h
1952for the macro you have to use in your source code\&.
1953.sp
1954For cache simulation, results will be less accurate when switching on instrumentation later in the program run, as the simulator starts with an empty cache at that moment\&. Switch on event collection later to cope with this error\&.
1955.RE
1956.PP
1957\fB\-\-collect\-atstart=<yes|no> [default: yes] \fR
1958.RS 4
1959Specify whether event collection is enabled at beginning of the profile run\&.
1960.sp
1961To only look at parts of your program, you have two possibilities:
1962.sp
1963.RS 4
1964.ie n \{\
1965\h'-04' 1.\h'+01'\c
1966.\}
1967.el \{\
1968.sp -1
1969.IP " 1." 4.2
1970.\}
1971Zero event counters before entering the program part you want to profile, and dump the event counters to a file after leaving that program part\&.
1972.RE
1973.sp
1974.RS 4
1975.ie n \{\
1976\h'-04' 2.\h'+01'\c
1977.\}
1978.el \{\
1979.sp -1
1980.IP " 2." 4.2
1981.\}
1982Switch on/off collection state as needed to only see event counters happening while inside of the program part you want to profile\&.
1983.RE
1984.sp
1985The second option can be used if the program part you want to profile is called many times\&. Option 1, i\&.e\&. creating a lot of dumps is not practical here\&.
1986.sp
1987Collection state can be toggled at entry and exit of a given function with the option
1988\fB--toggle-collect\fR\&. If you use this option, collection state should be disabled at the beginning\&. Note that the specification of
1989\fB\-\-toggle\-collect\fR
1990implicitly sets
1991\fB\-\-collect\-state=no\fR\&.
1992.sp
1993Collection state can be toggled also by inserting the client request
1994CALLGRIND_TOGGLE_COLLECT ;
1995at the needed code positions\&.
1996.RE
1997.PP
1998\fB\-\-toggle\-collect=<function> \fR
1999.RS 4
2000Toggle collection on entry/exit of
2001\fBfunction\fR\&.
2002.RE
2003.PP
2004\fB\-\-collect\-jumps=<no|yes> [default: no] \fR
2005.RS 4
2006This specifies whether information for (conditional) jumps should be collected\&. As above, callgrind_annotate currently is not able to show you the data\&. You have to use KCachegrind to get jump arrows in the annotated code\&.
2007.RE
2008.PP
2009\fB\-\-collect\-systime=<no|yes> [default: no] \fR
2010.RS 4
2011This specifies whether information for system call times should be collected\&.
2012.RE
2013.PP
2014\fB\-\-collect\-bus=<no|yes> [default: no] \fR
2015.RS 4
2016This specifies whether the number of global bus events executed should be collected\&. The event type "Ge" is used for these events\&.
2017.RE
2018.PP
2019\fB\-\-cache\-sim=<yes|no> [default: no] \fR
2020.RS 4
2021Specify if you want to do full cache simulation\&. By default, only instruction read accesses will be counted ("Ir")\&. With cache simulation, further event counters are enabled: Cache misses on instruction reads ("I1mr"/"ILmr"), data read accesses ("Dr") and related cache misses ("D1mr"/"DLmr"), data write accesses ("Dw") and related cache misses ("D1mw"/"DLmw")\&. For more information, see
2022Cachegrind: a cache and branch-prediction profiler\&.
2023.RE
2024.PP
2025\fB\-\-branch\-sim=<yes|no> [default: no] \fR
2026.RS 4
2027Specify if you want to do branch prediction simulation\&. Further event counters are enabled: Number of executed conditional branches and related predictor misses ("Bc"/"Bcm"), executed indirect jumps and related misses of the jump address predictor ("Bi"/"Bim")\&.
2028.RE
2029.SH "HELGRIND OPTIONS"
2030.PP
2031\fB\-\-free\-is\-write=no|yes [default: no] \fR
2032.RS 4
2033When enabled (not the default), Helgrind treats freeing of heap memory as if the memory was written immediately before the free\&. This exposes races where memory is referenced by one thread, and freed by another, but there is no observable synchronisation event to ensure that the reference happens before the free\&.
2034.sp
2035This functionality is new in Valgrind 3\&.7\&.0, and is regarded as experimental\&. It is not enabled by default because its interaction with custom memory allocators is not well understood at present\&. User feedback is welcomed\&.
2036.RE
2037.PP
2038\fB\-\-track\-lockorders=no|yes [default: yes] \fR
2039.RS 4
2040When enabled (the default), Helgrind performs lock order consistency checking\&. For some buggy programs, the large number of lock order errors reported can become annoying, particularly if you\*(Aqre only interested in race errors\&. You may therefore find it helpful to disable lock order checking\&.
2041.RE
2042.PP
2043\fB\-\-history\-level=none|approx|full [default: full] \fR
2044.RS 4
2045\fB\-\-history\-level=full\fR
2046(the default) causes Helgrind collects enough information about "old" accesses that it can produce two stack traces in a race report \-\- both the stack trace for the current access, and the trace for the older, conflicting access\&. To limit memory usage, "old" accesses stack traces are limited to a maximum of 8 entries, even if
2047\fB\-\-num\-callers\fR
2048value is bigger\&.
2049.sp
2050Collecting such information is expensive in both speed and memory, particularly for programs that do many inter\-thread synchronisation events (locks, unlocks, etc)\&. Without such information, it is more difficult to track down the root causes of races\&. Nonetheless, you may not need it in situations where you just want to check for the presence or absence of races, for example, when doing regression testing of a previously race\-free program\&.
2051.sp
2052\fB\-\-history\-level=none\fR
2053is the opposite extreme\&. It causes Helgrind not to collect any information about previous accesses\&. This can be dramatically faster than
2054\fB\-\-history\-level=full\fR\&.
2055.sp
2056\fB\-\-history\-level=approx\fR
2057provides a compromise between these two extremes\&. It causes Helgrind to show a full trace for the later access, and approximate information regarding the earlier access\&. This approximate information consists of two stacks, and the earlier access is guaranteed to have occurred somewhere between program points denoted by the two stacks\&. This is not as useful as showing the exact stack for the previous access (as
2058\fB\-\-history\-level=full\fR
2059does), but it is better than nothing, and it is almost as fast as
2060\fB\-\-history\-level=none\fR\&.
2061.RE
2062.PP
2063\fB\-\-conflict\-cache\-size=N [default: 1000000] \fR
2064.RS 4
2065This flag only has any effect at
2066\fB\-\-history\-level=full\fR\&.
2067.sp
2068Information about "old" conflicting accesses is stored in a cache of limited size, with LRU\-style management\&. This is necessary because it isn\*(Aqt practical to store a stack trace for every single memory access made by the program\&. Historical information on not recently accessed locations is periodically discarded, to free up space in the cache\&.
2069.sp
2070This option controls the size of the cache, in terms of the number of different memory addresses for which conflicting access information is stored\&. If you find that Helgrind is showing race errors with only one stack instead of the expected two stacks, try increasing this value\&.
2071.sp
2072The minimum value is 10,000 and the maximum is 30,000,000 (thirty times the default value)\&. Increasing the value by 1 increases Helgrind\*(Aqs memory requirement by very roughly 100 bytes, so the maximum value will easily eat up three extra gigabytes or so of memory\&.
2073.RE
2074.PP
2075\fB\-\-check\-stack\-refs=no|yes [default: yes] \fR
2076.RS 4
2077By default Helgrind checks all data memory accesses made by your program\&. This flag enables you to skip checking for accesses to thread stacks (local variables)\&. This can improve performance, but comes at the cost of missing races on stack\-allocated data\&.
2078.RE
2079.PP
2080\fB\-\-ignore\-thread\-creation=<yes|no> [default: no]\fR
2081.RS 4
2082Controls whether all activities during thread creation should be ignored\&. By default enabled only on Solaris\&. Solaris provides higher throughput, parallelism and scalability than other operating systems, at the cost of more fine\-grained locking activity\&. This means for example that when a thread is created under glibc, just one big lock is used for all thread setup\&. Solaris libc uses several fine\-grained locks and the creator thread resumes its activities as soon as possible, leaving for example stack and TLS setup sequence to the created thread\&. This situation confuses Helgrind as it assumes there is some false ordering in place between creator and created thread; and therefore many types of race conditions in the application would not be reported\&. To prevent such false ordering, this command line option is set to
2083yes
2084by default on Solaris\&. All activity (loads, stores, client requests) is therefore ignored during:
2085.sp
2086.RS 4
2087.ie n \{\
2088\h'-04'\(bu\h'+03'\c
2089.\}
2090.el \{\
2091.sp -1
2092.IP \(bu 2.3
2093.\}
2094pthread_create() call in the creator thread
2095.RE
2096.sp
2097.RS 4
2098.ie n \{\
2099\h'-04'\(bu\h'+03'\c
2100.\}
2101.el \{\
2102.sp -1
2103.IP \(bu 2.3
2104.\}
2105thread creation phase (stack and TLS setup) in the created thread
2106.RE
2107.sp
2108Also new memory allocated during thread creation is untracked, that is race reporting is suppressed there\&. DRD does the same thing implicitly\&. This is necessary because Solaris libc caches many objects and reuses them for different threads and that confuses Helgrind\&.
2109.RE
2110.SH "DRD OPTIONS"
2111.PP
2112\fB\-\-check\-stack\-var=<yes|no> [default: no]\fR
2113.RS 4
2114Controls whether DRD detects data races on stack variables\&. Verifying stack variables is disabled by default because most programs do not share stack variables over threads\&.
2115.RE
2116.PP
2117\fB\-\-exclusive\-threshold=<n> [default: off]\fR
2118.RS 4
2119Print an error message if any mutex or writer lock has been held longer than the time specified in milliseconds\&. This option enables the detection of lock contention\&.
2120.RE
2121.PP
2122\fB\-\-join\-list\-vol=<n> [default: 10]\fR
2123.RS 4
2124Data races that occur between a statement at the end of one thread and another thread can be missed if memory access information is discarded immediately after a thread has been joined\&. This option allows to specify for how many joined threads memory access information should be retained\&.
2125.RE
2126.PP
2127\fB \-\-first\-race\-only=<yes|no> [default: no] \fR
2128.RS 4
2129Whether to report only the first data race that has been detected on a memory location or all data races that have been detected on a memory location\&.
2130.RE
2131.PP
2132\fB \-\-free\-is\-write=<yes|no> [default: no] \fR
2133.RS 4
2134Whether to report races between accessing memory and freeing memory\&. Enabling this option may cause DRD to run slightly slower\&. Notes:
2135.sp
2136.RS 4
2137.ie n \{\
2138\h'-04'\(bu\h'+03'\c
2139.\}
2140.el \{\
2141.sp -1
2142.IP \(bu 2.3
2143.\}
2144Don\*(Aqt enable this option when using custom memory allocators that use the
2145VG_USERREQ__MALLOCLIKE_BLOCK
2146and
2147VG_USERREQ__FREELIKE_BLOCK
2148because that would result in false positives\&.
2149.RE
2150.sp
2151.RS 4
2152.ie n \{\
2153\h'-04'\(bu\h'+03'\c
2154.\}
2155.el \{\
2156.sp -1
2157.IP \(bu 2.3
2158.\}
2159Don\*(Aqt enable this option when using reference\-counted objects because that will result in false positives, even when that code has been annotated properly with
2160ANNOTATE_HAPPENS_BEFORE
2161and
2162ANNOTATE_HAPPENS_AFTER\&. See e\&.g\&. the output of the following command for an example:
2163valgrind \-\-tool=drd \-\-free\-is\-write=yes drd/tests/annotate_smart_pointer\&.
2164.RE
2165.RE
2166.PP
2167\fB \-\-report\-signal\-unlocked=<yes|no> [default: yes] \fR
2168.RS 4
2169Whether to report calls to
2170\fBpthread_cond_signal\fR
2171and
2172\fBpthread_cond_broadcast\fR
2173where the mutex associated with the signal through
2174\fBpthread_cond_wait\fR
2175or
2176\fBpthread_cond_timed_wait\fRis not locked at the time the signal is sent\&. Sending a signal without holding a lock on the associated mutex is a common programming error which can cause subtle race conditions and unpredictable behavior\&. There exist some uncommon synchronization patterns however where it is safe to send a signal without holding a lock on the associated mutex\&.
2177.RE
2178.PP
2179\fB\-\-segment\-merging=<yes|no> [default: yes]\fR
2180.RS 4
2181Controls segment merging\&. Segment merging is an algorithm to limit memory usage of the data race detection algorithm\&. Disabling segment merging may improve the accuracy of the so\-called \*(Aqother segments\*(Aq displayed in race reports but can also trigger an out of memory error\&.
2182.RE
2183.PP
2184\fB\-\-segment\-merging\-interval=<n> [default: 10]\fR
2185.RS 4
2186Perform segment merging only after the specified number of new segments have been created\&. This is an advanced configuration option that allows to choose whether to minimize DRD\*(Aqs memory usage by choosing a low value or to let DRD run faster by choosing a slightly higher value\&. The optimal value for this parameter depends on the program being analyzed\&. The default value works well for most programs\&.
2187.RE
2188.PP
2189\fB\-\-shared\-threshold=<n> [default: off]\fR
2190.RS 4
2191Print an error message if a reader lock has been held longer than the specified time (in milliseconds)\&. This option enables the detection of lock contention\&.
2192.RE
2193.PP
2194\fB\-\-show\-confl\-seg=<yes|no> [default: yes]\fR
2195.RS 4
2196Show conflicting segments in race reports\&. Since this information can help to find the cause of a data race, this option is enabled by default\&. Disabling this option makes the output of DRD more compact\&.
2197.RE
2198.PP
2199\fB\-\-show\-stack\-usage=<yes|no> [default: no]\fR
2200.RS 4
2201Print stack usage at thread exit time\&. When a program creates a large number of threads it becomes important to limit the amount of virtual memory allocated for thread stacks\&. This option makes it possible to observe how much stack memory has been used by each thread of the client program\&. Note: the DRD tool itself allocates some temporary data on the client thread stack\&. The space necessary for this temporary data must be allocated by the client program when it allocates stack memory, but is not included in stack usage reported by DRD\&.
2202.RE
2203.PP
2204\fB\-\-ignore\-thread\-creation=<yes|no> [default: no]\fR
2205.RS 4
2206Controls whether all activities during thread creation should be ignored\&. By default enabled only on Solaris\&. Solaris provides higher throughput, parallelism and scalability than other operating systems, at the cost of more fine\-grained locking activity\&. This means for example that when a thread is created under glibc, just one big lock is used for all thread setup\&. Solaris libc uses several fine\-grained locks and the creator thread resumes its activities as soon as possible, leaving for example stack and TLS setup sequence to the created thread\&. This situation confuses DRD as it assumes there is some false ordering in place between creator and created thread; and therefore many types of race conditions in the application would not be reported\&. To prevent such false ordering, this command line option is set to
2207yes
2208by default on Solaris\&. All activity (loads, stores, client requests) is therefore ignored during:
2209.sp
2210.RS 4
2211.ie n \{\
2212\h'-04'\(bu\h'+03'\c
2213.\}
2214.el \{\
2215.sp -1
2216.IP \(bu 2.3
2217.\}
2218pthread_create() call in the creator thread
2219.RE
2220.sp
2221.RS 4
2222.ie n \{\
2223\h'-04'\(bu\h'+03'\c
2224.\}
2225.el \{\
2226.sp -1
2227.IP \(bu 2.3
2228.\}
2229thread creation phase (stack and TLS setup) in the created thread
2230.RE
2231.RE
2232.PP
2233\fB\-\-trace\-addr=<address> [default: none]\fR
2234.RS 4
2235Trace all load and store activity for the specified address\&. This option may be specified more than once\&.
2236.RE
2237.PP
2238\fB\-\-ptrace\-addr=<address> [default: none]\fR
2239.RS 4
2240Trace all load and store activity for the specified address and keep doing that even after the memory at that address has been freed and reallocated\&.
2241.RE
2242.PP
2243\fB\-\-trace\-alloc=<yes|no> [default: no]\fR
2244.RS 4
2245Trace all memory allocations and deallocations\&. May produce a huge amount of output\&.
2246.RE
2247.PP
2248\fB\-\-trace\-barrier=<yes|no> [default: no]\fR
2249.RS 4
2250Trace all barrier activity\&.
2251.RE
2252.PP
2253\fB\-\-trace\-cond=<yes|no> [default: no]\fR
2254.RS 4
2255Trace all condition variable activity\&.
2256.RE
2257.PP
2258\fB\-\-trace\-fork\-join=<yes|no> [default: no]\fR
2259.RS 4
2260Trace all thread creation and all thread termination events\&.
2261.RE
2262.PP
2263\fB\-\-trace\-hb=<yes|no> [default: no]\fR
2264.RS 4
2265Trace execution of the
2266ANNOTATE_HAPPENS_BEFORE(),
2267ANNOTATE_HAPPENS_AFTER()
2268and
2269ANNOTATE_HAPPENS_DONE()
2270client requests\&.
2271.RE
2272.PP
2273\fB\-\-trace\-mutex=<yes|no> [default: no]\fR
2274.RS 4
2275Trace all mutex activity\&.
2276.RE
2277.PP
2278\fB\-\-trace\-rwlock=<yes|no> [default: no]\fR
2279.RS 4
2280Trace all reader\-writer lock activity\&.
2281.RE
2282.PP
2283\fB\-\-trace\-semaphore=<yes|no> [default: no]\fR
2284.RS 4
2285Trace all semaphore activity\&.
2286.RE
2287.SH "MASSIF OPTIONS"
2288.PP
2289\fB\-\-heap=<yes|no> [default: yes] \fR
2290.RS 4
2291Specifies whether heap profiling should be done\&.
2292.RE
2293.PP
2294\fB\-\-heap\-admin=<size> [default: 8] \fR
2295.RS 4
2296If heap profiling is enabled, gives the number of administrative bytes per block to use\&. This should be an estimate of the average, since it may vary\&. For example, the allocator used by glibc on Linux requires somewhere between 4 to 15 bytes per block, depending on various factors\&. That allocator also requires admin space for freed blocks, but Massif cannot account for this\&.
2297.RE
2298.PP
2299\fB\-\-stacks=<yes|no> [default: no] \fR
2300.RS 4
2301Specifies whether stack profiling should be done\&. This option slows Massif down greatly, and so is off by default\&. Note that Massif assumes that the main stack has size zero at start\-up\&. This is not true, but doing otherwise accurately is difficult\&. Furthermore, starting at zero better indicates the size of the part of the main stack that a user program actually has control over\&.
2302.RE
2303.PP
2304\fB\-\-pages\-as\-heap=<yes|no> [default: no] \fR
2305.RS 4
2306Tells Massif to profile memory at the page level rather than at the malloc\*(Aqd block level\&. See above for details\&.
2307.RE
2308.PP
2309\fB\-\-depth=<number> [default: 30] \fR
2310.RS 4
2311Maximum depth of the allocation trees recorded for detailed snapshots\&. Increasing it will make Massif run somewhat more slowly, use more memory, and produce bigger output files\&.
2312.RE
2313.PP
2314\fB\-\-alloc\-fn=<name> \fR
2315.RS 4
2316Functions specified with this option will be treated as though they were a heap allocation function such as
2317\fBmalloc\fR\&. This is useful for functions that are wrappers to
2318\fBmalloc\fR
2319or
2320\fBnew\fR, which can fill up the allocation trees with uninteresting information\&. This option can be specified multiple times on the command line, to name multiple functions\&.
2321.sp
2322Note that the named function will only be treated this way if it is the top entry in a stack trace, or just below another function treated this way\&. For example, if you have a function
2323\fBmalloc1\fR
2324that wraps
2325\fBmalloc\fR, and
2326\fBmalloc2\fR
2327that wraps
2328\fBmalloc1\fR, just specifying
2329\fB\-\-alloc\-fn=malloc2\fR
2330will have no effect\&. You need to specify
2331\fB\-\-alloc\-fn=malloc1\fR
2332as well\&. This is a little inconvenient, but the reason is that checking for allocation functions is slow, and it saves a lot of time if Massif can stop looking through the stack trace entries as soon as it finds one that doesn\*(Aqt match rather than having to continue through all the entries\&.
2333.sp
2334Note that C++ names are demangled\&. Note also that overloaded C++ names must be written in full\&. Single quotes may be necessary to prevent the shell from breaking them up\&. For example:
2335.sp
2336.if n \{\
2337.RS 4
2338.\}
2339.nf
2340\-\-alloc\-fn=\*(Aqoperator new(unsigned, std::nothrow_t const&)\*(Aq
2341.fi
2342.if n \{\
2343.RE
2344.\}
2345.sp
2346.RE
2347.PP
2348\fB\-\-ignore\-fn=<name> \fR
2349.RS 4
2350Any direct heap allocation (i\&.e\&. a call to
2351\fBmalloc\fR,
2352\fBnew\fR, etc, or a call to a function named by an
2353\fB\-\-alloc\-fn\fR
2354option) that occurs in a function specified by this option will be ignored\&. This is mostly useful for testing purposes\&. This option can be specified multiple times on the command line, to name multiple functions\&.
2355.sp
2356Any
2357\fBrealloc\fR
2358of an ignored block will also be ignored, even if the
2359\fBrealloc\fR
2360call does not occur in an ignored function\&. This avoids the possibility of negative heap sizes if ignored blocks are shrunk with
2361\fBrealloc\fR\&.
2362.sp
2363The rules for writing C++ function names are the same as for
2364\fB\-\-alloc\-fn\fR
2365above\&.
2366.RE
2367.PP
2368\fB\-\-threshold=<m\&.n> [default: 1\&.0] \fR
2369.RS 4
2370The significance threshold for heap allocations, as a percentage of total memory size\&. Allocation tree entries that account for less than this will be aggregated\&. Note that this should be specified in tandem with ms_print\*(Aqs option of the same name\&.
2371.RE
2372.PP
2373\fB\-\-peak\-inaccuracy=<m\&.n> [default: 1\&.0] \fR
2374.RS 4
2375Massif does not necessarily record the actual global memory allocation peak; by default it records a peak only when the global memory allocation size exceeds the previous peak by at least 1\&.0%\&. This is because there can be many local allocation peaks along the way, and doing a detailed snapshot for every one would be expensive and wasteful, as all but one of them will be later discarded\&. This inaccuracy can be changed (even to 0\&.0%) via this option, but Massif will run drastically slower as the number approaches zero\&.
2376.RE
2377.PP
2378\fB\-\-time\-unit=<i|ms|B> [default: i] \fR
2379.RS 4
2380The time unit used for the profiling\&. There are three possibilities: instructions executed (i), which is good for most cases; real (wallclock) time (ms, i\&.e\&. milliseconds), which is sometimes useful; and bytes allocated/deallocated on the heap and/or stack (B), which is useful for very short\-run programs, and for testing purposes, because it is the most reproducible across different machines\&.
2381.RE
2382.PP
2383\fB\-\-detailed\-freq=<n> [default: 10] \fR
2384.RS 4
2385Frequency of detailed snapshots\&. With
2386\fB\-\-detailed\-freq=1\fR, every snapshot is detailed\&.
2387.RE
2388.PP
2389\fB\-\-max\-snapshots=<n> [default: 100] \fR
2390.RS 4
2391The maximum number of snapshots recorded\&. If set to N, for all programs except very short\-running ones, the final number of snapshots will be between N/2 and N\&.
2392.RE
2393.PP
2394\fB\-\-massif\-out\-file=<file> [default: massif\&.out\&.%p] \fR
2395.RS 4
2396Write the profile data to
2397file
2398rather than to the default output file,
2399massif\&.out\&.<pid>\&. The
2400\fB%p\fR
2401and
2402\fB%q\fR
2403format specifiers can be used to embed the process ID and/or the contents of an environment variable in the name, as is the case for the core option
2404\fB--log-file\fR\&.
2405.RE
2406.SH "SGCHECK OPTIONS"
2407.PP
2408There are no SGCheck\-specific command\-line options at present\&.
2409.SH "BBV OPTIONS"
2410.PP
2411\fB\-\-bb\-out\-file=<name> [default: bb\&.out\&.%p] \fR
2412.RS 4
2413This option selects the name of the basic block vector file\&. The
2414\fB%p\fR
2415and
2416\fB%q\fR
2417format specifiers can be used to embed the process ID and/or the contents of an environment variable in the name, as is the case for the core option
2418\fB--log-file\fR\&.
2419.RE
2420.PP
2421\fB\-\-pc\-out\-file=<name> [default: pc\&.out\&.%p] \fR
2422.RS 4
2423This option selects the name of the PC file\&. This file holds program counter addresses and function name info for the various basic blocks\&. This can be used in conjunction with the basic block vector file to fast\-forward via function names instead of just instruction counts\&. The
2424\fB%p\fR
2425and
2426\fB%q\fR
2427format specifiers can be used to embed the process ID and/or the contents of an environment variable in the name, as is the case for the core option
2428\fB--log-file\fR\&.
2429.RE
2430.PP
2431\fB\-\-interval\-size=<number> [default: 100000000] \fR
2432.RS 4
2433This option selects the size of the interval to use\&. The default is 100 million instructions, which is a commonly used value\&. Other sizes can be used; smaller intervals can help programs with finer\-grained phases\&. However smaller interval size can lead to accuracy issues due to warm\-up effects (When fast\-forwarding the various architectural features will be un\-initialized, and it will take some number of instructions before they "warm up" to the state a full simulation would be at without the fast\-forwarding\&. Large interval sizes tend to mitigate this\&.)
2434.RE
2435.PP
2436\fB\-\-instr\-count\-only [default: no] \fR
2437.RS 4
2438This option tells the tool to only display instruction count totals, and to not generate the actual basic block vector file\&. This is useful for debugging, and for gathering instruction count info without generating the large basic block vector files\&.
2439.RE
2440.SH "LACKEY OPTIONS"
2441.PP
2442\fB\-\-basic\-counts=<no|yes> [default: yes] \fR
2443.RS 4
2444When enabled, Lackey prints the following statistics and information about the execution of the client program:
2445.sp
2446.RS 4
2447.ie n \{\
2448\h'-04' 1.\h'+01'\c
2449.\}
2450.el \{\
2451.sp -1
2452.IP " 1." 4.2
2453.\}
2454The number of calls to the function specified by the
2455\fB\-\-fnname\fR
2456option (the default is
2457main)\&. If the program has had its symbols stripped, the count will always be zero\&.
2458.RE
2459.sp
2460.RS 4
2461.ie n \{\
2462\h'-04' 2.\h'+01'\c
2463.\}
2464.el \{\
2465.sp -1
2466.IP " 2." 4.2
2467.\}
2468The number of conditional branches encountered and the number and proportion of those taken\&.
2469.RE
2470.sp
2471.RS 4
2472.ie n \{\
2473\h'-04' 3.\h'+01'\c
2474.\}
2475.el \{\
2476.sp -1
2477.IP " 3." 4.2
2478.\}
2479The number of superblocks entered and completed by the program\&. Note that due to optimisations done by the JIT, this is not at all an accurate value\&.
2480.RE
2481.sp
2482.RS 4
2483.ie n \{\
2484\h'-04' 4.\h'+01'\c
2485.\}
2486.el \{\
2487.sp -1
2488.IP " 4." 4.2
2489.\}
2490The number of guest (x86, amd64, ppc, etc\&.) instructions and IR statements executed\&. IR is Valgrind\*(Aqs RISC\-like intermediate representation via which all instrumentation is done\&.
2491.RE
2492.sp
2493.RS 4
2494.ie n \{\
2495\h'-04' 5.\h'+01'\c
2496.\}
2497.el \{\
2498.sp -1
2499.IP " 5." 4.2
2500.\}
2501Ratios between some of these counts\&.
2502.RE
2503.sp
2504.RS 4
2505.ie n \{\
2506\h'-04' 6.\h'+01'\c
2507.\}
2508.el \{\
2509.sp -1
2510.IP " 6." 4.2
2511.\}
2512The exit code of the client program\&.
2513.RE
2514.RE
2515.PP
2516\fB\-\-detailed\-counts=<no|yes> [default: no] \fR
2517.RS 4
2518When enabled, Lackey prints a table containing counts of loads, stores and ALU operations, differentiated by their IR types\&. The IR types are identified by their IR name ("I1", "I8", \&.\&.\&. "I128", "F32", "F64", and "V128")\&.
2519.RE
2520.PP
2521\fB\-\-trace\-mem=<no|yes> [default: no] \fR
2522.RS 4
2523When enabled, Lackey prints the size and address of almost every memory access made by the program\&. See the comments at the top of the file
2524lackey/lk_main\&.c
2525for details about the output format, how it works, and inaccuracies in the address trace\&. Note that this option produces immense amounts of output\&.
2526.RE
2527.PP
2528\fB\-\-trace\-superblocks=<no|yes> [default: no] \fR
2529.RS 4
2530When enabled, Lackey prints out the address of every superblock (a single entry, multiple exit, linear chunk of code) executed by the program\&. This is primarily of interest to Valgrind developers\&. See the comments at the top of the file
2531lackey/lk_main\&.c
2532for details about the output format\&. Note that this option produces large amounts of output\&.
2533.RE
2534.PP
2535\fB\-\-fnname=<name> [default: main] \fR
2536.RS 4
2537Changes the function for which calls are counted when
2538\fB\-\-basic\-counts=yes\fR
2539is specified\&.
2540.RE
2541.SH "SEE ALSO"
2542.PP
2543cg_annotate(1), callgrind_annotate(1), callgrind_control(1), ms_print(1),
2544$INSTALL/share/doc/valgrind/html/index\&.html
2545or
2546http://www\&.valgrind\&.org/docs/manual/index\&.html,
Elliott Hughesed398002017-06-21 14:41:24 -07002547\m[blue]\fBDebugging your program using Valgrind\*(Aqs gdbserver and GDB\fR\m[]\&\s-2\u[1]\d\s+2
2548\m[blue]\fBvgdb\fR\m[]\&\s-2\u[2]\d\s+2,
Elliott Hughesa0664b92017-04-18 17:46:52 -07002549\m[blue]\fBValgrind monitor commands\fR\m[]\&\s-2\u[3]\d\s+2,
2550\m[blue]\fBThe Commentary\fR\m[]\&\s-2\u[4]\d\s+2,
2551\m[blue]\fBScheduling and Multi\-Thread Performance\fR\m[]\&\s-2\u[5]\d\s+2,
2552\m[blue]\fBCachegrind: a cache and branch\-prediction profiler\fR\m[]\&\s-2\u[6]\d\s+2\&.
2553.SH "AUTHOR"
2554.PP
2555See the AUTHORS file in the valgrind distribution for a comprehensive list of authors\&.
2556.PP
2557This manpage was written by Andres Roldan <aroldan@debian\&.org> and the Valgrind developers\&.
2558.SH "NOTES"
2559.IP " 1." 4
2560Debugging your program using Valgrind's gdbserver and GDB
2561.RS 4
2562\%http://www.valgrind.org/docs/manual/manual-core-adv.html#manual-core-adv.gdbserver
2563.RE
2564.IP " 2." 4
2565vgdb
2566.RS 4
2567\%http://www.valgrind.org/docs/manual/manual-core-adv.html#manual-core-adv.vgdb
2568.RE
2569.IP " 3." 4
2570Valgrind monitor commands
2571.RS 4
2572\%http://www.valgrind.org/docs/manual/manual-core-adv.html#manual-core-adv.valgrind-monitor-commands
2573.RE
2574.IP " 4." 4
2575The Commentary
2576.RS 4
2577\%http://www.valgrind.org/docs/manual/manual-core.html#manual-core.comment
2578.RE
2579.IP " 5." 4
2580Scheduling and Multi-Thread Performance
2581.RS 4
2582\%http://www.valgrind.org/docs/manual/manual-core.html#manual-core.pthreads_perf_sched
2583.RE
2584.IP " 6." 4
2585Cachegrind: a cache and branch-prediction profiler
2586.RS 4
2587\%http://www.valgrind.org/docs/manual/cg-manual.html
2588.RE