Fixes BZ#385939.
Slightly modified patch by: Fauchet Gauthier <gauthier.fauchet@free.fr>
385334 PPC64, fix vpermr, xxperm, xxpermr mask value.
385868 glibc ld.so _dl_runtime_resolve_avx_slow conditional jump warning.
385912 none/tests/rlimit_nofile fails on newer glibc/kernel.
+385939 Optionally exit on the first error
386397 PPC64, valgrind truncates powerpc timebase to 32-bits.
n-i-bz Fix missing workq_ops operations (macOS)
}
-/* Do text-mode actions on error, that is, immediately after an error
- is printed. These are:
+/* Do actions on error, that is, immediately after an error is printed.
+ These are:
* possibly, call the GDB server
* possibly, generate a suppression.
- Note this should not be called in XML mode!
*/
static
void do_actions_on_error(const Error* err, Bool allow_db_attach)
}
if (VG_(clo_gen_suppressions) == 1 && !still_noisy)
VG_(clo_gen_suppressions) = 0;
+
+ if (VG_(clo_exit_on_first_error)) {
+ if (VG_(clo_xml))
+ VG_(printf_xml)("</valgrindoutput>\n");
+ VG_(umsg)("\n");
+ VG_(umsg)("Exit program on first error (--exit-on-first-error=yes)\n");
+ VG_(client_exit)( VG_(clo_error_exitcode) );
+ }
}
* prints the tool-specific parts of the message
+ In both modes:
+
* calls do_actions_on_error. This optionally does a gdbserver call
and optionally prints a suppression; both of these may require user input.
*/
" --demangle=no|yes automatically demangle C++ names? [yes]\n"
" --num-callers=<number> show <number> callers in stack traces [12]\n"
" --error-limit=no|yes stop showing new errors if too many? [yes]\n"
+" --exit-on-first-error=no|yes exit code on the first error found? [no]\n"
" --error-exitcode=<number> exit code to return if errors found [0=disable]\n"
" --error-markers=<begin>,<end> add lines with begin/end markers before/after\n"
" each error output in plain text mode [none]\n"
" --core-redzone-size=<number> set minimum size of redzones added before/after\n"
" heap blocks allocated for Valgrind internal use (in bytes) [4]\n"
" --wait-for-gdb=yes|no pause on startup to wait for gdb attach\n"
-" --sym-offsets=yes|no show syms in form 'name+offset' ? [no]\n"
+" --sym-offsets=yes|no show syms in form 'name+offset'? [no]\n"
" --command-line-only=no|yes only use command line options [no]\n"
"\n"
" Vex options for all Valgrind tools:\n"
else if VG_BOOL_CLO(arg, "--demangle", VG_(clo_demangle)) {}
else if VG_STR_CLO (arg, "--soname-synonyms",VG_(clo_soname_synonyms)) {}
else if VG_BOOL_CLO(arg, "--error-limit", VG_(clo_error_limit)) {}
+ else if VG_BOOL_CLO(arg, "--exit-on-first-error", VG_(clo_exit_on_first_error)) {}
else if VG_INT_CLO (arg, "--error-exitcode", VG_(clo_error_exitcode)) {}
else if VG_STR_CLO (arg, "--error-markers", tmp_str) {
Int m;
"Can't use --gen-suppressions= with %s\n"
"because it doesn't generate errors.\n", VG_(details).name);
}
+ if ((VG_(clo_exit_on_first_error)) &&
+ (VG_(clo_error_exitcode)==0)) {
+ VG_(fmsg_bad_option)("--exit-on-first-error=yes",
+ "You must define a non nul exit error code, with --error-exitcode=...\n");
+ }
# if !defined(VGO_darwin)
if (VG_(clo_resync_filter) != 0) {
Bool VG_(clo_error_limit) = True;
Int VG_(clo_error_exitcode) = 0;
HChar *VG_(clo_error_markers)[2] = {NULL, NULL};
+Bool VG_(clo_exit_on_first_error) = False;
#if defined(VGPV_arm_linux_android) \
|| defined(VGPV_x86_linux_android) \
/* Should we stop collecting errors if too many appear? default: YES */
extern Bool VG_(clo_error_limit);
+/* Should we exit if an error appears? default: NO */
+extern Bool VG_(clo_exit_on_first_error);
/* Alternative exit code to hand to parent if errors were found.
default: 0 (no, return the application's exit code in the normal
way. */
</listitem>
</varlistentry>
+ <varlistentry id="opt.exit-on-first-error" xreflabel="--exit-on-first-error">
+ <term>
+ <option><![CDATA[--exit-on-first-error=<yes|no> [default: no] ]]></option>
+ </term>
+ <listitem>
+ <para>If this option is enabled, Valgrind exits on the first error.
+ A nonzero exit value must be defined using
+ <computeroutput>--error-exitcode</computeroutput> option.
+ Useful if you are running regression tests or have some other
+ automated test machinery.</para>
+ </listitem>
+ </varlistentry>
+
<varlistentry id="opt.error-markers" xreflabel="--error-markers">
<term>
<option><![CDATA[--error-markers=<begin>,<end> [default: none]]]></option>
atomic_incs.stdout.exp-32bit atomic_incs.stdout.exp-64bit \
badaddrvalue.stderr.exp \
badaddrvalue.stdout.exp badaddrvalue.vgtest \
+ exit_on_first_error.stderr.exp \
+ exit_on_first_error.vgtest \
+ exit_on_first_error_with_xml.stderr.exp \
+ exit_on_first_error_with_xml.vgtest \
badfree-2trace.stderr.exp badfree-2trace.vgtest \
badfree.stderr.exp badfree.vgtest \
badfree3.stderr.exp badfree3.vgtest \
--- /dev/null
+
+Invalid write of size 1
+ ...
+ Address 0x........ is 1 bytes before a block of size 8 alloc'd
+ at 0x........: malloc (vg_replace_malloc.c:...)
+ ...
+
+
+Exit program on first error (--exit-on-first-error=yes)
--- /dev/null
+prog: badaddrvalue
+vgopts: --exit-on-first-error=yes --error-exitcode=3
--- /dev/null
+<?xml version="1.0"?>
+
+<valgrindoutput>
+
+<protocolversion>4</protocolversion>
+<protocoltool>memcheck</protocoltool>
+
+<preamble>
+ <line>...</line>
+ <line>...</line>
+ <line>...</line>
+ <line>...</line>
+</preamble>
+
+<pid>...</pid>
+<ppid>...</ppid>
+<tool>memcheck</tool>
+
+<args>
+ <vargv>...</vargv>
+ <argv>
+ <exe>./badaddrvalue</exe>
+ </argv>
+</args>
+
+<status>
+ <state>RUNNING</state>
+ <time>...</time>
+</status>
+
+<error>
+ <unique>0x........</unique>
+ <tid>...</tid>
+ <kind>InvalidWrite</kind>
+ <what>Invalid write of size 1</what>
+ <stack>
+ <frame>
+ <ip>0x........</ip>
+ <obj>...</obj>
+ <fn>main</fn>
+ <dir>...</dir>
+ <file>badaddrvalue.c</file>
+ <line>...</line>
+ </frame>
+ </stack>
+ <auxwhat>Address 0x........ is 1 bytes before a block of size 8 alloc'd</auxwhat>
+ <stack>
+ <frame>
+ <ip>0x........</ip>
+ <obj>...</obj>
+ <fn>malloc</fn>
+ <dir>...</dir>
+ <file>vg_replace_malloc.c</file>
+ <line>...</line>
+ </frame>
+ <frame>
+ <ip>0x........</ip>
+ <obj>...</obj>
+ <fn>main</fn>
+ <dir>...</dir>
+ <file>badaddrvalue.c</file>
+ <line>...</line>
+ </frame>
+ </stack>
+</error>
+
+</valgrindoutput>
--- /dev/null
+prog: badaddrvalue
+vgopts: --exit-on-first-error=yes --error-exitcode=3 --xml=yes --xml-fd=2 --log-file=/dev/null
+stderr_filter: filter_xml
+
--demangle=no|yes automatically demangle C++ names? [yes]
--num-callers=<number> show <number> callers in stack traces [12]
--error-limit=no|yes stop showing new errors if too many? [yes]
+ --exit-on-first-error=no|yes exit code on the first error found? [no]
--error-exitcode=<number> exit code to return if errors found [0=disable]
--error-markers=<begin>,<end> add lines with begin/end markers before/after
each error output in plain text mode [none]
--demangle=no|yes automatically demangle C++ names? [yes]
--num-callers=<number> show <number> callers in stack traces [12]
--error-limit=no|yes stop showing new errors if too many? [yes]
+ --exit-on-first-error=no|yes exit code on the first error found? [no]
--error-exitcode=<number> exit code to return if errors found [0=disable]
--error-markers=<begin>,<end> add lines with begin/end markers before/after
each error output in plain text mode [none]
--core-redzone-size=<number> set minimum size of redzones added before/after
heap blocks allocated for Valgrind internal use (in bytes) [4]
--wait-for-gdb=yes|no pause on startup to wait for gdb attach
- --sym-offsets=yes|no show syms in form 'name+offset' ? [no]
+ --sym-offsets=yes|no show syms in form 'name+offset'? [no]
--command-line-only=no|yes only use command line options [no]
Vex options for all Valgrind tools: