From: Julian Seward Date: Fri, 7 Aug 2009 15:46:56 +0000 (+0000) Subject: Tidy up of messaging: X-Git-Tag: svn/VALGRIND_3_5_0~104 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8ffe2fdefae14ef59aefec03f9f0be4257343708;p=thirdparty%2Fvalgrind.git Tidy up of messaging: * For all tools and the core, don't show statistics when -v is in effect. Instead, try to restrict -v to mostly user-useful stuff. * A new flag --stats=no|yes [no] produces statistics output instead. * Fix longstanding problem in that Memcheck's leak checker ran after the core's error manager module shut down, thereby not showing use counts of leak suppressions. This fixes #186790. * As a consequence, the leak checker text output of Memcheck has changed a bit -- leak check is done before the final error summary is done (much more logical), and the output has been tidied up a bit. * Helgrind, Drd and Ptrcheck now also print "For counts of detected and suppressed errors, rerun with: -v", which makes them consistent with Memcheck in this regard. These are filtered out by the regtest filter scripts. For all tools except Memcheck, the regtests are unchanged. On Memcheck regtests still fail due to rearrangements of the leak checker output. This will be fixed by a followup commit. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10746 --- diff --git a/cachegrind/cg_main.c b/cachegrind/cg_main.c index 77e250a933..b8c0a625c1 100644 --- a/cachegrind/cg_main.c +++ b/cachegrind/cg_main.c @@ -1591,7 +1591,7 @@ static void cg_fini(Int exitcode) } // Various stats - if (VG_(clo_verbosity) > 1) { + if (VG_(clo_stats)) { Int debug_lookups = full_debugs + fn_debugs + file_line_debugs + no_debugs; diff --git a/callgrind/main.c b/callgrind/main.c index 53ae058d03..c1ec141dfa 100644 --- a/callgrind/main.c +++ b/callgrind/main.c @@ -1190,7 +1190,7 @@ void finish(void) if (VG_(clo_verbosity) == 0) return; /* Hash table stats */ - if (VG_(clo_verbosity) > 1) { + if (VG_(clo_stats)) { int BB_lookups = CLG_(stat).full_debug_BBs + CLG_(stat).fn_name_debug_BBs + diff --git a/coregrind/m_errormgr.c b/coregrind/m_errormgr.c index a92609ad38..41918357cc 100644 --- a/coregrind/m_errormgr.c +++ b/coregrind/m_errormgr.c @@ -806,7 +806,6 @@ static Bool show_used_suppressions ( void ) for (su = suppressions; su != NULL; su = su->next) { if (su->count <= 0) continue; - any_supp = True; if (VG_(clo_xml)) { VG_(printf_xml_no_f_c)( " \n" " %d\n" @@ -814,8 +813,12 @@ static Bool show_used_suppressions ( void ) " \n", su->count, su->sname ); } else { - VG_(dmsg)("supp: %6d %s\n", su->count, su->sname); + // blank line before the first shown suppression, if any + if (!any_supp) + VG_(dmsg)("\n"); + VG_(dmsg)("used_suppression: %6d %s\n", su->count, su->sname); } + any_supp = True; } if (VG_(clo_xml)) @@ -866,6 +869,9 @@ void VG_(show_all_errors) ( void ) if (VG_(clo_verbosity) <= 1) return; + // We do the following only at -v or above, and only in non-XML + // mode + /* Print the contexts in order of increasing error count. */ for (i = 0; i < n_err_contexts; i++) { n_min = (1 << 30) - 1; @@ -898,19 +904,16 @@ void VG_(show_all_errors) ( void ) p_min->count = 1 << 30; } - if (n_supp_contexts > 0) - VG_(umsg)("\n"); any_supp = show_used_suppressions(); - if (n_err_contexts > 0) { - if (any_supp) - VG_(umsg)("\n"); - VG_(umsg)("IN SUMMARY: " - "%d errors from %d contexts (suppressed: %d from %d)\n", - n_errs_found, n_err_contexts, n_errs_suppressed, - n_supp_contexts ); + if (any_supp) VG_(umsg)("\n"); - } + // reprint this, so users don't have to scroll way up to find + // the first printing + VG_(umsg)("ERROR SUMMARY: " + "%d errors from %d contexts (suppressed: %d from %d)\n", + n_errs_found, n_err_contexts, n_errs_suppressed, + n_supp_contexts ); } diff --git a/coregrind/m_main.c b/coregrind/m_main.c index 08a96a7c9e..edaf9193a7 100644 --- a/coregrind/m_main.c +++ b/coregrind/m_main.c @@ -119,7 +119,7 @@ static void usage_NORETURN ( Bool debug_help ) " --help-debug show this message, plus debugging options\n" " --version show version\n" " -q --quiet run silently; only print error msgs\n" -" -v --verbose be more verbose, incl counts of errors\n" +" -v --verbose be more verbose -- show misc extra info\n" " --trace-children=no|yes Valgrind-ise child processes (follow execve)? [no]\n" " --child-silent-after-fork=no|yes omit child output between fork & exec? [no]\n" " --track-fds=no|yes track open file descriptors? [no]\n" @@ -171,6 +171,7 @@ static void usage_NORETURN ( Bool debug_help ) Char* usage2 = "\n" " debugging options for all Valgrind tools:\n" +" --stats=no|yes show tool and core statistics [no]\n" " -d show verbose debugging output\n" " --sanity-level= level of sanity checking to do [1]\n" " --trace-flags= show generated code? (X = 0|1) [00000000]\n" @@ -437,6 +438,7 @@ void main_process_cmd_line_options ( /*OUT*/Bool* logging_to_fd, VG_STREQ(arg, "--quiet")) VG_(clo_verbosity)--; + else if VG_BOOL_CLO(arg, "--stats", VG_(clo_stats)) {} else if VG_BOOL_CLO(arg, "--xml", VG_(clo_xml)) {} else if VG_BOOL_CLO(arg, "--db-attach", VG_(clo_db_attach)) {} else if VG_BOOL_CLO(arg, "--demangle", VG_(clo_demangle)) {} @@ -2411,35 +2413,21 @@ void shutdown_actions_NORETURN( ThreadId tid, if (VG_(clo_track_fds)) VG_(show_open_fds)(); - /* ** HACK ALERT ** HACK ALERT ** HACK ALERT ** HACK ALERT ** */ - if (VG_(clo_xml)) { - /* THIS IS WHAT WE SHOULD CHANGE IT TO */ - /* For the moment, do it like this (the "right way") in XML - mode, so that output is as described in XML Protocol 4. */ - /* A good test is memcheck/tests/amd64/defcfaexpr; ensure - the output does not change */ - VG_TDICT_CALL(tool_fini, 0/*exitcode*/); - - /* Show the error counts. */ - if (VG_(needs).core_errors || VG_(needs).tool_errors) { - VG_(printf_xml)( "\n" ); - VG_(show_error_counts_as_XML)(); - VG_(printf_xml)( "\n" ); - } + /* Call the tool's finalisation function. This makes Memcheck's + leak checker run, and possibly chuck a bunch of leak errors into + the error management machinery. */ + VG_TDICT_CALL(tool_fini, 0/*exitcode*/); - /* In XML mode, this merely prints the used suppressions. */ - if (VG_(needs).core_errors || VG_(needs).tool_errors) - VG_(show_all_errors)(); - - } else { - /* THIS IS WHAT IT HAS ALWAYS BEEN, - resulting in https://bugs.kde.org/show_bug.cgi?id=186790 */ - if (VG_(needs).core_errors || VG_(needs).tool_errors) - VG_(show_all_errors)(); - - VG_TDICT_CALL(tool_fini, 0/*exitcode*/); + /* Show the error counts. */ + if (VG_(needs).core_errors || VG_(needs).tool_errors) { + VG_(printf_xml)( "\n" ); + VG_(show_error_counts_as_XML)(); + VG_(printf_xml)( "\n" ); } - /* END ** HACK ALERT ** HACK ALERT ** HACK ALERT ** HACK ALERT ** */ + + /* In XML mode, this merely prints the used suppressions. */ + if (VG_(needs).core_errors || VG_(needs).tool_errors) + VG_(show_all_errors)(); if (VG_(clo_xml)) { VG_(printf_xml)("\n"); @@ -2449,7 +2437,7 @@ void shutdown_actions_NORETURN( ThreadId tid, VG_(sanity_check_general)( True /*include expensive checks*/ ); - if (VG_(clo_verbosity) > 1) + if (VG_(clo_stats)) print_all_stats(); /* Show a profile of the heap(s) at shutdown. Optionally, first diff --git a/coregrind/m_options.c b/coregrind/m_options.c index 0738befe53..3582818194 100644 --- a/coregrind/m_options.c +++ b/coregrind/m_options.c @@ -51,6 +51,7 @@ Char* VG_(clo_db_command) = GDB_PATH " -nw %f %p"; Int VG_(clo_gen_suppressions) = 0; Int VG_(clo_sanity_level) = 1; Int VG_(clo_verbosity) = 1; +Bool VG_(clo_stats) = False; Bool VG_(clo_xml) = False; HChar* VG_(clo_xml_user_comment) = NULL; Bool VG_(clo_demangle) = True; diff --git a/drd/drd_main.c b/drd/drd_main.c index 840b8d5b9d..03b523edfa 100644 --- a/drd/drd_main.c +++ b/drd/drd_main.c @@ -568,7 +568,13 @@ static void drd_start_client_code(const ThreadId tid, const ULong bbs_done) static void DRD_(fini)(Int exitcode) { // thread_print_all(); - if (VG_(clo_verbosity) > 1 || DRD_(s_print_stats)) + 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_stats) || DRD_(s_print_stats)) { ULong pu = DRD_(thread_get_update_conflict_set_count)(); ULong pu_seg_cr = DRD_(thread_get_update_conflict_set_new_sg_count)(); diff --git a/drd/tests/filter_stderr b/drd/tests/filter_stderr index ee9ec45083..e8aebb325c 100755 --- a/drd/tests/filter_stderr +++ b/drd/tests/filter_stderr @@ -28,7 +28,8 @@ sed \ -e "s/[@\$*]* (drd_pthread_intercepts.c:/ (drd_pthread_intercepts.c:/" \ -e "s/ (\([a-zA-Z_]*\.c\):[0-9]*)/ (\1:?)/" \ -e "s/ (\([a-zA-Z_]*\.h\):[0-9]*)/ (\1:?)/" \ --e "s/ (\([a-zA-Z_]*\.cpp\):[0-9]*)/ (\1:?)/" | +-e "s/ (\([a-zA-Z_]*\.cpp\):[0-9]*)/ (\1:?)/" \ +-e "/^For counts of detected and suppressed errors, rerun with: -v$/d" | # Remove the message that more than hundred errors have been detected # (consists of two lines) and also the empty line above it. diff --git a/exp-ptrcheck/h_main.c b/exp-ptrcheck/h_main.c index 7a91d35459..235b6589f9 100644 --- a/exp-ptrcheck/h_main.c +++ b/exp-ptrcheck/h_main.c @@ -5328,7 +5328,13 @@ void h_post_clo_init ( void ) void h_fini ( Int exitcode ) { - if (VG_(clo_verbosity) >= 2) { + 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_stats)) { VG_(message)(Vg_DebugMsg, " h_: %'10llu client allocs, %'10llu client frees\n", stats__client_mallocs, stats__client_frees); diff --git a/exp-ptrcheck/sg_main.c b/exp-ptrcheck/sg_main.c index 27ed782078..5d324caa96 100644 --- a/exp-ptrcheck/sg_main.c +++ b/exp-ptrcheck/sg_main.c @@ -2452,7 +2452,7 @@ void sg_pre_thread_first_insn ( ThreadId tid ) { void sg_fini(Int exitcode) { - if (VG_(clo_verbosity) >= 2) { + if (VG_(clo_stats)) { VG_(message)(Vg_DebugMsg, " sg_: %'llu total accesses, of which:\n", stats__total_accesses); VG_(message)(Vg_DebugMsg, diff --git a/exp-ptrcheck/tests/filter_stderr b/exp-ptrcheck/tests/filter_stderr index 11e5851a03..346262fa26 100755 --- a/exp-ptrcheck/tests/filter_stderr +++ b/exp-ptrcheck/tests/filter_stderr @@ -14,11 +14,12 @@ sed "s/(in \/.*libpthread.*)$/(in \/...libpthread...)/" | # Anonymise paths like "__libc_start_main (../foo/bar/libc-quux.c:129)" sed "s/__libc_\(.*\) (.*)$/__libc_\1 (...libc...)/" | -# Remove preambly stuff +# Remove preambly stuff; also postambly stuff sed \ -e "/^exp-ptrcheck, a heap, stack & global array overrun detector\.$/d" \ -e "/^NOTE: This is an Experimental-Class Valgrind Tool.$/d" \ --e "/^Copyright (C) 2003-200., and GNU GPL'd, by OpenWorks Ltd et al.$/d" | +-e "/^Copyright (C) 2003-200., and GNU GPL'd, by OpenWorks Ltd et al.$/d" \ +-e "/^For counts of detected and suppressed errors, rerun with: -v$/d" | # Tidy up in cases where glibc (+ libdl + libpthread + ld) have # been built with debugging information, hence source locs are present. diff --git a/helgrind/hg_main.c b/helgrind/hg_main.c index 7758a344df..e6202623f4 100644 --- a/helgrind/hg_main.c +++ b/helgrind/hg_main.c @@ -4240,12 +4240,26 @@ static void hg_post_clo_init ( void ) static void hg_fini ( Int exitcode ) { + 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) + && HG_(clo_history_level) >= 2) { + VG_(umsg)( + "Use --history-level=approx or =none to gain increased speed, at\n" ); + VG_(umsg)( + "the cost of reduced accuracy of conflicting-access information\n"); + } + if (SHOW_DATA_STRUCTURES) pp_everything( PP_ALL, "SK_(fini)" ); if (HG_(clo_sanity_flags)) all__sanity_check("SK_(fini)"); - if (VG_(clo_verbosity) >= 2) { + if (VG_(clo_stats)) { if (1) { VG_(printf)("\n"); diff --git a/helgrind/tests/filter_stderr b/helgrind/tests/filter_stderr index 8b90d71265..07ea536ba1 100755 --- a/helgrind/tests/filter_stderr +++ b/helgrind/tests/filter_stderr @@ -7,8 +7,13 @@ $dir/../../tests/filter_stderr_basic | # Anonymise addresses $dir/../../tests/filter_addresses | -# Remove "Helgrind, ..." line and the following copyright line. -sed "/^Helgrind, a thread error detector/ , /./ d" | +# Remove "Helgrind, ..." line and the following copyright line; +# also the standard postamble (does such a word exist?) +sed \ + -e "/^Helgrind, a thread error detector/ , /./ d" \ + -e "/^For counts of detected and suppressed errors, rerun with: -v$/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" | # Anonymise line numbers in hg_intercepts.c sed "s/hg_intercepts.c:[0-9]*/hg_intercepts.c:.../g" | diff --git a/include/pub_tool_options.h b/include/pub_tool_options.h index ec03af3b77..f9e1b003d1 100644 --- a/include/pub_tool_options.h +++ b/include/pub_tool_options.h @@ -142,6 +142,9 @@ /* Verbosity level: 0 = silent, 1 (default), > 1 = more verbose. */ extern Int VG_(clo_verbosity); +/* Show tool and core statistics */ +extern Bool VG_(clo_stats); + /* Emit all messages as XML? default: NO */ /* If clo_xml is set, various other options are set in a non-default way. See vg_main.c and mc_main.c. */ diff --git a/massif/ms_main.c b/massif/ms_main.c index 585df2208b..ecfb31c936 100644 --- a/massif/ms_main.c +++ b/massif/ms_main.c @@ -220,6 +220,12 @@ Number of snapshots: 50 VG_(dmsg)("Massif: " format, ##args); \ } +// Used for printing stats when clo_stats == True. +#define STATS(format, args...) \ + if (VG_(clo_stats)) { \ + VG_(dmsg)("Massif: " format, ##args); \ + } + //------------------------------------------------------------// //--- Statistics ---// //------------------------------------------------------------// @@ -2225,28 +2231,28 @@ static void ms_fini(Int exit_status) // Stats tl_assert(n_xpts > 0); // always have alloc_xpt - VERB(1, "heap allocs: %u\n", n_heap_allocs); - VERB(1, "heap reallocs: %u\n", n_heap_reallocs); - VERB(1, "heap frees: %u\n", n_heap_frees); - VERB(1, "ignored heap allocs: %u\n", n_ignored_heap_allocs); - VERB(1, "ignored heap frees: %u\n", n_ignored_heap_frees); - VERB(1, "ignored heap reallocs: %u\n", n_ignored_heap_reallocs); - VERB(1, "stack allocs: %u\n", n_stack_allocs); - VERB(1, "stack frees: %u\n", n_stack_frees); - VERB(1, "XPts: %u\n", n_xpts); - VERB(1, "top-XPts: %u (%d%%)\n", + STATS("heap allocs: %u\n", n_heap_allocs); + STATS("heap reallocs: %u\n", n_heap_reallocs); + STATS("heap frees: %u\n", n_heap_frees); + STATS("ignored heap allocs: %u\n", n_ignored_heap_allocs); + STATS("ignored heap frees: %u\n", n_ignored_heap_frees); + STATS("ignored heap reallocs: %u\n", n_ignored_heap_reallocs); + STATS("stack allocs: %u\n", n_stack_allocs); + STATS("stack frees: %u\n", n_stack_frees); + STATS("XPts: %u\n", n_xpts); + STATS("top-XPts: %u (%d%%)\n", alloc_xpt->n_children, ( n_xpts ? alloc_xpt->n_children * 100 / n_xpts : 0)); - VERB(1, "XPt init expansions: %u\n", n_xpt_init_expansions); - VERB(1, "XPt later expansions: %u\n", n_xpt_later_expansions); - VERB(1, "SXPt allocs: %u\n", n_sxpt_allocs); - VERB(1, "SXPt frees: %u\n", n_sxpt_frees); - VERB(1, "skipped snapshots: %u\n", n_skipped_snapshots); - VERB(1, "real snapshots: %u\n", n_real_snapshots); - VERB(1, "detailed snapshots: %u\n", n_detailed_snapshots); - VERB(1, "peak snapshots: %u\n", n_peak_snapshots); - VERB(1, "cullings: %u\n", n_cullings); - VERB(1, "XCon redos: %u\n", n_XCon_redos); + STATS("XPt init expansions: %u\n", n_xpt_init_expansions); + STATS("XPt later expansions: %u\n", n_xpt_later_expansions); + STATS("SXPt allocs: %u\n", n_sxpt_allocs); + STATS("SXPt frees: %u\n", n_sxpt_frees); + STATS("skipped snapshots: %u\n", n_skipped_snapshots); + STATS("real snapshots: %u\n", n_real_snapshots); + STATS("detailed snapshots: %u\n", n_detailed_snapshots); + STATS("peak snapshots: %u\n", n_peak_snapshots); + STATS("cullings: %u\n", n_cullings); + STATS("XCon redos: %u\n", n_XCon_redos); } diff --git a/massif/tests/culling1.vgtest b/massif/tests/culling1.vgtest index c282f9bc81..eb5ad2f6d5 100644 --- a/massif/tests/culling1.vgtest +++ b/massif/tests/culling1.vgtest @@ -1,5 +1,5 @@ prog: culling1 -vgopts: -v -v --stacks=no --time-unit=B --heap-admin=16 --massif-out-file=massif.out +vgopts: -v -v --stats=yes --stacks=no --time-unit=B --heap-admin=16 --massif-out-file=massif.out vgopts: --ignore-fn=__part_load_locale --ignore-fn=__time_load_locale --ignore-fn=dwarf2_unwind_dyld_add_image_hook --ignore-fn=get_or_create_key_element stderr_filter: filter_verbose cleanup: rm massif.out diff --git a/massif/tests/culling2.vgtest b/massif/tests/culling2.vgtest index 9cd6032ae4..d0b234f217 100644 --- a/massif/tests/culling2.vgtest +++ b/massif/tests/culling2.vgtest @@ -1,5 +1,5 @@ prog: culling2 -vgopts: -v -v --stacks=no --time-unit=B --heap-admin=16 --massif-out-file=massif.out +vgopts: -v -v --stats=yes --stacks=no --time-unit=B --heap-admin=16 --massif-out-file=massif.out vgopts: --ignore-fn=__part_load_locale --ignore-fn=__time_load_locale --ignore-fn=dwarf2_unwind_dyld_add_image_hook --ignore-fn=get_or_create_key_element stderr_filter: filter_verbose cleanup: rm massif.out diff --git a/massif/tests/deep-B.vgtest b/massif/tests/deep-B.vgtest index f6e390d833..ea3a3234c3 100644 --- a/massif/tests/deep-B.vgtest +++ b/massif/tests/deep-B.vgtest @@ -1,5 +1,5 @@ prog: deep -vgopts: --stacks=no --time-unit=B --alloc-fn=a6 --alloc-fn=a7 --alloc-fn=a8 --alloc-fn=a9 --alloc-fn=a10 --alloc-fn=a11 --alloc-fn=a12 -v -v --depth=8 --massif-out-file=massif.out +vgopts: --stats=yes --stacks=no --time-unit=B --alloc-fn=a6 --alloc-fn=a7 --alloc-fn=a8 --alloc-fn=a9 --alloc-fn=a10 --alloc-fn=a11 --alloc-fn=a12 -v -v --depth=8 --massif-out-file=massif.out vgopts: --ignore-fn=__part_load_locale --ignore-fn=__time_load_locale --ignore-fn=dwarf2_unwind_dyld_add_image_hook --ignore-fn=get_or_create_key_element stderr_filter: filter_verbose post: perl ../../massif/ms_print massif.out | ../../tests/filter_addresses diff --git a/massif/tests/deep-C.vgtest b/massif/tests/deep-C.vgtest index b40ba36da3..34f92cda73 100644 --- a/massif/tests/deep-C.vgtest +++ b/massif/tests/deep-C.vgtest @@ -1,5 +1,5 @@ prog: deep -vgopts: --stacks=no --time-unit=B --alloc-fn=a3 --alloc-fn=a4 --alloc-fn=a5 --alloc-fn=a6 --alloc-fn=a7 --alloc-fn=a8 --alloc-fn=a9 --alloc-fn=a10 --alloc-fn=a11 --alloc-fn=a12 -v -v --depth=8 --massif-out-file=massif.out +vgopts: --stacks=no --time-unit=B --alloc-fn=a3 --alloc-fn=a4 --alloc-fn=a5 --alloc-fn=a6 --alloc-fn=a7 --alloc-fn=a8 --alloc-fn=a9 --alloc-fn=a10 --alloc-fn=a11 --alloc-fn=a12 -v -v --stats=yes --depth=8 --massif-out-file=massif.out vgopts: --ignore-fn=__part_load_locale --ignore-fn=__time_load_locale --ignore-fn=dwarf2_unwind_dyld_add_image_hook --ignore-fn=get_or_create_key_element stderr_filter: filter_verbose post: perl ../../massif/ms_print massif.out | ../../tests/filter_addresses diff --git a/massif/tests/peak2.vgtest b/massif/tests/peak2.vgtest index 91a6e49642..79e671ab19 100644 --- a/massif/tests/peak2.vgtest +++ b/massif/tests/peak2.vgtest @@ -1,5 +1,5 @@ prog: peak -vgopts: --stacks=no --time-unit=B -v -v --peak-inaccuracy=10.0 --heap-admin=128 --massif-out-file=massif.out +vgopts: --stacks=no --time-unit=B -v -v --stats=yes --peak-inaccuracy=10.0 --heap-admin=128 --massif-out-file=massif.out vgopts: --ignore-fn=__part_load_locale --ignore-fn=__time_load_locale --ignore-fn=dwarf2_unwind_dyld_add_image_hook --ignore-fn=get_or_create_key_element stderr_filter: filter_verbose post: perl ../../massif/ms_print massif.out | ../../tests/filter_addresses diff --git a/massif/tests/realloc.vgtest b/massif/tests/realloc.vgtest index 4344328979..bdb38d839e 100644 --- a/massif/tests/realloc.vgtest +++ b/massif/tests/realloc.vgtest @@ -1,5 +1,5 @@ prog: realloc -vgopts: -v -v --stacks=no --heap-admin=0 --time-unit=B --threshold=0 --massif-out-file=massif.out +vgopts: -v -v --stats=yes --stacks=no --heap-admin=0 --time-unit=B --threshold=0 --massif-out-file=massif.out vgopts: --ignore-fn=__part_load_locale --ignore-fn=__time_load_locale --ignore-fn=dwarf2_unwind_dyld_add_image_hook --ignore-fn=get_or_create_key_element stderr_filter: filter_verbose post: perl ../../massif/ms_print --threshold=0 massif.out | ../../tests/filter_addresses diff --git a/memcheck/mc_leakcheck.c b/memcheck/mc_leakcheck.c index ea1e1bea3f..2e7513aa99 100644 --- a/memcheck/mc_leakcheck.c +++ b/memcheck/mc_leakcheck.c @@ -918,6 +918,7 @@ void MC_(detect_memory_leaks) ( ThreadId tid, LeakCheckMode mode ) if (lc_n_chunks == 0) { tl_assert(lc_chunks == NULL); if (VG_(clo_verbosity) >= 1 && !VG_(clo_xml)) { + VG_(umsg)("\n"); VG_(umsg)("All heap blocks were freed -- no leaks are possible.\n"); } return; @@ -969,9 +970,11 @@ void MC_(detect_memory_leaks) ( ThreadId tid, LeakCheckMode mode ) lc_markstack_top = -1; // Verbosity. - if (VG_(clo_verbosity) > 0 && !VG_(clo_xml)) - VG_(umsg)( "searching for pointers to %'d not-freed blocks.\n", + if (VG_(clo_verbosity) > 1 && !VG_(clo_xml)) { + VG_(umsg)( "\n" ); + VG_(umsg)( "Searching for pointers to %'d not-freed blocks.\n", lc_n_chunks ); + } // Scan the memory root-set, pushing onto the mark stack any blocks // pointed to. @@ -1029,8 +1032,8 @@ void MC_(detect_memory_leaks) ( ThreadId tid, LeakCheckMode mode ) // from the root-set has been traced. lc_process_markstack(/*clique*/-1); - if (VG_(clo_verbosity) > 0 && !VG_(clo_xml)) - VG_(umsg)("checked %'lu bytes.\n", lc_scanned_szB); + if (VG_(clo_verbosity) > 1 && !VG_(clo_xml)) + VG_(umsg)("Checked %'lu bytes.\n", lc_scanned_szB); // Trace all the leaked blocks to determine which are directly leaked and // which are indirectly leaked. For each Unreached block, push it onto diff --git a/memcheck/mc_main.c b/memcheck/mc_main.c index d83464fcda..98043d5107 100644 --- a/memcheck/mc_main.c +++ b/memcheck/mc_main.c @@ -5569,15 +5569,24 @@ static void mc_fini ( Int exitcode ) { MC_(print_malloc_stats)(); - if (VG_(clo_verbosity) == 1 && !VG_(clo_xml)) { - if (MC_(clo_leak_check) == LC_Off) - VG_(message)(Vg_UserMsg, - "For a detailed leak analysis, rerun with: --leak-check=yes\n"); + if (MC_(clo_leak_check) != LC_Off) { + MC_(detect_memory_leaks)(1/*bogus ThreadId*/, MC_(clo_leak_check)); + } + if (VG_(clo_verbosity) == 1 && !VG_(clo_xml) + && MC_(clo_leak_check) == LC_Off) { VG_(message)(Vg_UserMsg, - "For counts of detected errors, rerun with: -v\n"); + "For a detailed leak analysis, rerun with: --leak-check=yes\n"); } + if (VG_(clo_verbosity) >= 1 && !VG_(clo_xml)) { + VG_(message)(Vg_UserMsg, "\n"); + } + + if (VG_(clo_verbosity) == 1 && !VG_(clo_xml)) { + VG_(message)(Vg_UserMsg, + "For counts of detected and suppressed errors, rerun with: -v\n"); + } if (MC_(any_value_errors) && !VG_(clo_xml) && VG_(clo_verbosity) >= 1 && MC_(clo_mc_level) == 2) { @@ -5586,12 +5595,9 @@ static void mc_fini ( Int exitcode ) "uninitialised values come from\n"); } - if (MC_(clo_leak_check) != LC_Off) - MC_(detect_memory_leaks)(1/*bogus ThreadId*/, MC_(clo_leak_check)); - done_prof_mem(); - if (VG_(clo_verbosity) > 1) { + if (VG_(clo_stats)) { SizeT max_secVBit_szB, max_SMs_szB, max_shmem_szB; VG_(message)(Vg_DebugMsg, diff --git a/memcheck/mc_malloc_wrappers.c b/memcheck/mc_malloc_wrappers.c index e1ceeb1a7f..bef9f5195b 100644 --- a/memcheck/mc_malloc_wrappers.c +++ b/memcheck/mc_malloc_wrappers.c @@ -902,17 +902,19 @@ void MC_(print_malloc_stats) ( void ) nbytes += (ULong)mc->szB; } - VG_(message)(Vg_UserMsg, - "malloc/free: in use at exit: %'llu bytes in %'lu blocks.\n", + VG_(umsg)( + "HEAP SUMMARY:\n" + ); + VG_(umsg)( + " in use at exit: %'llu bytes in %'lu blocks.\n", nbytes, nblocks ); - VG_(message)(Vg_UserMsg, - "malloc/free: %'lu allocs, %'lu frees, %'llu bytes allocated.\n", + VG_(umsg)( + " total heap usage: %'lu allocs, %'lu frees, " + "%'llu bytes allocated.\n", cmalloc_n_mallocs, cmalloc_n_frees, cmalloc_bs_mallocd ); - if (VG_(clo_verbosity) > 1) - VG_(message)(Vg_UserMsg, "\n"); } /*--------------------------------------------------------------------*/ diff --git a/memcheck/tests/filter_allocs b/memcheck/tests/filter_allocs index 9013deb354..5b58666b93 100755 --- a/memcheck/tests/filter_allocs +++ b/memcheck/tests/filter_allocs @@ -1,6 +1,6 @@ #! /bin/sh ./filter_stderr | -sed -e "s/malloc\/free: in use at exit: [0-9,]* bytes in [0-9,]* blocks./malloc\/free: in use at exit: ... bytes in ... blocks./" \ - -e "s/malloc.free: [0-9,]* allocs, [0-9,]* frees, [0-9,]* bytes allocated./malloc\/free: ... allocs, ... frees, ... bytes allocated./" +sed -e "s/in use at exit: [0-9,]* bytes in [0-9,]* blocks./in use at exit: ... bytes in ... blocks./" \ + -e "s/total heap usage: [0-9,]* allocs, [0-9,]* frees, [0-9,]* bytes allocated./total heap usage: ... allocs, ... frees, ... bytes allocated./" diff --git a/none/tests/cmdline1.stdout.exp b/none/tests/cmdline1.stdout.exp index ee3dfdbf20..0fab2a28ad 100644 --- a/none/tests/cmdline1.stdout.exp +++ b/none/tests/cmdline1.stdout.exp @@ -8,7 +8,7 @@ usage: valgrind [options] prog-and-args --help-debug show this message, plus debugging options --version show version -q --quiet run silently; only print error msgs - -v --verbose be more verbose, incl counts of errors + -v --verbose be more verbose -- show misc extra info --trace-children=no|yes Valgrind-ise child processes (follow execve)? [no] --child-silent-after-fork=no|yes omit child output between fork & exec? [no] --track-fds=no|yes track open file descriptors? [no] diff --git a/none/tests/cmdline2.stdout.exp b/none/tests/cmdline2.stdout.exp index dc147a448e..cb7e515c48 100644 --- a/none/tests/cmdline2.stdout.exp +++ b/none/tests/cmdline2.stdout.exp @@ -8,7 +8,7 @@ usage: valgrind [options] prog-and-args --help-debug show this message, plus debugging options --version show version -q --quiet run silently; only print error msgs - -v --verbose be more verbose, incl counts of errors + -v --verbose be more verbose -- show misc extra info --trace-children=no|yes Valgrind-ise child processes (follow execve)? [no] --child-silent-after-fork=no|yes omit child output between fork & exec? [no] --track-fds=no|yes track open file descriptors? [no] @@ -60,6 +60,7 @@ usage: valgrind [options] prog-and-args (none) debugging options for all Valgrind tools: + --stats=no|yes show tool and core statistics [no] -d show verbose debugging output --sanity-level= level of sanity checking to do [1] --trace-flags= show generated code? (X = 0|1) [00000000]