|
From: <sv...@va...> - 2006-05-12 23:50:18
|
Author: sewardj
Date: 2006-05-13 00:50:15 +0100 (Sat, 13 May 2006)
New Revision: 5897
Log:
A new flag, --error-exitcode=3D, has been added, to allow changing the
exit code in runs where Valgrind reported errors. Fixes #121814 and
#126517.
Modified:
trunk/NEWS
trunk/coregrind/m_main.c
trunk/coregrind/m_options.c
trunk/coregrind/pub_core_options.h
trunk/docs/xml/manual-core.xml
Modified: trunk/NEWS
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/NEWS 2006-05-12 23:35:10 UTC (rev 5896)
+++ trunk/NEWS 2006-05-12 23:50:15 UTC (rev 5897)
@@ -67,6 +67,10 @@
functions, and will carefully check data passed to the (P)MPI_
interface.
=20
+- A new flag, --error-exitcode=3D, has been added. This allows changing=
the
+ exit code in runs where Valgrind reported errors, which is useful when
+ using Valgrind as part of an automated test suite.
+
- XXX: others...
=20
Please note that Helgrind is still not working. We have made an importa=
nt
Modified: trunk/coregrind/m_main.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_main.c 2006-05-12 23:35:10 UTC (rev 5896)
+++ trunk/coregrind/m_main.c 2006-05-12 23:50:15 UTC (rev 5897)
@@ -917,6 +917,7 @@
" --demangle=3Dno|yes automatically demangle C++ names? [yes]=
\n"
" --num-callers=3D<number> show <number> callers in stack traces [=
12]\n"
" --error-limit=3Dno|yes stop showing new errors if too many? [y=
es]\n"
+" --error-exitcode=3D<number> exit code to return if errors found [0=3D=
disable]\n"
" --show-below-main=3Dno|yes continue stack traces below main() [no]=
\n"
" --suppressions=3D<filename> suppress errors described in <filename>=
\n"
" --gen-suppressions=3Dno|yes|all print suppressions for errors? [=
no]\n"
@@ -1117,6 +1118,7 @@
else VG_BOOL_CLO(arg, "--db-attach", VG_(clo_db_attach))
else VG_BOOL_CLO(arg, "--demangle", VG_(clo_demangle))
else VG_BOOL_CLO(arg, "--error-limit", VG_(clo_error_limit))
+ else VG_NUM_CLO (arg, "--error-exitcode", VG_(clo_error_exitcode=
))
else VG_BOOL_CLO(arg, "--show-emwarns", VG_(clo_show_emwarns))
else VG_NUM_CLO (arg, "--max-stackframe", VG_(clo_max_stackframe=
))
else VG_BOOL_CLO(arg, "--run-libc-freeres", VG_(clo_run_libc_freer=
es))
@@ -2685,7 +2687,16 @@
=20
switch (tids_schedretcode) {
case VgSrc_ExitSyscall: /* the normal way out */
- VG_(exit)( VG_(threads)[tid].os_state.exitcode );
+ /* Change the application return code to user's return code,
+ if an error was found */
+ if (VG_(clo_error_exitcode) > 0=20
+ && VG_(get_n_errs_found)() > 0) {
+ VG_(exit)( VG_(clo_error_exitcode) );
+ } else {
+ /* otherwise, return the client's exit code, in the normal
+ way. */
+ VG_(exit)( VG_(threads)[tid].os_state.exitcode );
+ }
/* NOT ALIVE HERE! */
VG_(core_panic)("entered the afterlife in main() -- ExitSyscall");
break; /* what the hell :) */
Modified: trunk/coregrind/m_options.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_options.c 2006-05-12 23:35:10 UTC (rev 5896)
+++ trunk/coregrind/m_options.c 2006-05-12 23:50:15 UTC (rev 5897)
@@ -38,6 +38,7 @@
/* Define, and set defaults. */
VexControl VG_(clo_vex_control);
Bool VG_(clo_error_limit) =3D True;
+Int VG_(clo_error_exitcode) =3D 0;
Bool VG_(clo_db_attach) =3D False;
Char* VG_(clo_db_command) =3D GDB_PATH " -nw %f %p";
Int VG_(clo_gen_suppressions) =3D 0;
Modified: trunk/coregrind/pub_core_options.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/pub_core_options.h 2006-05-12 23:35:10 UTC (rev 5896)
+++ trunk/coregrind/pub_core_options.h 2006-05-12 23:50:15 UTC (rev 5897)
@@ -44,13 +44,17 @@
=20
/* Should we stop collecting errors if too many appear? default: YES */
extern Bool VG_(clo_error_limit);
+/* Alternative exit code to hand to parent if errors were found.
+ default: 0 (no, return the application's exit code in the normal
+ way. */
+extern Int VG_(clo_error_exitcode);
/* Enquire about whether to attach to a debugger at errors? default: N=
O */
extern Bool VG_(clo_db_attach);
/* The debugger command? default: whatever gdb ./configure found */
extern Char* VG_(clo_db_command);
/* Generating a suppression for each error? default: 0 (NO)
Other values: 1 (yes, but ask user), 2 (yes, don't ask user) */
-extern Int VG_(clo_gen_suppressions);
+extern Int VG_(clo_gen_suppressions);
/* Sanity-check level: 0 =3D none, 1 (default), > 1 =3D expensive. */
extern Int VG_(clo_sanity_level);
/* Automatically attempt to demangle C++ names? default: YES */
Modified: trunk/docs/xml/manual-core.xml
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/docs/xml/manual-core.xml 2006-05-12 23:35:10 UTC (rev 5896)
+++ trunk/docs/xml/manual-core.xml 2006-05-12 23:50:15 UTC (rev 5897)
@@ -834,6 +834,22 @@
</listitem>
</varlistentry>
=20
+ <varlistentry id=3D"opt.error-exitcode" xreflabel=3D"--error-exitcode"=
>
+ <term>
+ <option><![CDATA[--error-exitcode=3D<number> [default: 0] ]]></opt=
ion>
+ </term>
+ <listitem>
+ <para>Specifies 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=20
+ 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.</pa=
ra>
+ </listitem>
+ </varlistentry>
+
<varlistentry id=3D"opt.stack-traces" xreflabel=3D"--show-below-main">
<term>
<option><![CDATA[--show-below-main=3D<yes|no> [default: no] ]]></o=
ption>
|