3

I use massif, sgcheck and memcheck valgrind's modules to check a c/c++ project. I would like to know if it is possible to make valgrind ignore part of code. When I run it on my project I have something like 248 different "false" errors generated by opencv call. It is normal but currently I can't really avoid this call, that why I would like to make valgrind ignore this part of code.

I try to do generate a file to "suppress" his error by adding --gen-suppressions=all --log-file=valgrind.out to my command line to generated a file to ignore the error. But there is some "hand process" to do, like remove 248 bloc in the log file, and I would like to avoid it.

So : do you know if there is a way (a bit like ifdef or ifndef maybe) to make valgrind ignore a part of code ?

Thx !

Bastienm
  • 363
  • 2
  • 16
  • Are you sure that those errors are false? – user7860670 Jan 11 '18 at 10:58
  • I said "false" because they are true but in open cv. And this opencv function is used only for debugging. But in fact they are true, I know it and I would like to ignore them – Bastienm Jan 11 '18 at 13:29
  • 1
    This is not a duplicate because I tryed the --suppression valgrind's option. But in my case there is a lot of thing to edit in the output file and I would like to avoid it. That's why I'm trying to find a mechanism a bit like `#ifdef` in c++ to ignore a part of the code – Bastienm Jan 11 '18 at 13:33
  • @Bastienm Rather than adding a solution to your question, post it as an answer. – Ken Wayne VanderLinde Jan 11 '18 at 15:58
  • @KenWayneVanderLinde : ok, I changed it. – Bastienm Jan 11 '18 at 16:01

1 Answers1

0

Finally I did it using --gen-suppressions=all --log-file=valgrind.out :

  • Add --gen-suppressions=all –log-file=valgrind_tmp.out to memcheck command
  • sed '/==/ d' valgrind_tmp.out > valgrind.out to remove all the useless lines
  • now run memcheck with --suppressions=valgrind.out

So I did not find a way to make memcheck avoid specific part of code, I'm just filtering the error output.

Bastienm
  • 363
  • 2
  • 16