<li><code>--cachesim=no</code> [default]<br>
<code>--cachesim=yes</code> <p>When enabled, turns off memory
checking, and turns on cache profiling. Cache profiling is
- described in detail in <a href="#cache">Section 7</a>. </li><p>
+ described in detail in <a href="#cache">Section 7</a>.
+ </li><br><p>
+
+ <li><code>--wierd-hacks=hack1,hack2,...</code>
+ Pass 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 hacks
+ are enabled. Use with caution! Currently known hacks are:
+ <p>
+ <ul>
+ <li><code>ioctl-VTIME</code> Use this if you have a program
+ which sets readable file descriptors to have a timeout by
+ doing <code>ioctl</code> on them with a
+ <code>TCSETA</code>-style command <b>and</b> a non-zero
+ <code>VTIME</code> timeout value. This is considered
+ potentially dangerous and therefore is not engaged by
+ default, because it is (remotely) conceivable that it could
+ cause threads doing <code>read</code> to incorrectly block
+ the entire process.
+ <p>
+ You probably want to try this one if you have a program
+ which unexpectedly blocks in a <code>read</code> from a file
+ descriptor which you know to have been messed with by
+ <code>ioctl</code>. This could happen, for example, if the
+ descriptor is used to read input from some kind of screen
+ handling library.
+ <p>
+ To find out if your program is blocking unexpectedly in the
+ <code>read</code> system call, run with
+ <code>--trace-syscalls=yes</code> flag.
+ </ul>
+
+ </li><p>
</ul>
There are also some options for debugging Valgrind itself. You
<li><code>--cachesim=no</code> [default]<br>
<code>--cachesim=yes</code> <p>When enabled, turns off memory
checking, and turns on cache profiling. Cache profiling is
- described in detail in <a href="#cache">Section 7</a>. </li><p>
+ described in detail in <a href="#cache">Section 7</a>.
+ </li><br><p>
+
+ <li><code>--wierd-hacks=hack1,hack2,...</code>
+ Pass 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 hacks
+ are enabled. Use with caution! Currently known hacks are:
+ <p>
+ <ul>
+ <li><code>ioctl-VTIME</code> Use this if you have a program
+ which sets readable file descriptors to have a timeout by
+ doing <code>ioctl</code> on them with a
+ <code>TCSETA</code>-style command <b>and</b> a non-zero
+ <code>VTIME</code> timeout value. This is considered
+ potentially dangerous and therefore is not engaged by
+ default, because it is (remotely) conceivable that it could
+ cause threads doing <code>read</code> to incorrectly block
+ the entire process.
+ <p>
+ You probably want to try this one if you have a program
+ which unexpectedly blocks in a <code>read</code> from a file
+ descriptor which you know to have been messed with by
+ <code>ioctl</code>. This could happen, for example, if the
+ descriptor is used to read input from some kind of screen
+ handling library.
+ <p>
+ To find out if your program is blocking unexpectedly in the
+ <code>read</code> system call, run with
+ <code>--trace-syscalls=yes</code> flag.
+ </ul>
+
+ </li><p>
</ul>
There are also some options for debugging Valgrind itself. You
--suppressions=*) vgopts="$vgopts $arg"; shift;;
--cachesim=yes) vgopts="$vgopts $arg"; shift;;
--cachesim=no) vgopts="$vgopts $arg"; shift;;
+ --wierd-hacks=*) vgopts="$vgopts $arg"; shift;;
# options for debugging Valgrind
--sanity-level=*) vgopts="$vgopts $arg"; shift;;
--single-step=yes) vgopts="$vgopts $arg"; shift;;
echo " --check-addrVs=no|yes experimental lighterweight checking? [yes]"
echo " yes == Valgrind's original behaviour"
echo " --cachesim=no|yes do cache profiling? [no]"
+ echo " --wierd-hacks=hack1,hack2,... [no hacks selected]"
+ echo " recognised hacks are: ioctl-VTIME"
+ echo ""
echo
echo " options for debugging Valgrind itself are:"
echo " --sanity-level=<number> level of sanity checking to do [1]"
extern Int VG_(clo_dump_error);
/* Number of parents of a backtrace. Default: 8. */
extern Int VG_(clo_backtrace_size);
+/* Engage miscellaneous wierd hacks needed for some progs. */
+extern Char* VG_(clo_wierd_hacks);
/* ---------------------------------------------------------------------
ULong VG_(clo_stop_after);
Int VG_(clo_dump_error);
Int VG_(clo_backtrace_size);
+Char* VG_(clo_wierd_hacks);
/* This Bool is needed by wrappers in vg_clientmalloc.c to decide how
to behave. Initially we say False. */
VG_(clo_stop_after) = 1000000000000LL;
VG_(clo_dump_error) = 0;
VG_(clo_backtrace_size) = 4;
+ VG_(clo_wierd_hacks) = NULL;
eventually_logfile_fd = VG_(clo_logfile_fd);
else if (STREQ(argv[i], "--trace-pthread=all"))
VG_(clo_trace_pthread_level) = 2;
+ else if (STREQN(14, argv[i], "--wierd-hacks="))
+ VG_(clo_wierd_hacks) = &argv[i][14];
+
else if (STREQN(13, argv[i], "--stop-after="))
VG_(clo_stop_after) = VG_(atoll)(&argv[i][13]);
Char* VG_(strstr) ( const Char* haystack, Char* needle )
{
- Int n = VG_(strlen)(needle);
+ Int n;
+ if (haystack == NULL)
+ return NULL;
+ n = VG_(strlen)(needle);
while (True) {
if (haystack[0] == 0)
return NULL;
vg_assert(is_valid_tid(tid));
syscall_no = vg_waiting_fds[i].syscall_no;
switch (syscall_no) {
- case __NR_read:
+ case __NR_read:
+ /* In order to catch timeout events on fds which are
+ readable and which have been ioctl(TCSETA)'d with a
+ VTIMEout, we appear to need to ask if the fd is
+ writable, for some reason. Ask me not why. Since this
+ is strange and potentially troublesome we only do it if
+ the user asks specially. */
+ if (VG_(strstr)(VG_(clo_wierd_hacks), "ioctl-VTIME") != NULL)
+ VKI_FD_SET(fd, &writefds);
VKI_FD_SET(fd, &readfds); break;
case __NR_write:
VKI_FD_SET(fd, &writefds); break;
<li><code>--cachesim=no</code> [default]<br>
<code>--cachesim=yes</code> <p>When enabled, turns off memory
checking, and turns on cache profiling. Cache profiling is
- described in detail in <a href="#cache">Section 7</a>. </li><p>
+ described in detail in <a href="#cache">Section 7</a>.
+ </li><br><p>
+
+ <li><code>--wierd-hacks=hack1,hack2,...</code>
+ Pass 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 hacks
+ are enabled. Use with caution! Currently known hacks are:
+ <p>
+ <ul>
+ <li><code>ioctl-VTIME</code> Use this if you have a program
+ which sets readable file descriptors to have a timeout by
+ doing <code>ioctl</code> on them with a
+ <code>TCSETA</code>-style command <b>and</b> a non-zero
+ <code>VTIME</code> timeout value. This is considered
+ potentially dangerous and therefore is not engaged by
+ default, because it is (remotely) conceivable that it could
+ cause threads doing <code>read</code> to incorrectly block
+ the entire process.
+ <p>
+ You probably want to try this one if you have a program
+ which unexpectedly blocks in a <code>read</code> from a file
+ descriptor which you know to have been messed with by
+ <code>ioctl</code>. This could happen, for example, if the
+ descriptor is used to read input from some kind of screen
+ handling library.
+ <p>
+ To find out if your program is blocking unexpectedly in the
+ <code>read</code> system call, run with
+ <code>--trace-syscalls=yes</code> flag.
+ </ul>
+
+ </li><p>
</ul>
There are also some options for debugging Valgrind itself. You
<li><code>--cachesim=no</code> [default]<br>
<code>--cachesim=yes</code> <p>When enabled, turns off memory
checking, and turns on cache profiling. Cache profiling is
- described in detail in <a href="#cache">Section 7</a>. </li><p>
+ described in detail in <a href="#cache">Section 7</a>.
+ </li><br><p>
+
+ <li><code>--wierd-hacks=hack1,hack2,...</code>
+ Pass 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 hacks
+ are enabled. Use with caution! Currently known hacks are:
+ <p>
+ <ul>
+ <li><code>ioctl-VTIME</code> Use this if you have a program
+ which sets readable file descriptors to have a timeout by
+ doing <code>ioctl</code> on them with a
+ <code>TCSETA</code>-style command <b>and</b> a non-zero
+ <code>VTIME</code> timeout value. This is considered
+ potentially dangerous and therefore is not engaged by
+ default, because it is (remotely) conceivable that it could
+ cause threads doing <code>read</code> to incorrectly block
+ the entire process.
+ <p>
+ You probably want to try this one if you have a program
+ which unexpectedly blocks in a <code>read</code> from a file
+ descriptor which you know to have been messed with by
+ <code>ioctl</code>. This could happen, for example, if the
+ descriptor is used to read input from some kind of screen
+ handling library.
+ <p>
+ To find out if your program is blocking unexpectedly in the
+ <code>read</code> system call, run with
+ <code>--trace-syscalls=yes</code> flag.
+ </ul>
+
+ </li><p>
</ul>
There are also some options for debugging Valgrind itself. You
--suppressions=*) vgopts="$vgopts $arg"; shift;;
--cachesim=yes) vgopts="$vgopts $arg"; shift;;
--cachesim=no) vgopts="$vgopts $arg"; shift;;
+ --wierd-hacks=*) vgopts="$vgopts $arg"; shift;;
# options for debugging Valgrind
--sanity-level=*) vgopts="$vgopts $arg"; shift;;
--single-step=yes) vgopts="$vgopts $arg"; shift;;
echo " --check-addrVs=no|yes experimental lighterweight checking? [yes]"
echo " yes == Valgrind's original behaviour"
echo " --cachesim=no|yes do cache profiling? [no]"
+ echo " --wierd-hacks=hack1,hack2,... [no hacks selected]"
+ echo " recognised hacks are: ioctl-VTIME"
+ echo ""
echo
echo " options for debugging Valgrind itself are:"
echo " --sanity-level=<number> level of sanity checking to do [1]"
extern Int VG_(clo_dump_error);
/* Number of parents of a backtrace. Default: 8. */
extern Int VG_(clo_backtrace_size);
+/* Engage miscellaneous wierd hacks needed for some progs. */
+extern Char* VG_(clo_wierd_hacks);
/* ---------------------------------------------------------------------
ULong VG_(clo_stop_after);
Int VG_(clo_dump_error);
Int VG_(clo_backtrace_size);
+Char* VG_(clo_wierd_hacks);
/* This Bool is needed by wrappers in vg_clientmalloc.c to decide how
to behave. Initially we say False. */
VG_(clo_stop_after) = 1000000000000LL;
VG_(clo_dump_error) = 0;
VG_(clo_backtrace_size) = 4;
+ VG_(clo_wierd_hacks) = NULL;
eventually_logfile_fd = VG_(clo_logfile_fd);
else if (STREQ(argv[i], "--trace-pthread=all"))
VG_(clo_trace_pthread_level) = 2;
+ else if (STREQN(14, argv[i], "--wierd-hacks="))
+ VG_(clo_wierd_hacks) = &argv[i][14];
+
else if (STREQN(13, argv[i], "--stop-after="))
VG_(clo_stop_after) = VG_(atoll)(&argv[i][13]);
Char* VG_(strstr) ( const Char* haystack, Char* needle )
{
- Int n = VG_(strlen)(needle);
+ Int n;
+ if (haystack == NULL)
+ return NULL;
+ n = VG_(strlen)(needle);
while (True) {
if (haystack[0] == 0)
return NULL;
vg_assert(is_valid_tid(tid));
syscall_no = vg_waiting_fds[i].syscall_no;
switch (syscall_no) {
- case __NR_read:
+ case __NR_read:
+ /* In order to catch timeout events on fds which are
+ readable and which have been ioctl(TCSETA)'d with a
+ VTIMEout, we appear to need to ask if the fd is
+ writable, for some reason. Ask me not why. Since this
+ is strange and potentially troublesome we only do it if
+ the user asks specially. */
+ if (VG_(strstr)(VG_(clo_wierd_hacks), "ioctl-VTIME") != NULL)
+ VKI_FD_SET(fd, &writefds);
VKI_FD_SET(fd, &readfds); break;
case __NR_write:
VKI_FD_SET(fd, &writefds); break;