How to install Valgrind on macOS Mojave(10.14) with Homebrew?

前端 未结 10 1232
梦谈多话
梦谈多话 2020-12-04 08:58

I tried to install Valgrind with brew install Valgrind and got :

valgrind: This formula either does not compile or function as expected
on macOS         


        
相关标签:
10条回答
  • 2020-12-04 09:39

    You may use Experimental Version of Valgrind for macOS 10.14.5 Mojave at:

    https://github.com/sowson/valgrind

    The command to use it is:

    brew install --HEAD https://raw.githubusercontent.com/sowson/valgrind/master/valgrind.rb
    

    It is still experimental and needs some work but for simple projects works already... Enjoy!

    0 讨论(0)
  • 2020-12-04 09:40

    I have just found a working solution to use VALGRIND on my Mac (Mojave 10.14.6). Just run this command :

    brew install --HEAD https://raw.githubusercontent.com/LouisBrunner/valgrind-macos/master/valgrind.rb
    

    (From https://github.com/LouisBrunner/valgrind-macos)

    Hope it will work for you.

    0 讨论(0)
  • 2020-12-04 09:43

    As of 2019-NOV-30, it is possible to build against OS X 10.14.6 via https://github.com/sowson/valgrind and https://github.com/LouisBrunner/valgrind-macos

    However, there are many test failures (see the LouisBrunner link), noise during runs, and SEGVs when running against non-trivial programs: installing is, well, installing. YMMV.

    0 讨论(0)
  • 2020-12-04 09:45

    Not a proper solution for macOs, but for the time being, I created a docker image. After installing docker for macOS, this is how to start valgrind:

    cd </path/to/source/directory/where/you/want/run/valgrind/with>
    curl -O https://raw.githubusercontent.com/biocyberman/ValgrindDocker/master/startValgrind
    ./startValgrind # this will takes time for the first time, because it needs to fetch docker valgrind image
    # you will get a root command prompt inside the docker image. 
    # do what ever you want
    # type 'exit' to quit
    
    0 讨论(0)
  • 2020-12-04 09:46

    addition: I found this one worked for me on my OSX 10.14

    brew install --HEAD https://raw.githubusercontent.com/LouisBrunner/valgrind-macos/master/valgrind.rb
    

    A branch that is working to get OSX correct. something to tide us over until we get a real valgrind version fixed.

    0 讨论(0)
  • 2020-12-04 09:47

    You can follow alex.m's answer to get valgrind, but if you'r using it on a int main() { return 0; } program, you'll get many weird errors, and non-existing allocs / free.

    To 'hide' these annoying errors, you can follow theses steps (it's more a workaround than a real fix) (based on this wiki page and some research in Valgrind's source code):

    • First, create and compile a int main() { return 0; } program.
    • Execute the following command (to create file containing error suppression):

    valgrind --leak-check=full --show-reachable=yes --error-limit=no --gen-supressions=all --log-file=$YOUR_LOG$ $YOUR_BINARY$

    • Using this gawk script, create the .supp valgrind file:

    cat ./$YOUR_LOG$ | ./$YOUR_SCRIPT_FILE$ > minimal.supp

    • Copy and Past minimal.supp content at the end of $YOUR_VALGRIND_INSTALLATION_PATH$/lib/valgrind/default.supp file

    And you are done! Weird and nonexistent errors will be ignored. If you also want's to remove the non-existing allocs, frees etc, you can directly edit Valgrind's source code. Or just use heapusage for leak-tracking

    0 讨论(0)
提交回复
热议问题