From fd5b4b7fa02022c1fcf2412dab646aadce03e115 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Tue, 2 Dec 2003 10:17:44 +0000 Subject: [PATCH] Make --leak-check observe -q properly -- only prints out errors, not general info and summaries. MERGE TO STABLE git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2082 --- memcheck/mac_leakcheck.c | 42 ++++++++++++++----------- memcheck/tests/nanoleak.stderr.exp | 11 ------- memcheck/tests/nanoleak_supp.stderr.exp | 11 ------- memcheck/tests/trivialleak.stderr.exp | 11 ------- 4 files changed, 23 insertions(+), 52 deletions(-) diff --git a/memcheck/mac_leakcheck.c b/memcheck/mac_leakcheck.c index 508407568..a5966126c 100644 --- a/memcheck/mac_leakcheck.c +++ b/memcheck/mac_leakcheck.c @@ -421,8 +421,10 @@ void MAC_(do_detect_memory_leaks) ( return; } - VG_(message)(Vg_UserMsg, "searching for pointers to %d not-freed blocks.", - lc_n_shadows ); + if (VG_(clo_verbosity) > 0) + VG_(message)(Vg_UserMsg, + "searching for pointers to %d not-freed blocks.", + lc_n_shadows ); lc_min_mallocd_addr = lc_shadows[0]->data; lc_max_mallocd_addr = lc_shadows[lc_n_shadows-1]->data @@ -441,7 +443,8 @@ void MAC_(do_detect_memory_leaks) ( &vg_detect_memory_leaks_notify_addr ); - VG_(message)(Vg_UserMsg, "checked %d bytes.", bytes_notified); + if (VG_(clo_verbosity) > 0) + VG_(message)(Vg_UserMsg, "checked %d bytes.", bytes_notified); /* Common up the lost blocks so we can print sensible error messages. */ n_lossrecords = 0; @@ -526,23 +529,24 @@ void MAC_(do_detect_memory_leaks) ( p_min->num_blocks = 0; } - VG_(message)(Vg_UserMsg, ""); - VG_(message)(Vg_UserMsg, "LEAK SUMMARY:"); - VG_(message)(Vg_UserMsg, " definitely lost: %d bytes in %d blocks.", - MAC_(bytes_leaked), blocks_leaked ); - VG_(message)(Vg_UserMsg, " possibly lost: %d bytes in %d blocks.", - MAC_(bytes_dubious), blocks_dubious ); - VG_(message)(Vg_UserMsg, " still reachable: %d bytes in %d blocks.", - MAC_(bytes_reachable), blocks_reachable ); - VG_(message)(Vg_UserMsg, " suppressed: %d bytes in %d blocks.", - MAC_(bytes_suppressed), blocks_suppressed ); - if (!MAC_(clo_show_reachable)) { - VG_(message)(Vg_UserMsg, - "Reachable blocks (those to which a pointer was found) are not shown."); - VG_(message)(Vg_UserMsg, - "To see them, rerun with: --show-reachable=yes"); + if (VG_(clo_verbosity) > 0) { + VG_(message)(Vg_UserMsg, ""); + VG_(message)(Vg_UserMsg, "LEAK SUMMARY:"); + VG_(message)(Vg_UserMsg, " definitely lost: %d bytes in %d blocks.", + MAC_(bytes_leaked), blocks_leaked ); + VG_(message)(Vg_UserMsg, " possibly lost: %d bytes in %d blocks.", + MAC_(bytes_dubious), blocks_dubious ); + VG_(message)(Vg_UserMsg, " still reachable: %d bytes in %d blocks.", + MAC_(bytes_reachable), blocks_reachable ); + VG_(message)(Vg_UserMsg, " suppressed: %d bytes in %d blocks.", + MAC_(bytes_suppressed), blocks_suppressed ); + if (!MAC_(clo_show_reachable)) { + VG_(message)(Vg_UserMsg, + "Reachable blocks (those to which a pointer was found) are not shown."); + VG_(message)(Vg_UserMsg, + "To see them, rerun with: --show-reachable=yes"); + } } - VG_(message)(Vg_UserMsg, ""); VG_(free) ( lc_shadows ); VG_(free) ( lc_reachedness ); diff --git a/memcheck/tests/nanoleak.stderr.exp b/memcheck/tests/nanoleak.stderr.exp index 9ed81965a..57fdf3c3b 100644 --- a/memcheck/tests/nanoleak.stderr.exp +++ b/memcheck/tests/nanoleak.stderr.exp @@ -1,15 +1,4 @@ -searching for pointers to 1 not-freed blocks. -checked ... bytes. 1000 bytes in 1 blocks are definitely lost in loss record 1 of 1 at 0x........: malloc (vg_replace_malloc.c:...) by 0x........: main (nanoleak.c:6) - -LEAK SUMMARY: - definitely lost: 1000 bytes in 1 blocks. - possibly lost: 0 bytes in 0 blocks. - still reachable: 0 bytes in 0 blocks. - suppressed: 0 bytes in 0 blocks. -Reachable blocks (those to which a pointer was found) are not shown. -To see them, rerun with: --show-reachable=yes - diff --git a/memcheck/tests/nanoleak_supp.stderr.exp b/memcheck/tests/nanoleak_supp.stderr.exp index 3e620b322..e69de29bb 100644 --- a/memcheck/tests/nanoleak_supp.stderr.exp +++ b/memcheck/tests/nanoleak_supp.stderr.exp @@ -1,11 +0,0 @@ -searching for pointers to 1 not-freed blocks. -checked ... bytes. - -LEAK SUMMARY: - definitely lost: 0 bytes in 0 blocks. - possibly lost: 0 bytes in 0 blocks. - still reachable: 0 bytes in 0 blocks. - suppressed: 1000 bytes in 1 blocks. -Reachable blocks (those to which a pointer was found) are not shown. -To see them, rerun with: --show-reachable=yes - diff --git a/memcheck/tests/trivialleak.stderr.exp b/memcheck/tests/trivialleak.stderr.exp index ad41678d5..1bd6e545f 100644 --- a/memcheck/tests/trivialleak.stderr.exp +++ b/memcheck/tests/trivialleak.stderr.exp @@ -1,16 +1,5 @@ -searching for pointers to 1000 not-freed blocks. -checked ... bytes. 1000 bytes in 1000 blocks are definitely lost in loss record 1 of 1 at 0x........: malloc (vg_replace_malloc.c:...) by 0x........: test (trivialleak.c:8) by 0x........: main (trivialleak.c:12) - -LEAK SUMMARY: - definitely lost: 1000 bytes in 1000 blocks. - possibly lost: 0 bytes in 0 blocks. - still reachable: 0 bytes in 0 blocks. - suppressed: 0 bytes in 0 blocks. -Reachable blocks (those to which a pointer was found) are not shown. -To see them, rerun with: --show-reachable=yes -