From: Bart Van Assche Date: Thu, 26 Aug 2010 10:56:27 +0000 (+0000) Subject: Added new memcheck command-line option --show-possibly-lost. Closes #201170. X-Git-Tag: svn/VALGRIND_3_6_0~165 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8122b2aaef5cb6dbe3254415e5a6ba27a4af1f7e;p=thirdparty%2Fvalgrind.git Added new memcheck command-line option --show-possibly-lost. Closes #201170. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11292 --- diff --git a/NEWS b/NEWS index 25cceb3700..ead2949dd1 100644 --- a/NEWS +++ b/NEWS @@ -29,6 +29,8 @@ Improvements: Both can be used for a better approximation of a "Cycle Estimation" as derived event (you need to update the event formula in KCachegrind yourself). +- Added new memcheck command-line option --show-possibly-lost. + Release 3.5.0 (19 August 2009) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/xml/FAQ.xml b/docs/xml/FAQ.xml index 9ee8ea3d08..983e02adde 100644 --- a/docs/xml/FAQ.xml +++ b/docs/xml/FAQ.xml @@ -528,7 +528,10 @@ int main(void) "possibly lost" means your program is leaking - memory, unless you're doing funny things with pointers. + memory, unless you're doing funny things with pointers. + This is sometimes reasonable. Use + if you don't want to see + these reports. "still reachable" means your program is probably ok -- it diff --git a/memcheck/docs/mc-manual.xml b/memcheck/docs/mc-manual.xml index 3ee00f21dc..4c75629d1f 100644 --- a/memcheck/docs/mc-manual.xml +++ b/memcheck/docs/mc-manual.xml @@ -620,6 +620,16 @@ criteria: + + + + + + When disabled, the memory leak detector will not show "possibly lost" blocks. + + + + diff --git a/memcheck/mc_include.h b/memcheck/mc_include.h index 76061985ff..c2ef03eb65 100644 --- a/memcheck/mc_include.h +++ b/memcheck/mc_include.h @@ -395,6 +395,9 @@ extern VgRes MC_(clo_leak_resolution); /* In leak check, show reachable-but-not-freed blocks? default: NO */ extern Bool MC_(clo_show_reachable); +/* In leak check, show possibly-lost blocks? default: YES */ +extern Bool MC_(clo_show_possibly_lost); + /* Assume accesses immediately below %esp are due to gcc-2.96 bugs. * default: NO */ extern Bool MC_(clo_workaround_gcc296_bugs); diff --git a/memcheck/mc_leakcheck.c b/memcheck/mc_leakcheck.c index 9bd050a6fa..2d3e6d6b7b 100644 --- a/memcheck/mc_leakcheck.c +++ b/memcheck/mc_leakcheck.c @@ -845,7 +845,8 @@ static void print_results(ThreadId tid, Bool is_full_check) print_record = is_full_check && ( MC_(clo_show_reachable) || Unreached == lr->key.state || - Possible == lr->key.state ); + ( MC_(clo_show_possibly_lost) && + Possible == lr->key.state ) ); // We don't count a leaks as errors with --leak-check=summary. // Otherwise you can get high error counts with few or no error // messages, which can be confusing. Also, you could argue that diff --git a/memcheck/mc_main.c b/memcheck/mc_main.c index 1e4d843d44..c0d8c9cb00 100644 --- a/memcheck/mc_main.c +++ b/memcheck/mc_main.c @@ -4744,6 +4744,7 @@ Long MC_(clo_freelist_vol) = 10*1000*1000LL; LeakCheckMode MC_(clo_leak_check) = LC_Summary; VgRes MC_(clo_leak_resolution) = Vg_HighRes; Bool MC_(clo_show_reachable) = False; +Bool MC_(clo_show_possibly_lost) = True; Bool MC_(clo_workaround_gcc296_bugs) = False; Int MC_(clo_malloc_fill) = -1; Int MC_(clo_free_fill) = -1; @@ -4793,6 +4794,8 @@ static Bool mc_process_cmd_line_options(Char* arg) if VG_BOOL_CLO(arg, "--partial-loads-ok", MC_(clo_partial_loads_ok)) {} else if VG_BOOL_CLO(arg, "--show-reachable", MC_(clo_show_reachable)) {} + else if VG_BOOL_CLO(arg, "--show-possibly-lost", + MC_(clo_show_possibly_lost)) {} else if VG_BOOL_CLO(arg, "--workaround-gcc296-bugs", MC_(clo_workaround_gcc296_bugs)) {} @@ -4863,6 +4866,8 @@ static void mc_print_usage(void) " --leak-check=no|summary|full search for memory leaks at exit? [summary]\n" " --leak-resolution=low|med|high differentiation of leak stack traces [high]\n" " --show-reachable=no|yes show reachable blocks in leak check? [no]\n" +" --show-possibly-lost=no|yes show possibly lost blocks in leak check?\n" +" [yes]\n" " --undef-value-errors=no|yes check for undefined value errors [yes]\n" " --track-origins=no|yes show origins of undefined values? [no]\n" " --partial-loads-ok=no|yes too hard to explain here; see manual [no]\n" diff --git a/memcheck/tests/Makefile.am b/memcheck/tests/Makefile.am index 8bcae42607..3280896770 100644 --- a/memcheck/tests/Makefile.am +++ b/memcheck/tests/Makefile.am @@ -74,6 +74,7 @@ EXTRA_DIST = \ inline.stderr.exp inline.stdout.exp inline.vgtest \ leak-0.vgtest leak-0.stderr.exp \ leak-cases-full.vgtest leak-cases-full.stderr.exp \ + leak-cases-possible.vgtest leak-cases-possible.stderr.exp \ leak-cases-summary.vgtest leak-cases-summary.stderr.exp \ leak-cycle.vgtest leak-cycle.stderr.exp \ leak-pool-0.vgtest leak-pool-0.stderr.exp \ diff --git a/memcheck/tests/leak-cases-possible.stderr.exp b/memcheck/tests/leak-cases-possible.stderr.exp new file mode 100644 index 0000000000..27672122ac --- /dev/null +++ b/memcheck/tests/leak-cases-possible.stderr.exp @@ -0,0 +1,22 @@ +leaked: 80 bytes in 5 blocks +dubious: 96 bytes in 6 blocks +reachable: 64 bytes in 4 blocks +suppressed: 0 bytes in 0 blocks +16 bytes in 1 blocks are definitely lost in loss record ... of ... + at 0x........: malloc (vg_replace_malloc.c:...) + by 0x........: mk (leak-cases.c:52) + by 0x........: f (leak-cases.c:74) + by 0x........: main (leak-cases.c:107) + +32 (16 direct, 16 indirect) bytes in 1 blocks are definitely lost in loss record ... of ... + at 0x........: malloc (vg_replace_malloc.c:...) + by 0x........: mk (leak-cases.c:52) + by 0x........: f (leak-cases.c:76) + by 0x........: main (leak-cases.c:107) + +32 (16 direct, 16 indirect) bytes in 1 blocks are definitely lost in loss record ... of ... + at 0x........: malloc (vg_replace_malloc.c:...) + by 0x........: mk (leak-cases.c:52) + by 0x........: f (leak-cases.c:91) + by 0x........: main (leak-cases.c:107) + diff --git a/memcheck/tests/leak-cases-possible.vgtest b/memcheck/tests/leak-cases-possible.vgtest new file mode 100644 index 0000000000..50f8fda224 --- /dev/null +++ b/memcheck/tests/leak-cases-possible.vgtest @@ -0,0 +1,2 @@ +prog: leak-cases +vgopts: -q --leak-check=full --leak-resolution=high --show-possibly-lost=no