Can I make valgrind ignore glibc libraries?

后端 未结 4 1008
青春惊慌失措
青春惊慌失措 2020-12-17 18:23

Is it possible to tell valgrind to ignore some set of libraries? Specifically glibc libraries..

Actual Problem: I have some code that runs fine in normal execution.

4条回答
  •  执念已碎
    2020-12-17 19:21

    This probably doesn't answer your question, but will provide you the specifics of how to suppress certain errors (which others have alluded to but have not described in detail):

    First, run valgrind as follows:

     valgrind --gen-suppressions=all --log-file=valgrind.out ./a.out
    

    Now the output file valgrind.out will contain some automatically-generated suppression blocks like the following:

    {
       stupid sendmsg bug: http://sourceware.org/bugzilla/show_bug.cgi?id=14687
       Memcheck:Param
       sendmsg(mmsg[0].msg_hdr)
       fun:sendmmsg
       obj:/usr/lib/libresolv-2.17.so
       fun:__libc_res_nquery
       obj:/usr/lib/libresolv-2.17.so
       fun:__libc_res_nsearch
       fun:_nss_dns_gethostbyname4_r
       fun:gaih_inet
       fun:getaddrinfo
       fun:get_socket_fd
       fun:main
    }
    

    Where "stupid sendmsg bug" and the link are the name that I added to refer to this block. Now, save that block to sendmsg.supp and tell valgrind about that file on the next run:

    valgrind --log-file=valgrind --suppressions=sendmsg.supp ./a.out
    

    And valgrind will graciously ignore that stupid upstream bug.

提交回复
热议问题