Added new memcheck command-line option --show-possibly-lost. Closes #201170.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11292
This commit is contained in:
Bart Van Assche 2010-08-26 10:56:27 +00:00
parent d8f43a43a1
commit 8122b2aaef
9 changed files with 51 additions and 2 deletions

2
NEWS
View File

@ -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)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -528,7 +528,10 @@ int main(void)
</listitem>
<listitem>
<para>"possibly lost" means your program is leaking
memory, unless you're doing funny things with pointers.</para>
memory, unless you're doing funny things with pointers.
This is sometimes reasonable. Use
<option>--show-possibly-lost=no</option> if you don't want to see
these reports.</para>
</listitem>
<listitem>
<para>"still reachable" means your program is probably ok -- it

View File

@ -620,6 +620,16 @@ criteria:</para>
</listitem>
</varlistentry>
<varlistentry id="opt.show-possibly-lost" xreflabel="--show-possibly-lost">
<term>
<option><![CDATA[--show-possibly-lost=<yes|no> [default: yes] ]]></option>
</term>
<listitem>
<para>When disabled, the memory leak detector will not show "possibly lost" blocks.
</para>
</listitem>
</varlistentry>
<varlistentry id="opt.leak-resolution" xreflabel="--leak-resolution">
<term>
<option><![CDATA[--leak-resolution=<low|med|high> [default: high] ]]></option>

View File

@ -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);

View File

@ -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

View File

@ -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"

View File

@ -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 \

View File

@ -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)

View File

@ -0,0 +1,2 @@
prog: leak-cases
vgopts: -q --leak-check=full --leak-resolution=high --show-possibly-lost=no