Search code examples
cvalgrind

How to make valgrind ignore certain line?


for example

==26460== 2 bytes in 1 blocks are still reachable in loss record 2 of 105
==26460==    at 0x4C28BE3: malloc (vg_replace_malloc.c:299)
==26460==    by 0x580D889: strdup (in /usr/lib64/libc-2.17.so)
==26460==    by 0x4F50AF: init (init.c:468)
==26460==    by 0x406D75: main (main.c:825)

I want to not check init.c:468: mode = strdup, i'm sure this only malloc once, and will last whole process life.

Is it possible to make valgrind not check this line?


Solution

  • As I said in my comment: I recommend not to.

    But Valgrind does have a feature to suppress warnings. The most convenient way of suppressing a specific message is supported by the feature dedicated to exactly that purpose:

    --gen-suppressions=yes
    

    Which apparently will ouptput the precise suppression syntax for each/any generated message.

    See 5.1 in the FAQ:
    http://valgrind.org/docs/manual/faq.html#faq.writesupp

    (I love their style:
    "F:Can you write ... for me?" and I expected a totally adequate
    "A:No." But they actually answer
    "A: Yes ...". Beyond cool.)