]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
massif: match --ignore-fn with the first IP that has a fnname
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Sat, 23 Sep 2017 11:26:12 +0000 (13:26 +0200)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Sat, 23 Sep 2017 11:30:42 +0000 (13:30 +0200)
Currently, --ignore-fn is only matched with the top IP entries that
have a fnname. With this change, we first search for the first IP that
has a fnname.
This e.g. allows to ignore the allocation for a stacktrace such as:
   0x1 0x2 0x3 fn_to_ignore otherfn

This is then used in massif c++ tests new-cpp and overloaded-new to ignore
the c++ libstdc++ allocation similar to:
==10754== 72,704 bytes in 1 blocks are still reachable in loss record 10 of 10
==10754==    at 0x4C2BBCD: malloc (vg_replace_malloc.c:299)
==10754==    by 0x4EC39BF: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.22)
==10754==    by 0x400F8A9: call_init.part.0 (dl-init.c:72)
==10754==    by 0x400F9BA: call_init (dl-init.c:30)
==10754==    by 0x400F9BA: _dl_init (dl-init.c:120)
==10754==    by 0x4000C59: ??? (in /lib/x86_64-linux-gnu/ld-2.24.so)

massif/ms_main.c
massif/tests/new-cpp.post.exp
massif/tests/new-cpp.vgtest
massif/tests/overloaded-new.post.exp
massif/tests/overloaded-new.vgtest

index 953eda7e820800516f90c692cc9d13584726e998..37488212401fd89518eaf4e83fbb91431d65d27f 100644 (file)
@@ -507,7 +507,7 @@ void filter_IPs (Addr* ips, Int n_ips,
                  UInt* top, UInt* n_ips_sel)
 {
    Int i;
-   Bool top_has_fnname;
+   Bool top_has_fnname = False;
    const HChar *fnname;
 
    *top = 0;
@@ -519,7 +519,7 @@ void filter_IPs (Addr* ips, Int n_ips,
    //  'sliding' a bunch of functions without names by removing an
    //  alloc function 'inside' a stacktrace e.g.
    //    0x1 0x2 0x3 alloc func1 main
-   //  becomes   0x1 0x2 0x3 func1 main
+   //  became   0x1 0x2 0x3 func1 main
    for (i = *top; i < n_ips; i++) {
       top_has_fnname = VG_(get_fnname)(ips[*top], &fnname);
       if (top_has_fnname &&  VG_(strIsMemberXA)(alloc_fns, fnname)) {
@@ -532,14 +532,19 @@ void filter_IPs (Addr* ips, Int n_ips,
    }
 
    // filter the whole stacktrace if this allocation has to be ignored.
-   if (*n_ips_sel > 0 
-       && top_has_fnname 
-       && VG_(strIsMemberXA)(ignore_fns, fnname)) {
-      VERB(4, "ignored allocation from fn %s\n", fnname);
-      *top = n_ips;
-      *n_ips_sel = 0;
-   }
-       
+   if (*n_ips_sel > 0 && VG_(sizeXA)(ignore_fns) > 0) {
+      if (!top_has_fnname) {
+         // top has no fnname => search for the first entry that has a fnname
+         for (i = *top; i < n_ips && !top_has_fnname; i++) {
+            top_has_fnname = VG_(get_fnname)(ips[i], &fnname);
+         }
+      }
+      if (top_has_fnname && VG_(strIsMemberXA)(ignore_fns, fnname)) {
+         VERB(4, "ignored allocation from fn %s\n", fnname);
+         *top = n_ips;
+         *n_ips_sel = 0;
+      }
+   }       
 
    if (!VG_(clo_show_below_main) && *n_ips_sel > 0 ) {
       Int mbm = VG_(XT_offset_main_or_below_main)(ips, n_ips);
index 1fe91e60ce9b93e40cfc11bd5516df765b333eff..9d90cf6c220fd52b9f6fefc9ecb39fc1bf98d89c 100644 (file)
@@ -1,6 +1,6 @@
 --------------------------------------------------------------------------------
 Command:            ./new-cpp
-Massif arguments:   --stacks=no --time-unit=B --massif-out-file=massif.out --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 --ignore-fn=_GLOBAL__sub_I_eh_alloc.cc
+Massif arguments:   --stacks=no --time-unit=B --massif-out-file=massif.out --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 --ignore-fn=_GLOBAL__sub_I_eh_alloc.cc --ignore-fn=call_init.part.0
 ms_print arguments: massif.out
 --------------------------------------------------------------------------------
 
index 09dba32977b24051ca8316e94b7a814c26ea02ba..88bdf939b99581c2dbb0bcc24c6d0df401bad43e 100644 (file)
@@ -1,6 +1,6 @@
 prog: new-cpp
 vgopts: --stacks=no --time-unit=B --massif-out-file=massif.out
 vgopts: --ignore-fn=__part_load_locale --ignore-fn=__time_load_locale --ignore-fn=dwarf2_unwind_dyld_add_image_hook
-vgopts: --ignore-fn=get_or_create_key_element --ignore-fn=_GLOBAL__sub_I_eh_alloc.cc
+vgopts: --ignore-fn=get_or_create_key_element --ignore-fn=_GLOBAL__sub_I_eh_alloc.cc --ignore-fn=call_init.part.0
 post: perl ../../massif/ms_print massif.out | ../../tests/filter_addresses
 cleanup: rm massif.out
index 2a53b90b706b37d3342fc7b7d412b0b0c16dbab0..e55885fc577055edc9cc3855f5d16ef2cfa12563 100644 (file)
@@ -1,6 +1,6 @@
 --------------------------------------------------------------------------------
 Command:            ./overloaded-new
-Massif arguments:   --stacks=no --time-unit=B --massif-out-file=massif.out --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 --ignore-fn=_GLOBAL__sub_I_eh_alloc.cc
+Massif arguments:   --stacks=no --time-unit=B --massif-out-file=massif.out --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 --ignore-fn=_GLOBAL__sub_I_eh_alloc.cc --ignore-fn=call_init.part.0
 ms_print arguments: massif.out
 --------------------------------------------------------------------------------
 
index 2ffb3eceb4c316fcf0d11362207adf803ef350b3..20bcd97e62925d019ac8fa7917fc931133b969c9 100644 (file)
@@ -1,6 +1,6 @@
 prog: overloaded-new
 vgopts: --stacks=no --time-unit=B --massif-out-file=massif.out
 vgopts: --ignore-fn=__part_load_locale --ignore-fn=__time_load_locale --ignore-fn=dwarf2_unwind_dyld_add_image_hook
-vgopts: --ignore-fn=get_or_create_key_element --ignore-fn=_GLOBAL__sub_I_eh_alloc.cc
+vgopts: --ignore-fn=get_or_create_key_element --ignore-fn=_GLOBAL__sub_I_eh_alloc.cc --ignore-fn=call_init.part.0
 post: perl ../../massif/ms_print massif.out | ../../tests/filter_addresses
 cleanup: rm massif.out