]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Allow to see more details about suppressed errors.
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Sun, 14 Apr 2024 13:35:16 +0000 (15:35 +0200)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Sun, 14 Apr 2024 13:39:06 +0000 (15:39 +0200)
Extend --show-error-list=no|yes with all to allow to look also the
list of suppressed errors and see which supp entry is suppressing it.
Add an option also_suppressed in the monitor command 'c.vinfo all_errors'
to similarly be able to show the suppressed errors.

Small fix in check_makefile_consistency: avoid it considers emacs ~ files.

15 files changed:
NEWS
coregrind/m_errormgr.c
coregrind/m_gdbserver/server.c
coregrind/m_gdbserver/valgrind-monitor-def.py
coregrind/m_main.c
coregrind/m_options.c
coregrind/pub_core_errormgr.h
coregrind/pub_core_options.h
docs/xml/manual-core-adv.xml
docs/xml/manual-core.xml
gdbserver_tests/mchelp.stdoutB.exp
gdbserver_tests/mssnapshot.stderrB.exp
none/tests/cmdline1.stdout.exp
none/tests/cmdline2.stdout.exp
tests/check_makefile_consistency

diff --git a/NEWS b/NEWS
index 1a62b321bd0eae7456175af7263a977f327f83eb..705e17be238125f405d43856229209b57694d5f5 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,14 @@ AMD64/macOS 10.13 and nanoMIPS/Linux.
   descriptors. Printing the context where the file descriptor was
   originally opened and where it was previously closed.
 
+* The option --show-error-list=no|yes now accepts a new value all.
+  This indicates to also print the suppressed errors.
+  This is useful to analyse which errors are suppressed by which
+  suppression entries.
+  The valgrind monitor command 'v.info all_errors' similarly now
+  accepts a new optional argument 'also_suppressed' to show
+  all errors including the suppressed errors.
+
 * ================== PLATFORM CHANGES =================
 
 * ==================== TOOL CHANGES ===================
index 40e36d162d6c74071277eb995dfaa0de7f33e042..3f8aa31b7f66dd240a435c297559a1c8b9904bb8 100644 (file)
@@ -973,21 +973,20 @@ static Bool show_used_suppressions ( void )
    return any_supp;
 }
 
-/* Show all the errors that occurred, and possibly also the
-   suppressions used. */
-void VG_(show_all_errors) (  Int verbosity, Bool xml )
+/* See pub_core_errormgr.h. */
+void VG_(show_all_errors) (  Int verbosity, Bool xml, Int show_error_list)
 {
-   Int    i, n_min;
+   Int    i, n_min, n_errs;
    Error *p, *p_min;
    Bool   any_supp;
    Bool   any_error = False;
 
-   if (verbosity == 0 && !VG_(clo_show_error_list))
+   if (verbosity == 0 && show_error_list == 0)
       return;
 
    /* If we're printing XML, just show the suppressions and stop. */
    if (xml) {
-      if (VG_(clo_show_error_list))
+      if (show_error_list > 0)
          (void)show_used_suppressions();
       return;
    }
@@ -998,21 +997,25 @@ void VG_(show_all_errors) (  Int verbosity, Bool xml )
              n_errs_found, n_err_contexts,
              n_errs_suppressed, n_supp_contexts );
 
-   if (!VG_(clo_show_error_list))
+   if (show_error_list == 0)
       return;
 
-   // We do the following if VG_(clo_show_error_list)
+   // We do the following if show_error_list > 0
    // or at -v or above, and only in non-XML mode.
 
    /* Print the contexts in order of increasing error count.
+      The below implements this in a quadratic algorithm based on the assumption
+      that there are not too many errors (including the suppressed if showing
+      the suppressed errors) !
       Once an error is shown, we add a huge value to its count to filter it
       out.
       After having shown all errors, we reset count to the original value. */
-   for (i = 0; i < n_err_contexts; i++) {
+   n_errs = n_err_contexts + (show_error_list < 2 ? 0 : n_errs_suppressed);
+   for (i = 0; i < n_errs; i++) {
       n_min = (1 << 30) - 1;
       p_min = NULL;
       for (p = errors; p != NULL; p = p->next) {
-         if (p->supp != NULL) continue;
+         if (show_error_list < 2 && p->supp != NULL) continue;
          if (p->count < n_min) {
             n_min = p->count;
             p_min = p;
@@ -1023,8 +1026,12 @@ void VG_(show_all_errors) (  Int verbosity, Bool xml )
 
       any_error = True;
       VG_(umsg)("\n");
-      VG_(umsg)("%d errors in context %d of %u:\n",
-                p_min->count, i+1, n_err_contexts);
+      VG_(umsg)("%d errors%s%s%s in context %d of %u:\n",
+                p_min->count,
+                p_min->supp == NULL ? "" : " (suppressed by ",
+                p_min->supp == NULL ? "" : p_min->supp->sname,
+                p_min->supp == NULL ? "" : ")",
+                i+1, n_errs);
       pp_Error( p_min, False/*allow_db_attach*/, False /* xml */, True /* count_error */ );
 
       // We're not printing XML -- we'd have exited above if so.
index 83825408ae581bf38fafc709f253ae0942a84764..8ca4de20f6db28d52506a35188a5eb22c6d9ff16 100644 (file)
@@ -230,7 +230,7 @@ int handle_gdb_valgrind_command (char *mon, OutputSink *sink_wanted_at_return)
 "general valgrind monitor commands:\n"
 "  help [debug]            : monitor command help. With debug: + debugging commands\n"
 "  v.wait [<ms>]           : sleep <ms> (default 0) then continue\n"
-"  v.info all_errors       : show all errors found so far\n"
+"  v.info all_errors [also_suppressed] : show all errors found so far\n"
 "  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"
@@ -375,9 +375,23 @@ int handle_gdb_valgrind_command (char *mon, OutputSink *sink_wanted_at_return)
       case -1:
          break;
       case 0: // all_errors
+      {
+         Int show_error_list = 1;
+         wcmd = strtok_r (NULL, " ", &ssaveptr);
+         if (wcmd != NULL) {
+            switch (VG_(keyword_id) ("also_suppressed", wcmd, kwd_report_all)) {
+            case -2:
+            case -1: break;
+            case  0:
+               show_error_list = 2;
+               break;
+            default: vg_assert (0);
+            }
+         }
          // A verbosity of minimum 2 is needed to show the errors.
-         VG_(show_all_errors)(/* verbosity */ 2, /* xml */ False);
-         break;
+         VG_(show_all_errors)(/* verbosity */ 2, /* xml */ False, show_error_list);
+      }
+      break;
       case  1: // n_errs_found
          VG_(printf) ("n_errs_found %u n_errs_shown %u (vgdb-error %d) %s\n",
                       VG_(get_n_errs_found) (),
index d74b1590cc125852b07e26ebcfbb2bcd5b014815..bb9a83c3335cb0ac2088f919ac4c481d08e010d9 100644 (file)
@@ -287,12 +287,18 @@ WHAT is the v.info subcommand, specifying the type of information requested.
 ARG are optional arguments, depending on the WHAT subcommand.
 """
 
-@Vinit("valgrind", "v.info all_errors", gdb.COMMAND_STATUS, gdb.COMPLETE_NONE, False)
+@Vinit("valgrind", "v.info all_errors", gdb.COMMAND_STATUS, gdb.COMPLETE_NONE, True)
 class Valgrind_Info_All_Errors_Command(Valgrind_Command):
     """Show all errors found so far by Valgrind.
 Usage: valgrind v.info all_errors
 """
 
+@Vinit("valgrind", "v.info all_errors also_suppressed", gdb.COMMAND_STATUS, gdb.COMPLETE_NONE, False)
+class Valgrind_Info_All_Errors_Also_Suppressed_Command(Valgrind_Command):
+    """Show all errors found so far by Valgrind, including the suppressed errors.
+Usage: valgrind v.info all_errors also_suppressed
+"""
+
 @Vinit("valgrind", "v.info last_error", gdb.COMMAND_STATUS, gdb.COMPLETE_NONE, False)
 class Valgrind_Info_Last_Error_Command(Valgrind_Command):
     """Show last error found by Valgrind.
index 10b2d9be97d035ea5f67ff9bd970caffe7bad806..7ff57ce6631bb3c35d63da92c9f82eef8e235313 100644 (file)
@@ -137,8 +137,9 @@ static void usage_NORETURN ( int need_help )
 "    --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-error-list=no|yes  show detected errors list and\n"
-"                              suppression counts at exit [no]\n"
+"    --show-error-list=no|yes|all  show detected errors list and\n"
+"                              suppression counts at exit [no].\n"
+"                              all means to also print suppressed errors.\n"
 "    -s                        same as --show-error-list=yes\n"
 "    --keep-debuginfo=no|yes   Keep symbols etc for unloaded code [no]\n"
 "                              This allows saved stack traces (e.g. memory leaks)\n"
@@ -608,10 +609,19 @@ static void process_option (Clo_Mode mode,
          startpos = *nextpos ? nextpos + 1 : nextpos;
       }
    }
-   else if VG_BOOL_CLOM(cloPD, arg, "--show-error-list", VG_(clo_show_error_list)) {
+   else if VG_STR_CLOM(cloPD, arg, "--show-error-list", tmp_str) {
+      if (VG_(strcmp)(tmp_str, "yes") == 0)
+         VG_(clo_show_error_list) = 1;
+      else if (VG_(strcmp)(tmp_str, "all") == 0)
+         VG_(clo_show_error_list) = 2;
+      else if (VG_(strcmp)(tmp_str, "no") == 0)
+         VG_(clo_show_error_list) = 0;
+      else
+         VG_(fmsg_bad_option)(arg,
+            "Bad argument, should be 'yes', 'all' or 'no'\n");
       pos->show_error_list_set = True; }
    else if (VG_STREQ_CLOM(cloPD, arg, "-s")) {
-      VG_(clo_show_error_list) = True;
+      VG_(clo_show_error_list) = 1;
       pos->show_error_list_set = True;
    }
    else if VG_BOOL_CLO(arg, "--show-emwarns",   VG_(clo_show_emwarns)) {}
@@ -638,8 +648,8 @@ static void process_option (Clo_Mode mode,
    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)) {}
-else if VG_INT_CLOM(cloPD, arg, "--scheduling-quantum", 
-                    VG_(clo_scheduling_quantum)) {}
+   else if VG_INT_CLOM(cloPD, arg, "--scheduling-quantum",
+                       VG_(clo_scheduling_quantum)) {}
    else if VG_STR_CLO(arg, "--fair-sched",        tmp_str) {
       if (VG_(Clo_Mode)() != cloP)
          ;
@@ -2325,7 +2335,7 @@ void shutdown_actions_NORETURN( ThreadId tid,
       }
 
       /* In XML mode, this merely prints the used suppressions. */
-      VG_(show_all_errors)(VG_(clo_verbosity), VG_(clo_xml));
+      VG_(show_all_errors)(VG_(clo_verbosity), VG_(clo_xml), VG_(clo_show_error_list));
    }
 
    if (VG_(clo_xml)) {
index 1483af2d9d39734e5d3d19ce15294c900cd3fe97..ecbe9fc3adc86d4171debb55198c72dcafb5dd8f 100644 (file)
@@ -93,7 +93,7 @@ Int    VG_(clo_error_exitcode) = 0;
 HChar *VG_(clo_error_markers)[2] = {NULL, NULL};
 Bool   VG_(clo_exit_on_first_error) = False;
 
-Bool   VG_(clo_show_error_list) = False;
+Int   VG_(clo_show_error_list) = 0;
 
 #if defined(VGPV_arm_linux_android) \
     || defined(VGPV_x86_linux_android) \
index e3208a813937bead95bb02cf79e2ac7bb4c304c9..6dde62384e32961bb941774c9e16fbda54e5a2eb 100644 (file)
@@ -53,11 +53,20 @@ extern void VG_(add_suppression_file) (const HChar *filename);
 
 extern void VG_(load_suppressions)        ( void );
 
-// if verbosity == 0,           print nothing.
-// else if xml                  print suppressions used (in xml format)
-// else if verbosity == 1       print Error summary
-// else                         print all errors and suppressions used.
-extern void VG_(show_all_errors)          ( Int verbosity, Bool xml );
+// if verbosity == 0 && show_error_list == no (0)
+//       print nothing.
+// else if xml
+//       if show_error_list == yes (1)|all(2)
+//            print suppressions used (in xml format)
+// else
+//       print Error summary
+//       if show_error_list == yes|all
+//            print all errors and suppressions used.
+//            if show_error_list == all or also_suppressed,
+//                  also print the suppressed errors.
+extern void VG_(show_all_errors)          ( Int verbosity,
+                                            Bool xml,
+                                            Int show_error_list);
 
 /* Print (in readable format) the last error that occurred. */
 extern void VG_(show_last_error)          ( void );
index e949311af1445189611d714b79f8f8081c599f77..97cc741aa0f5f680ad1dc8a9511479573ea43f7f 100644 (file)
@@ -52,8 +52,13 @@ extern Int   VG_(clo_error_exitcode);
 /* For tools that report errors, list detected errors and show suppression
    usage counts at exit. Default: No.
    Unless set explicitly by the user, the option is automatically
-   considered as set to yes for verbosity > 1. */
-extern Bool  VG_(clo_show_error_list);
+   considered as set to yes for verbosity > 1.
+   Note that in xml mode, errors are automatically printed as part of
+   the xml output. This option then only controls printing the used suppressions.
+   default: 0 (NO)
+            1 (yes)
+            2 (all meaning also print suppressed errors). */
+extern Int  VG_(clo_show_error_list);
 
 
 /* Markers used to mark the begin/end of an error, when errors are
index ff8c8124afdd482b67e38d906482bff566432c89..d7944b8a15f88b4445ccb231c2dcc6fc717659de 100644 (file)
@@ -1525,8 +1525,10 @@ client request.
   </listitem>
 
   <listitem>
-    <para><varname>v.info all_errors</varname> shows all errors found
-    so far.</para>
+    <para><varname>v.info all_errors [also_suppressed]</varname> shows all errors found
+      so far.</para>
+    <para> The optional "also_suppressed" argument indicates to also output
+      the suppressed errors.</para>
   </listitem>
   <listitem>
     <para><varname>v.info last_error</varname> shows the last error
index 0985ac8673d295dadebbc4479e8d3c2b70da1363..8750de18921b5ed4dfa01a7e11ce6dde3d4294aa 100644 (file)
@@ -1288,12 +1288,13 @@ that can report errors, e.g. Memcheck, but not Cachegrind.</para>
 
   <varlistentry id="opt.show-error-list" xreflabel="--show-error-list">
     <term>
-      <option><![CDATA[--show-error-list=no|yes [default: no]]]></option>
+      <option><![CDATA[--show-error-list=no|yes|all [default: no]]]></option>
     </term>
     <listitem>
-      <para>If this option is enabled, for tools that report errors, valgrind
+      <para>If this option is yes, for tools that report errors, valgrind
         will show the list of detected errors and the list of used suppressions
-        at exit.
+        at exit. The value all indicates to also show the list of suppressed
+        errors.
       </para>
       <para>Note that at verbosity 2 and above, valgrind automatically shows
         the list of detected errors and the list of used suppressions
index 916c8a70d2d956271d646af648d8233be1b2da7c..29160c1e877fe79afe0225fc598f3f126462a21a 100644 (file)
@@ -1,7 +1,7 @@
 general valgrind monitor commands:
   help [debug]            : monitor command help. With debug: + debugging commands
   v.wait [<ms>]           : sleep <ms> (default 0) then continue
-  v.info all_errors       : show all errors found so far
+  v.info all_errors [also_suppressed] : show all errors found so far
   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
@@ -60,7 +60,7 @@ memcheck monitor commands:
 general valgrind monitor commands:
   help [debug]            : monitor command help. With debug: + debugging commands
   v.wait [<ms>]           : sleep <ms> (default 0) then continue
-  v.info all_errors       : show all errors found so far
+  v.info all_errors [also_suppressed] : show all errors found so far
   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
index 8d463a4a7123bd13d224268430b97ef8126d921f..0aefc5824aaba4d1d87ebe2dcdd6aa680e7c0944 100644 (file)
@@ -2,7 +2,7 @@ vgdb-error value changed from 0 to 999999
 general valgrind monitor commands:
   help [debug]            : monitor command help. With debug: + debugging commands
   v.wait [<ms>]           : sleep <ms> (default 0) then continue
-  v.info all_errors       : show all errors found so far
+  v.info all_errors [also_suppressed] : show all errors found so far
   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
index ce3cdfcf5d482ac19a35c3e7f940e5eff3218cf5..de9359a79c5b745f4838cefdf7f26b4d34094ff6 100644 (file)
@@ -50,8 +50,9 @@ usage: valgrind [options] prog-and-args
     --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-error-list=no|yes  show detected errors list and
-                              suppression counts at exit [no]
+    --show-error-list=no|yes|all  show detected errors list and
+                              suppression counts at exit [no].
+                              all means to also print suppressed errors.
     -s                        same as --show-error-list=yes
     --keep-debuginfo=no|yes   Keep symbols etc for unloaded code [no]
                               This allows saved stack traces (e.g. memory leaks)
index e46504338c613c1fdad6a6f7953dee5071ebd76c..88e4f404924f8d0dcccdb3d946d0022c4463861a 100644 (file)
@@ -50,8 +50,9 @@ usage: valgrind [options] prog-and-args
     --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-error-list=no|yes  show detected errors list and
-                              suppression counts at exit [no]
+    --show-error-list=no|yes|all  show detected errors list and
+                              suppression counts at exit [no].
+                              all means to also print suppressed errors.
     -s                        same as --show-error-list=yes
     --keep-debuginfo=no|yes   Keep symbols etc for unloaded code [no]
                               This allows saved stack traces (e.g. memory leaks)
index eb114d8305f8bd84817f6148f88c2164564ce39a..c2fc91183744acff419dbeb8c3346221e628aa21 100755 (executable)
@@ -84,8 +84,9 @@ do
           fi
         done
 
-        # check that filter files (but nor ones derived from filter*.in) are in dist_noinst_SCRIPTS
-        for f in $(ls -d filter* 2>/dev/null | grep -v \.in)
+        # check that filter files (but nor ones derived from filter*.in and emacs backup files)
+        # are in dist_noinst_SCRIPTS
+        for f in $(ls -d filter* 2>/dev/null | grep -v -e \.in -e '.*~$')
         do
           if [ ! -e "$f".in ]; then
             if ! echo "${parsed_makefile}" 2>/dev/null | grep '^ *dist_noinst_SCRIPTS *=' |