]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Added new memcheck command-line option --show-possibly-lost. Closes #201170.
authorBart Van Assche <bvanassche@acm.org>
Thu, 26 Aug 2010 10:56:27 +0000 (10:56 +0000)
committerBart Van Assche <bvanassche@acm.org>
Thu, 26 Aug 2010 10:56:27 +0000 (10:56 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11292

NEWS
docs/xml/FAQ.xml
memcheck/docs/mc-manual.xml
memcheck/mc_include.h
memcheck/mc_leakcheck.c
memcheck/mc_main.c
memcheck/tests/Makefile.am
memcheck/tests/leak-cases-possible.stderr.exp [new file with mode: 0644]
memcheck/tests/leak-cases-possible.vgtest [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 25cceb370031061e051b4e93d497f88ffef99a35..ead2949dd1be88482e85f966940ffcb5534ea581 100644 (file)
--- 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)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
index 9ee8ea3d0876ef7efa668f4c80f84adecbd4bf33..983e02adde4228cde678ac65ff031014086247fe 100644 (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
index 3ee00f21dc69193b8582aeae2eb68ba3e1c47c39..4c75629d1f61d70df88971a2814bca97f2808413 100644 (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>
index 76061985ff190787ea949b7c142a1b5059f87eaa..c2ef03eb65fa0f5a9658f1ed00118bec2780900a 100644 (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);
index 9bd050a6fa905d476ca713bca6edc86654e1eda7..2d3e6d6b7bf776ff2bc5b46a415f8ce051c715ff 100644 (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
index 1e4d843d44efa76d73e2721751601aff8baa0148..c0d8c9cb003fd854427a4f20a72a6d74ab6b3860 100644 (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"
index 8bcae42607ad1889840ec5a334a69025d48ebb3f..328089677013ec0fa0d3daa7da57935891c9e8cb 100644 (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 \
diff --git a/memcheck/tests/leak-cases-possible.stderr.exp b/memcheck/tests/leak-cases-possible.stderr.exp
new file mode 100644 (file)
index 0000000..2767212
--- /dev/null
@@ -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 (file)
index 0000000..50f8fda
--- /dev/null
@@ -0,0 +1,2 @@
+prog: leak-cases
+vgopts: -q --leak-check=full --leak-resolution=high --show-possibly-lost=no