]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Implement Option --error-markers=<begin>,<end>
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Wed, 12 Nov 2014 19:43:29 +0000 (19:43 +0000)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Wed, 12 Nov 2014 19:43:29 +0000 (19:43 +0000)
* This option can be used to mark the begin/end of errors in textual
output mode, to facilitate searching/extracting errors in output files
mixing valgrind errors with program output.

* Use the new option in various existing regtests to test the various
  possible usage.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14714

16 files changed:
NEWS
coregrind/m_errormgr.c
coregrind/m_main.c
coregrind/m_options.c
coregrind/pub_core_options.h
docs/xml/manual-core.xml
memcheck/tests/badaddrvalue.stderr.exp
memcheck/tests/badaddrvalue.vgtest
memcheck/tests/manuel1.stderr.exp
memcheck/tests/manuel1.vgtest
memcheck/tests/manuel2.stderr.exp
memcheck/tests/manuel2.stderr.exp64
memcheck/tests/manuel2.vgtest
memcheck/tests/manuel3.vgtest
none/tests/cmdline1.stdout.exp
none/tests/cmdline2.stdout.exp

diff --git a/NEWS b/NEWS
index 4bcf9293e7084a3c0f275d96ff8c3dbc100c8dcf..b6f36d7e1b0377ef24f4888c33243522e9c1d552 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,11 @@ Release 3.11.0 is under development, not yet released.
 
 * ==================== OTHER CHANGES ====================
 
+* Option --error-markers=<begin>,<end> can be used to mark
+  the begin/end of errors in textual output mode, to facilitate
+  searching/extracting errors in output files mixing valgrind
+  errors with program output.
+
 * ==================== FIXED BUGS ====================
 
 The following bugs have been fixed or resolved.  Note that "n-i-bz"
index 7a801f59bd8b8b253147287064d7c753bcf23994..b00d9e77d8a28ddce6d8c8de35641b40b69f8bd1 100644 (file)
@@ -626,6 +626,8 @@ static void pp_Error ( const Error* err, Bool allow_db_attach, Bool xml )
 
    } else {
 
+      if (VG_(clo_error_markers)[0])
+         VG_(umsg)("%s\n", VG_(clo_error_markers)[0]);
       VG_TDICT_CALL( tool_before_pp_Error, err );
 
       if (VG_(tdict).tool_show_ThreadIDs_for_errors
@@ -641,6 +643,8 @@ static void pp_Error ( const Error* err, Bool allow_db_attach, Bool xml )
    
       VG_TDICT_CALL( tool_pp_Error, err );
       VG_(umsg)("\n");
+      if (VG_(clo_error_markers)[1])
+         VG_(umsg)("%s\n", VG_(clo_error_markers)[1]);
 
       do_actions_on_error(err, allow_db_attach);
    }
index c61f19de134c7a9ffc4a5e1a9a87a886507b8ca4..403955870f024b805d1bd62273f9c1fb81615ff0 100644 (file)
@@ -127,6 +127,8 @@ static void usage_NORETURN ( Bool debug_help )
 "    --num-callers=<number>    show <number> callers in stack traces [12]\n"
 "    --error-limit=no|yes      stop showing new errors if too many? [yes]\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"
 "    --show-below-main=no|yes  continue stack traces below main() [no]\n"
 "    --default-suppressions=yes|no\n"
 "                              load default suppressions [yes]\n"
@@ -580,6 +582,31 @@ void main_process_cmd_line_options ( /*OUT*/Bool* logging_to_fd,
       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_INT_CLO (arg, "--error-exitcode", VG_(clo_error_exitcode)) {}
+      else if VG_STR_CLO (arg, "--error-markers",  tmp_str) {
+         Int m;
+         const HChar *startpos = tmp_str;
+         const HChar *nextpos;
+         for (m = 0; 
+              m < sizeof(VG_(clo_error_markers))
+                 /sizeof(VG_(clo_error_markers)[0]);
+              m++) {
+            /* Release previous value if clo given multiple times. */
+            VG_(free)(VG_(clo_error_markers)[m]);
+            VG_(clo_error_markers)[m] = NULL;
+
+            nextpos = VG_(strchr)(startpos, ',');
+            if (!nextpos)
+               nextpos = startpos + VG_(strlen)(startpos);
+            if (startpos != nextpos) {
+               VG_(clo_error_markers)[m] 
+                  = VG_(malloc)("", nextpos - startpos + 1);
+               VG_(memcpy)(VG_(clo_error_markers)[m], startpos, 
+                           nextpos - startpos);
+               VG_(clo_error_markers)[m][nextpos - startpos] = '\0';
+            }
+            startpos = *nextpos ? nextpos + 1 : nextpos;
+         }
+      }
       else if VG_BOOL_CLO(arg, "--show-emwarns",   VG_(clo_show_emwarns)) {}
 
       else if VG_BOOL_CLO(arg, "--run-libc-freeres", VG_(clo_run_libc_freeres)) {}
index 6c1d1bfa1ce91e55da403cd7ce1bece104f478b1..5284f2552f336929d0a39f4384a155f2d8141a7e 100644 (file)
@@ -46,6 +46,7 @@
 VexControl VG_(clo_vex_control);
 Bool   VG_(clo_error_limit)    = True;
 Int    VG_(clo_error_exitcode) = 0;
+HChar *VG_(clo_error_markers)[2] = {NULL, NULL};
 
 #if defined(VGPV_arm_linux_android) \
     || defined(VGPV_x86_linux_android) \
index de2adf24c13edf0ad05c8216bdee2ece365ffe65..1b49554161f019dd52ffe27d50f78bbcd807e8fa 100644 (file)
@@ -46,6 +46,12 @@ extern Bool  VG_(clo_error_limit);
    way. */
 extern Int   VG_(clo_error_exitcode);
 
+/* Markers used to mark the begin/end of an error, when errors are
+   printed in textual (non xml) format.
+   [0] is the error begin marker, [1] is the error end marker.
+   default: no markers. */
+extern HChar *VG_(clo_error_markers)[2];
+
 typedef 
    enum { 
       Vg_VgdbNo,   // Do not activate gdbserver.
index 55c831af68af553bdb5b0d0e27d27c54e8c74358..f11e9b166b09e347c1dbf681b32f0eb57ff930c3 100644 (file)
@@ -1160,6 +1160,23 @@ that can report errors, e.g. Memcheck, but not Cachegrind.</para>
     </listitem>
   </varlistentry>
 
+  <varlistentry id="opt.error-markers" xreflabel="--error-markers">
+    <term>
+      <option><![CDATA[--error-markers=<begin>,<end> [default: none]]]></option>
+    </term>
+    <listitem>
+      <para>When errors are output as plain text (i.e. XML not used),
+      <option>--error-markers</option> instructs to output a line
+      containing the <option>begin</option> (<option>end</option>)
+      string before (after) each error. </para>
+      <para> Such marker lines facilitate searching for errors and/or
+      extracting errors in an output file that contain valgrind errors mixed
+      with the program output. </para>
+      <para> Note that empty markers are accepted. So, only using a begin
+      (or an end) marker is possible.</para>
+    </listitem>
+  </varlistentry>
+
   <varlistentry id="opt.sigill-diagnostics" xreflabel="--sigill-diagnostics">
     <term>
       <option><![CDATA[--sigill-diagnostics=<yes|no> [default: yes] ]]></option>
index 7d2407e29feb061a12708c6079d664df4b17bb1b..fced525b76d20b430761915382da6bad2ad4b849 100644 (file)
@@ -1,12 +1,16 @@
+[[[
 Invalid write of size 1
    at 0x........: main (badaddrvalue.c:8)
  Address 0x........ is 1 bytes before a block of size 8 alloc'd
    at 0x........: malloc (vg_replace_malloc.c:...)
    by 0x........: main (badaddrvalue.c:7)
 
+]]]
+[[[
 Invalid read of size 1
    at 0x........: main (badaddrvalue.c:9)
  Address 0x........ is 1 bytes before a block of size 8 alloc'd
    at 0x........: malloc (vg_replace_malloc.c:...)
    by 0x........: main (badaddrvalue.c:7)
 
+]]]
index 4d4b7f68060a90de60bcfbf9161d0bd7315452b1..f58e9608a5983fba5b84c28a7718af2d27bd6ade 100644 (file)
@@ -1,2 +1,2 @@
 prog: badaddrvalue
-vgopts: -q
+vgopts: -q --error-markers=[[[,]]]
index f55ce0b646757e214e23e0d8d230220f4e41a123..3e825da3b649009c09bc5bae7fe5fef9b8bcec18 100644 (file)
@@ -1,3 +1,4 @@
+[[[
 Conditional jump or move depends on uninitialised value(s)
    at 0x........: main (manuel1.c:7)
 
index 853f8dfdbcee8f9f9a7466d328f5c64d1e19cf71..5590b0f29af69ca253d059d698bbc75daac51670 100644 (file)
@@ -1,2 +1,2 @@
 prog: manuel1
-vgopts: -q
+vgopts: -q --error-markers=[[[
index a9d575d0f4008db78749ea3f9b3863d67774b216..7a29c11ee39063832c1b94c36da34fd91906f24b 100644 (file)
@@ -1,3 +1,4 @@
 Use of uninitialised value of size 4
    at 0x........: main (manuel2.c:10)
 
+]]]
index 5bc75f510e458e0a0b99a8bec81171a5af81cee8..3fe5e52aeaa64db1b39615ed01b9e6d1f80a2865 100644 (file)
@@ -1,3 +1,4 @@
 Use of uninitialised value of size 8
    at 0x........: main (manuel2.c:10)
 
+]]]
index b3729b1663da75898c3e424af5a7807eb0df93f2..e51fae500301f016757782397fd54fb6fcb63151 100644 (file)
@@ -1,2 +1,2 @@
 prog: manuel2
-vgopts: -q
+vgopts: -q --error-markers=,]]]
index 14e5f24f34102b4d5db8d3b588534c1c73395d30..c78543599122c87a7ff45c77305c49ca00157a2d 100644 (file)
@@ -1,2 +1,2 @@
 prog: manuel3
-vgopts: -q
+vgopts: -q --error-markers=,
index 3837816ccb229bad983c3ff1c23458364b2efe13..8367d4ebbaf22c9a02ad7cefd15b609e4f44540d 100644 (file)
@@ -40,6 +40,8 @@ usage: valgrind [options] prog-and-args
     --num-callers=<number>    show <number> callers in stack traces [12]
     --error-limit=no|yes      stop showing new errors if too many? [yes]
     --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]
     --show-below-main=no|yes  continue stack traces below main() [no]
     --default-suppressions=yes|no
                               load default suppressions [yes]
index 72b25066c01ca3347e60c0cd9fcfc2de5eb92b13..bccb28d9617784185ee513d0e9745848d4648194 100644 (file)
@@ -40,6 +40,8 @@ usage: valgrind [options] prog-and-args
     --num-callers=<number>    show <number> callers in stack traces [12]
     --error-limit=no|yes      stop showing new errors if too many? [yes]
     --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]
     --show-below-main=no|yes  continue stack traces below main() [no]
     --default-suppressions=yes|no
                               load default suppressions [yes]