From: Nicholas Nethercote Date: Tue, 11 Aug 2009 00:52:40 +0000 (+0000) Subject: Count error contexts properly in VG_(unique_error). Avoids the problem seen X-Git-Tag: svn/VALGRIND_3_5_0~77 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9d2e0f9cbe8f158c7a56fceec62800934a4559bd;p=thirdparty%2Fvalgrind.git Count error contexts properly in VG_(unique_error). Avoids the problem seen of "5 errors from 0 contexts" with leak errors. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10773 --- diff --git a/NEWS b/NEWS index ae5c031cf1..3b06382b9c 100644 --- a/NEWS +++ b/NEWS @@ -77,6 +77,10 @@ Release 3.5.0 (???) - The default value for the --leak-resolution option has been changed from "low" to "high". In general, this means that more leak reports will be produced, but each leak report will describe fewer leaked blocks. + - "Definitely lost" and "possibly lost" leaks are now considered as normal + errors, ie. they are counted for the "ERROR SUMMARY" and + --error-exitcode. This is true even if their loss records aren't + printed, ie. if you run with --leak-check=summary. - The documentation for the leak checker has also been improved. * XXX: Atomic instructions are now handled properly... diff --git a/coregrind/m_errormgr.c b/coregrind/m_errormgr.c index 41918357cc..b026df4a56 100644 --- a/coregrind/m_errormgr.c +++ b/coregrind/m_errormgr.c @@ -79,6 +79,13 @@ static UInt n_errs_found = 0; /* Running count of suppressed errors detected. */ static UInt n_errs_suppressed = 0; +/* Running count of unsuppressed error contexts. */ +static UInt n_err_contexts = 0; + +/* Running count of suppressed error contexts. */ +static UInt n_supp_contexts = 0; + + /* forwards ... */ static Supp* is_suppressible_error ( Error* err ); @@ -712,6 +719,7 @@ void VG_(maybe_record_error) ( ThreadId tid, p->supp = is_suppressible_error(&err); errors = p; if (p->supp == NULL) { + n_err_contexts++; n_errs_found++; /* A bit of prettyprinting, to ensure there's a blank line in between each error. */ @@ -727,6 +735,7 @@ void VG_(maybe_record_error) ( ThreadId tid, is_first_shown_context = False; n_errs_shown++; } else { + n_supp_contexts++; n_errs_suppressed++; p->supp->count++; } @@ -760,8 +769,10 @@ Bool VG_(unique_error) ( ThreadId tid, ErrorKind ekind, Addr a, Char* s, su = is_suppressible_error(&err); if (NULL == su) { - if (count_error) + if (count_error) { n_errs_found++; + n_err_contexts++; + } if (print_error) { /* A bit of prettyprinting, to ensure there's a blank line @@ -782,6 +793,7 @@ Bool VG_(unique_error) ( ThreadId tid, ErrorKind ekind, Addr a, Char* s, } else { n_errs_suppressed++; + n_supp_contexts++; su->count++; return True; } @@ -833,28 +845,13 @@ static Bool show_used_suppressions ( void ) void VG_(show_all_errors) ( void ) { Int i, n_min; - Int n_err_contexts, n_supp_contexts; Error *p, *p_min; - Supp *su; Bool any_supp; if (VG_(clo_verbosity) == 0) return; - n_err_contexts = 0; - for (p = errors; p != NULL; p = p->next) { - if (p->supp == NULL) - n_err_contexts++; - } - - n_supp_contexts = 0; - for (su = suppressions; su != NULL; su = su->next) { - if (su->count > 0) - n_supp_contexts++; - } - - /* If we're printing XML, just show the suppressions and stop. - */ + /* If we're printing XML, just show the suppressions and stop. */ if (VG_(clo_xml)) { (void)show_used_suppressions(); return; diff --git a/memcheck/mc_leakcheck.c b/memcheck/mc_leakcheck.c index 68b317e1ad..0b8ea013f4 100644 --- a/memcheck/mc_leakcheck.c +++ b/memcheck/mc_leakcheck.c @@ -842,6 +842,9 @@ static void print_results(ThreadId tid, Bool is_full_check) // includes indirectly lost blocks! // lr = lr_array[i]; + // You could argue that indirect leaks should be counted as errors, but + // it seems better to make the counting criteria similar to the printing + // criteria. So we don't count them. count_as_error = Unreached == lr->key.state || Possible == lr->key.state; print_record = is_full_check &&