where XXXXXX is the bug number as listed below.
140178 open("/proc/self/exe", ...); doesn't quite work
+140939 --track-fds reports leakage of stdout/in/err and doesn't respect -q
345077 linux syscall execveat support (linux 3.19)
369029 handle linux syscalls sched_getattr and sched_setattr
n-i-bz helgrind: If hg_cli__realloc fails, return NULL.
" v.info last_error : show last error found\n"
" v.info location <addr> : show information about location <addr>\n"
" v.info n_errs_found [msg] : show the nr of errors found so far and the given msg\n"
-" v.info open_fds : show open file descriptors (only if --track-fds=yes)\n"
+" v.info open_fds : show open file descriptors (only if --track-fds=[yes|all])\n"
" v.kill : kill the Valgrind process\n"
" v.clo <clo_option>... : changes one or more dynamic command line options\n"
" with no clo_option, show the dynamically changeable options.\n"
VG_(show_open_fds) ("");
else
VG_(gdb_printf)
- ("Valgrind must be started with --track-fds=yes"
+ ("Valgrind must be started with --track-fds=[yes|all]"
" to show open fds\n");
ret = 1;
break;
" --vgdb-stop-at=event1,event2,... invoke gdbserver for given events [none]\n"
" where event is one of:\n"
" startup exit valgrindabexit all none\n"
-" --track-fds=no|yes track open file descriptors? [no]\n"
+" --track-fds=no|yes|all track open file descriptors? [no]\n"
+" all includes reporting stdin, stdout and stderr\n"
" --time-stamp=no|yes add timestamps to log messages? [no]\n"
" --log-fd=<number> log messages to file descriptor [2=stderr]\n"
" --log-file=<file> log messages to <file>\n"
else if VG_BOOL_CLOM(cloPD, arg, "--show-below-main", VG_(clo_show_below_main)) {}
else if VG_BOOL_CLO(arg, "--keep-debuginfo", VG_(clo_keep_debuginfo)) {}
else if VG_BOOL_CLOM(cloPD, arg, "--time-stamp", VG_(clo_time_stamp)) {}
- else if VG_BOOL_CLO(arg, "--track-fds", VG_(clo_track_fds)) {}
+ else if VG_STR_CLO(arg, "--track-fds", tmp_str) {
+ if (VG_(strcmp)(tmp_str, "yes") == 0)
+ VG_(clo_track_fds) = 1;
+ else if (VG_(strcmp)(tmp_str, "all") == 0)
+ VG_(clo_track_fds) = 2;
+ else if (VG_(strcmp)(tmp_str, "no") == 0)
+ VG_(clo_track_fds) = 0;
+ else
+ VG_(fmsg_bad_option)(arg,
+ "Bad argument, should be 'yes', 'all' or 'no'\n");
+ }
else if VG_BOOL_CLOM(cloPD, arg, "--trace-children", VG_(clo_trace_children)) {}
else if VG_BOOL_CLOM(cloPD, arg, "--child-silent-after-fork",
VG_(clo_child_silent_after_fork)) {}
XArray *VG_(clo_req_tsyms); // array of strings
Bool VG_(clo_run_libc_freeres) = True;
Bool VG_(clo_run_cxx_freeres) = True;
-Bool VG_(clo_track_fds) = False;
+UInt VG_(clo_track_fds) = 0;
Bool VG_(clo_show_below_main)= False;
Bool VG_(clo_keep_debuginfo) = False;
Bool VG_(clo_show_emwarns) = False;
/* Dump out a summary, and a more detailed list, of open file descriptors. */
void VG_(show_open_fds) (const HChar* when)
{
- OpenFd *i = allocated_fds;
+ OpenFd *i;
+ int non_std = 0;
- VG_(message)(Vg_UserMsg, "FILE DESCRIPTORS: %d open %s.\n", fd_count, when);
+ for (i = allocated_fds; i; i = i->next) {
+ if (i->fd > 2)
+ non_std++;
+ }
+
+ /* If we are running quiet and there are either no open file descriptors
+ or not tracking all fds, then don't report anything. */
+ if ((fd_count == 0
+ || ((non_std == 0) && (VG_(clo_track_fds) < 2)))
+ && (VG_(clo_verbosity) == 0))
+ return;
+
+ VG_(message)(Vg_UserMsg, "FILE DESCRIPTORS: %d open (%d std) %s.\n",
+ fd_count, fd_count - non_std, when);
+
+ for (i = allocated_fds; i; i = i->next) {
+ if (i->fd <= 2 && VG_(clo_track_fds) < 2)
+ continue;
- while (i) {
if (i->pathname) {
VG_(message)(Vg_UserMsg, "Open file descriptor %d: %s\n", i->fd,
i->pathname);
VG_(message)(Vg_UserMsg, " <inherited from parent>\n");
VG_(message)(Vg_UserMsg, "\n");
}
-
- i = i->next;
}
VG_(message)(Vg_UserMsg, "\n");
wildcards. */
extern XArray *VG_(clo_req_tsyms);
-/* Track open file descriptors? */
-extern Bool VG_(clo_track_fds);
+/* Track open file descriptors? 0 = No, 1 = Yes, 2 = All (including std) */
+extern UInt VG_(clo_track_fds);
/* Should we run __libc_freeres at exit? Sometimes causes crashes.
Default: YES. Note this is subservient to VG_(needs).libc_freeres;
<listitem>
<para><varname>v.info open_fds</varname> shows the list of open file
descriptors and details related to the file descriptor.
- This only works if <option>--track-fds=yes</option>
- was given at Valgrind startup.</para>
+ This only works if <option>--track-fds=yes</option> or
+ <option>--track-fds=all</option> (to include
+ <computeroutput>stdin</computeroutput>,
+ <computeroutput>stdout</computeroutput> and
+ <computeroutput>stderr</computeroutput>) was given at Valgrindr
+ startup.</para>
</listitem>
<listitem>
<varlistentry id="opt.track-fds" xreflabel="--track-fds">
<term>
- <option><![CDATA[--track-fds=<yes|no> [default: no] ]]></option>
+ <option><![CDATA[--track-fds=<yes|no|all> [default: no] ]]></option>
</term>
<listitem>
<para>When enabled, Valgrind will print out a list of open file
command <varname>v.info open_fds</varname>. 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.</para>
+ as the file name or socket details. Use <option>all</option> to
+ include reporting on <computeroutput>stdin</computeroutput>,
+ <computeroutput>stdout</computeroutput> and
+ <computeroutput>stderr</computeroutput>.</para>
</listitem>
</varlistentry>
v.info last_error : show last error found
v.info location <addr> : show information about location <addr>
v.info n_errs_found [msg] : show the nr of errors found so far and the given msg
- v.info open_fds : show open file descriptors (only if --track-fds=yes)
+ v.info open_fds : show open file descriptors (only if --track-fds=[yes|all])
v.kill : kill the Valgrind process
v.clo <clo_option>... : changes one or more dynamic command line options
with no clo_option, show the dynamically changeable options.
v.info last_error : show last error found
v.info location <addr> : show information about location <addr>
v.info n_errs_found [msg] : show the nr of errors found so far and the given msg
- v.info open_fds : show open file descriptors (only if --track-fds=yes)
+ v.info open_fds : show open file descriptors (only if --track-fds=[yes|all])
v.kill : kill the Valgrind process
v.clo <clo_option>... : changes one or more dynamic command line options
with no clo_option, show the dynamically changeable options.
v.info last_error : show last error found
v.info location <addr> : show information about location <addr>
v.info n_errs_found [msg] : show the nr of errors found so far and the given msg
- v.info open_fds : show open file descriptors (only if --track-fds=yes)
+ v.info open_fds : show open file descriptors (only if --track-fds=[yes|all])
v.kill : kill the Valgrind process
v.clo <clo_option>... : changes one or more dynamic command line options
with no clo_option, show the dynamically changeable options.
--vgdb-stop-at=event1,event2,... invoke gdbserver for given events [none]
where event is one of:
startup exit valgrindabexit all none
- --track-fds=no|yes track open file descriptors? [no]
+ --track-fds=no|yes|all track open file descriptors? [no]
+ all includes reporting stdin, stdout and stderr
--time-stamp=no|yes add timestamps to log messages? [no]
--log-fd=<number> log messages to file descriptor [2=stderr]
--log-file=<file> log messages to <file>
--vgdb-stop-at=event1,event2,... invoke gdbserver for given events [none]
where event is one of:
startup exit valgrindabexit all none
- --track-fds=no|yes track open file descriptors? [no]
+ --track-fds=no|yes|all track open file descriptors? [no]
+ all includes reporting stdin, stdout and stderr
--time-stamp=no|yes add timestamps to log messages? [no]
--log-fd=<number> log messages to file descriptor [2=stderr]
--log-file=<file> log messages to <file>
-FILE DESCRIPTORS: 7 open at exit.
+FILE DESCRIPTORS: 7 open (3 std) at exit.
Open AF_UNIX socket ...: /tmp/sock
...
-FILE DESCRIPTORS: 6 open at exit.
+FILE DESCRIPTORS: 6 open (3 std) at exit.
Open file descriptor ...: /tmp/data2
...
prog: fdleak_cmsg
-vgopts: --track-fds=yes
+vgopts: --track-fds=all
stderr_filter: filter_fdleak
args: < /dev/null
-FILE DESCRIPTORS: 4 open at exit.
+FILE DESCRIPTORS: 4 open (3 std) at exit.
Open file descriptor ...: /tmp/file
...
prog: fdleak_creat
-vgopts: --track-fds=yes
+vgopts: --track-fds=all
stderr_filter: filter_fdleak
args: < /dev/null
-FILE DESCRIPTORS: 5 open at exit.
+FILE DESCRIPTORS: 5 open (3 std) at exit.
Open file descriptor ...: /dev/null
...
prog: fdleak_dup
-vgopts: --track-fds=yes
+vgopts: --track-fds=all
stderr_filter: filter_fdleak
args: < /dev/null
-FILE DESCRIPTORS: 6 open at exit.
+FILE DESCRIPTORS: 6 open (3 std) at exit.
Open file descriptor ...: /dev/null
...
prog: fdleak_dup2
-vgopts: --track-fds=yes
+vgopts: --track-fds=all
stderr_filter: filter_fdleak
args: < /dev/null
-FILE DESCRIPTORS: 5 open at exit.
+FILE DESCRIPTORS: 5 open (3 std) at exit.
Open file descriptor ...: /dev/null
...
prog: fdleak_fcntl
-vgopts: --track-fds=yes
+vgopts: --track-fds=all
stderr_filter: filter_fdleak
args: < /dev/null
-FILE DESCRIPTORS: 5 open at exit.
+FILE DESCRIPTORS: 5 open (3 std) at exit.
Open AF_INET socket 4: 127.0.0.1:... <-> 127.0.0.1:...
...
Open AF_INET socket 3: 127.0.0.1:... <-> unbound
...
-Open file descriptor ...: ...
- <inherited from parent>
-Open file descriptor ...: ...
- <inherited from parent>
-Open file descriptor ...: /dev/null
- <inherited from parent>
-
-
-
-FILE DESCRIPTORS: 4 open at exit.
+FILE DESCRIPTORS: 4 open (3 std) at exit.
Open AF_INET socket 3: 127.0.0.1:... <-> 127.0.0.1:...
...
-Open file descriptor ...: ...
- <inherited from parent>
-
-Open file descriptor ...: ...
- <inherited from parent>
-
-Open file descriptor ...: /dev/null
- <inherited from parent>
-
-FILE DESCRIPTORS: 4 open at exit.
+FILE DESCRIPTORS: 4 open (3 std) at exit.
Open file descriptor ...: /dev/null
...
-Open file descriptor ...: ...
- <inherited from parent>
-
-Open file descriptor ...: ...
- <inherited from parent>
-
-Open file descriptor ...: /dev/null
- <inherited from parent>
-
-FILE DESCRIPTORS: 5 open at exit.
+FILE DESCRIPTORS: 5 open (3 std) at exit.
Open file descriptor ...:
...
Open file descriptor ...:
...
-Open file descriptor ...: ...
- <inherited from parent>
-
-Open file descriptor ...: ...
- <inherited from parent>
-
-Open file descriptor ...: /dev/null
- <inherited from parent>
-
-FILE DESCRIPTORS: 5 open at exit.
+FILE DESCRIPTORS: 5 open (3 std) at exit.
Open AF_UNIX socket ...: <unknown>
...
Open AF_UNIX socket ...: <unknown>
...
-Open file descriptor ...: ...
- <inherited from parent>
-
-Open file descriptor ...: ...
- <inherited from parent>
-
-Open file descriptor ...: /dev/null
- <inherited from parent>
-