]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Implement option --show-error-list=no|yes -s
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Sun, 23 Dec 2018 21:56:38 +0000 (22:56 +0100)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Fri, 28 Dec 2018 18:32:53 +0000 (19:32 +0100)
This option allows to list the detected errors and show the used
suppressions without increasing the verbosity.
Increasing the verbosity also activates a lot of messages that
are often not very useful for the user.
So, this option allows to see the list of errors and used suppressions
independently of the verbosity.

Note if a high verbosity is selected, the behaviour is unchanged.
In other words, when specifying -v, the list of detected errors
and the used suppressions are still shown, even if
--show-error-list=yes and -s are not used.

coregrind/m_errormgr.c
coregrind/m_main.c
coregrind/m_options.c
coregrind/pub_core_options.h
drd/tests/filter_stderr
exp-sgcheck/tests/filter_stderr
helgrind/tests/filter_stderr

index 5dc17252004fa7d952cdcae0df6ce37b56aca49e..fb41e4ebd582754154664cb47f43f6e729d05f42 100644 (file)
@@ -979,29 +979,31 @@ void VG_(show_all_errors) (  Int verbosity, Bool xml )
    Int    i, n_min;
    Error *p, *p_min;
    Bool   any_supp;
+   Bool   any_error = False;
 
-   if (verbosity == 0)
+   if (verbosity == 0 && !VG_(clo_show_error_list))
       return;
 
    /* If we're printing XML, just show the suppressions and stop. */
    if (xml) {
-      (void)show_used_suppressions();
+      if (VG_(clo_show_error_list))
+         (void)show_used_suppressions();
       return;
    }
 
    /* We only get here if not printing XML. */
    VG_(umsg)("ERROR SUMMARY: "
              "%u errors from %u contexts (suppressed: %u from %u)\n",
-             n_errs_found, n_err_contexts, 
+             n_errs_found, n_err_contexts,
              n_errs_suppressed, n_supp_contexts );
 
-   if (verbosity <= 1)
+   if (!VG_(clo_show_error_list))
       return;
 
-   // We do the following only at -v or above, and only in non-XML
-   // mode
+   // We do the following if VG_(clo_show_error_list)
+   // or at -v or above, and only in non-XML mode.
 
-   /* Print the contexts in order of increasing error count. 
+   /* Print the contexts in order of increasing error count.
       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. */
@@ -1018,6 +1020,7 @@ void VG_(show_all_errors) (  Int verbosity, Bool xml )
       // XXX: this isn't right.  See bug 203651.
       if (p_min == NULL) continue; //VG_(core_panic)("show_all_errors()");
 
+      any_error = True;
       VG_(umsg)("\n");
       VG_(umsg)("%d errors in context %d of %u:\n",
                 p_min->count, i+1, n_err_contexts);
@@ -1035,9 +1038,9 @@ void VG_(show_all_errors) (  Int verbosity, Bool xml )
       }
 
       p_min->count = p_min->count + (1 << 30);
-   } 
+   }
 
-   /* reset the counts, otherwise a 2nd call does not show anything anymore */ 
+   /* reset the counts, otherwise a 2nd call does not show anything anymore */
    for (p = errors; p != NULL; p = p->next) {
       if (p->count >= (1 << 30))
          p->count = p->count - (1 << 30);
@@ -1046,14 +1049,15 @@ void VG_(show_all_errors) (  Int verbosity, Bool xml )
 
    any_supp = show_used_suppressions();
 
-   if (any_supp) 
+   if (any_supp)
       VG_(umsg)("\n");
-   // reprint this, so users don't have to scroll way up to find
+   // reprint summary, so users don't have to scroll way up to find
    // the first printing
-   VG_(umsg)("ERROR SUMMARY: "
-             "%u errors from %u contexts (suppressed: %u from %u)\n",
-             n_errs_found, n_err_contexts, n_errs_suppressed,
-             n_supp_contexts );
+   if (any_supp || any_error)
+      VG_(umsg)("ERROR SUMMARY: "
+                "%u errors from %u contexts (suppressed: %u from %u)\n",
+                n_errs_found, n_err_contexts, n_errs_suppressed,
+                n_supp_contexts );
 }
 
 void VG_(show_last_error) ( void )
index cb4268569dd2df58c120ee4d7423bacab15b5796..7d987ea2668df587c7e37b4a29e212d13368414c 100644 (file)
@@ -129,6 +129,9 @@ static void usage_NORETURN ( Bool debug_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"
+"    -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"
 "                              to include file/line info for code that has been\n"
@@ -459,9 +462,11 @@ void main_process_cmd_line_options( void )
    Int   toolname_len = VG_(strlen)(VG_(clo_toolname));
    const HChar* tmp_str;         // Used in a couple of places.
 
-   /* Whether the user has explicitly provided --sigill-diagnostics.
+   /* Whether the user has explicitly provided --sigill-diagnostics
+      or --show-error-list.
       If not explicitly given depends on general verbosity setting. */
    Bool sigill_diag_set = False;
+   Bool show_error_list_set = False;
 
    /* Log to stderr by default, but usage message goes to stdout.  XML
       output is initially disabled. */
@@ -636,6 +641,12 @@ void main_process_cmd_line_options( void )
             startpos = *nextpos ? nextpos + 1 : nextpos;
          }
       }
+      else if VG_BOOL_CLO(arg, "--show-error-list", VG_(clo_show_error_list)) {
+            show_error_list_set = True; }
+      else if (VG_STREQ(arg, "-s")) {
+         VG_(clo_show_error_list) = True;
+         show_error_list_set = True;
+      }
       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)) {}
@@ -920,6 +931,13 @@ void main_process_cmd_line_options( void )
    if (!sigill_diag_set)
       VG_(clo_sigill_diag) = (VG_(clo_verbosity) > 0);
 
+   if (!show_error_list_set) {
+      if (VG_(clo_xml))
+         VG_(clo_show_error_list) = VG_(clo_verbosity) >= 1;
+      else
+         VG_(clo_show_error_list) = VG_(clo_verbosity) >= 2;
+   }
+
    if (VG_(clo_trace_notbelow) == -1) {
      if (VG_(clo_trace_notabove) == -1) {
        /* [] */
@@ -2153,9 +2171,12 @@ void shutdown_actions_NORETURN( ThreadId tid,
    VG_TDICT_CALL(tool_fini, 0/*exitcode*/);
 
    if (VG_(needs).core_errors || VG_(needs).tool_errors) {
-      if (VG_(clo_verbosity) == 1 && !VG_(clo_xml))
-         VG_(message)(Vg_UserMsg, 
-                      "For counts of detected and suppressed errors, rerun with: -v\n");
+      if (VG_(clo_verbosity) == 1
+          && !VG_(clo_xml)
+          && !VG_(clo_show_error_list))
+         VG_(message)(Vg_UserMsg,
+                      "For lists of detected and suppressed errors,"
+                      " rerun with: -s\n");
 
       /* Show the error counts. */
       if (VG_(clo_xml)) {
index 67eed342bad17e4c295cb823066addf55481d770..f9e9c8b0f6da00dbdedbd7390f4db241fa49476b 100644 (file)
@@ -54,6 +54,8 @@ 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;
+
 #if defined(VGPV_arm_linux_android) \
     || defined(VGPV_x86_linux_android) \
     || defined(VGPV_mips32_linux_android) \
index 3bae7f3f19881bea63115f5efa3988de8320776a..9a75da70c6c337356a79cdd66caa335234a8cd42 100644 (file)
@@ -51,6 +51,13 @@ extern Bool  VG_(clo_exit_on_first_error);
    way. */
 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);
+
+
 /* 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.
index 9347e4ecd82afec15e5337e0552901655ad564bd..7fbddbfe2e663a3b2f4252d794045fbcc4613402 100755 (executable)
@@ -42,7 +42,7 @@ sed \
 -e "s/ (\([a-zA-Z_]*\.cpp\):[0-9]*)/ (\1:?)/" \
 -e "s/\( name [^ ]*\)-[0-9]*\( oflag \)/\1\2/" \
 -e '/^   by 0x[0-9a-fA-F]*: process_dl_debug (in \/lib[0-9]*\/ld-[0-9.]*\.so)$/d' \
--e "/^For counts of detected and suppressed errors, rerun with: -v$/d" |
+-e "/^For detected errors list and suppressed errors count, rerun with: -s$/d" |
 
 # Remove the message that more than hundred errors have been detected
 # (consists of two lines) and also the empty line above it.
index 174bc94377a78e1fb956e2b3be6fa4703722be5b..94bd8736aaeee5e058784022822e149f38d634d3 100755 (executable)
@@ -19,7 +19,7 @@ sed \
 -e "/^exp-sgcheck, a stack and global array overrun detector$/d" \
 -e "/^NOTE: This is an Experimental-Class Valgrind Tool$/d"  \
 -e "/^Copyright (C) 2003-201., and GNU GPL'd, by OpenWorks Ltd et al.$/d" \
--e "/^For counts of detected and suppressed errors, rerun with: -v$/d" |
+-e "/^For detected errors list and suppressed errors count, rerun with: -s$/d" |
 
 # Tidy up in cases where glibc (+ libdl + libpthread + ld) have
 # been built with debugging information, hence source locs are present.
index cfdd89496a25b0645e35f1e8de41d36ad66ea3b0..0e7072357b592e9a139d13c37e78cab901d1e99d 100755 (executable)
@@ -42,7 +42,7 @@ sed \
 # do not contain them (at least on gcc110/fedora18).
 sed \
  -e "/^Helgrind, a thread error detector/ , /./ d" \
- -e "/^For counts of detected and suppressed errors, rerun with: -v$/d" \
+ -e "/^For detected errors list and suppressed errors count, rerun with: -s$/d" \
  -e "/^Use --history-level=approx or =none to gain increased speed, at$/d" \
  -e "/^the cost of reduced accuracy of conflicting-access information$/d" \
  -e "/pthread_create_WRK (hg_intercepts.c:/d" |