I am running OS X El Capitan 10.11. I use homebrew to install valgrind; it installs valgrind-3.11.0. I try to run on a program [[programname]] I built. I get: valgrind: [[programname]]: cannot execute binary file After some time tinkering, I discover I get this error message for all 32-bit executables, but never for 64-bit executables. I do some research and I discover that there is a totally sensible reason for this: Homebrew currently builds valgrind for El Capitan with the --enable-only64bit flag at configure time. Okay, mystery solved-- it makes sense valgrind cannot operate on the file. However, there is still a problem: This is not a good error message. The message gave me no indication the nature of the problem, and running valgrind with -v gave no additional prints in this case. Figuring out what was wrong (was something special about the file? was my Valgrind broken?) took some time. Searching Google for the error message, I find years of (stack overflow, etc) postings of (mostly mac users running ports or homebrew) users having difficulty understanding the message, and usually it turns out to come down to the valgrind binary having been built 32 or 64 bit only, so apparently I was not the only one to be confused by this. Expected behavior: Valgrind knows whether it was built in 32 or 64 bit mode. Even when built in 64 bit only mode, it could be aware that 32 bit mode *exists*. Valgrind could in principle detect that the binary is 32 bit mach-o, and print a message like valgrind: [[programname]]: Cannot execute 32-bit binary file. This copy of Valgrind is 64-bit only. This would improve user friendliness for newbies. (Filing as platform unspecified because the same error message for the same situation exists on Linux.) Simple repro steps: $ echo -e "#include <stdio.h>\nint main() { printf(\"Alive\"); }" > test.c $ gcc -m32 test.c $ valgrind ./a.out valgrind: ./a.out: cannot execute binary file
With: austin@debian-laptop:~/src/valgrind$ ./vg-in-place --version -v valgrind-3.13.0.SVN-16209-vex-3299 the error message has improved (64-bit valgrind, 32-bit binary): austin@debian-laptop:~/src/valgrind$ ./vg-in-place /tmp/a.out valgrind: failed to start tool 'memcheck' for platform 'x86-linux': No such file or directory Recompiling as 64-bit binary: austin@debian-laptop:~/src/valgrind$ ./vg-in-place /tmp/a.out ==19785== Memcheck, a memory error detector ==19785== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al. ==19785== Using Valgrind-3.13.0.SVN and LibVEX; rerun with -h for copyright info ==19785== Command: /tmp/a.out ==19785== Alive==19785== ==19785== HEAP SUMMARY: ==19785== in use at exit: 0 bytes in 0 blocks ==19785== total heap usage: 1 allocs, 1 frees, 1,024 bytes allocated ==19785== ==19785== All heap blocks were freed -- no leaks are possible ==19785== ==19785== For counts of detected and suppressed errors, rerun with: -v ==19785== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) Fixed.