From: Philippe Waroquiers Date: Sun, 14 Apr 2024 13:35:16 +0000 (+0200) Subject: Allow to see more details about suppressed errors. X-Git-Tag: VALGRIND_3_23_0~48 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=97386027d692753c46d0687e0a436f3062c311fb;p=thirdparty%2Fvalgrind.git Allow to see more details about suppressed errors. 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. --- diff --git a/NEWS b/NEWS index 1a62b321bd..705e17be23 100644 --- 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 =================== diff --git a/coregrind/m_errormgr.c b/coregrind/m_errormgr.c index 40e36d162d..3f8aa31b7f 100644 --- a/coregrind/m_errormgr.c +++ b/coregrind/m_errormgr.c @@ -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. diff --git a/coregrind/m_gdbserver/server.c b/coregrind/m_gdbserver/server.c index 83825408ae..8ca4de20f6 100644 --- a/coregrind/m_gdbserver/server.c +++ b/coregrind/m_gdbserver/server.c @@ -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 [] : sleep (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 : show information about location \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) (), diff --git a/coregrind/m_gdbserver/valgrind-monitor-def.py b/coregrind/m_gdbserver/valgrind-monitor-def.py index d74b1590cc..bb9a83c333 100644 --- a/coregrind/m_gdbserver/valgrind-monitor-def.py +++ b/coregrind/m_gdbserver/valgrind-monitor-def.py @@ -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. diff --git a/coregrind/m_main.c b/coregrind/m_main.c index 10b2d9be97..7ff57ce663 100644 --- a/coregrind/m_main.c +++ b/coregrind/m_main.c @@ -137,8 +137,9 @@ static void usage_NORETURN ( int need_help ) " --error-exitcode= exit code to return if errors found [0=disable]\n" " --error-markers=, 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)) { diff --git a/coregrind/m_options.c b/coregrind/m_options.c index 1483af2d9d..ecbe9fc3ad 100644 --- a/coregrind/m_options.c +++ b/coregrind/m_options.c @@ -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) \ diff --git a/coregrind/pub_core_errormgr.h b/coregrind/pub_core_errormgr.h index e3208a8139..6dde62384e 100644 --- a/coregrind/pub_core_errormgr.h +++ b/coregrind/pub_core_errormgr.h @@ -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 ); diff --git a/coregrind/pub_core_options.h b/coregrind/pub_core_options.h index e949311af1..97cc741aa0 100644 --- a/coregrind/pub_core_options.h +++ b/coregrind/pub_core_options.h @@ -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 diff --git a/docs/xml/manual-core-adv.xml b/docs/xml/manual-core-adv.xml index ff8c8124af..d7944b8a15 100644 --- a/docs/xml/manual-core-adv.xml +++ b/docs/xml/manual-core-adv.xml @@ -1525,8 +1525,10 @@ client request. - v.info all_errors shows all errors found - so far. + v.info all_errors [also_suppressed] shows all errors found + so far. + The optional "also_suppressed" argument indicates to also output + the suppressed errors. v.info last_error shows the last error diff --git a/docs/xml/manual-core.xml b/docs/xml/manual-core.xml index 0985ac8673..8750de1892 100644 --- a/docs/xml/manual-core.xml +++ b/docs/xml/manual-core.xml @@ -1288,12 +1288,13 @@ that can report errors, e.g. Memcheck, but not Cachegrind. - + - If this option is enabled, for tools that report errors, valgrind + 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. Note that at verbosity 2 and above, valgrind automatically shows the list of detected errors and the list of used suppressions diff --git a/gdbserver_tests/mchelp.stdoutB.exp b/gdbserver_tests/mchelp.stdoutB.exp index 916c8a70d2..29160c1e87 100644 --- a/gdbserver_tests/mchelp.stdoutB.exp +++ b/gdbserver_tests/mchelp.stdoutB.exp @@ -1,7 +1,7 @@ general valgrind monitor commands: help [debug] : monitor command help. With debug: + debugging commands v.wait [] : sleep (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 : show information about location 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 [] : sleep (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 : show information about location v.info n_errs_found [msg] : show the nr of errors found so far and the given msg diff --git a/gdbserver_tests/mssnapshot.stderrB.exp b/gdbserver_tests/mssnapshot.stderrB.exp index 8d463a4a71..0aefc5824a 100644 --- a/gdbserver_tests/mssnapshot.stderrB.exp +++ b/gdbserver_tests/mssnapshot.stderrB.exp @@ -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 [] : sleep (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 : show information about location v.info n_errs_found [msg] : show the nr of errors found so far and the given msg diff --git a/none/tests/cmdline1.stdout.exp b/none/tests/cmdline1.stdout.exp index ce3cdfcf5d..de9359a79c 100644 --- a/none/tests/cmdline1.stdout.exp +++ b/none/tests/cmdline1.stdout.exp @@ -50,8 +50,9 @@ usage: valgrind [options] prog-and-args --error-exitcode= exit code to return if errors found [0=disable] --error-markers=, 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) diff --git a/none/tests/cmdline2.stdout.exp b/none/tests/cmdline2.stdout.exp index e46504338c..88e4f40492 100644 --- a/none/tests/cmdline2.stdout.exp +++ b/none/tests/cmdline2.stdout.exp @@ -50,8 +50,9 @@ usage: valgrind [options] prog-and-args --error-exitcode= exit code to return if errors found [0=disable] --error-markers=, 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) diff --git a/tests/check_makefile_consistency b/tests/check_makefile_consistency index eb114d8305..c2fc911837 100755 --- a/tests/check_makefile_consistency +++ b/tests/check_makefile_consistency @@ -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 *=' |