Mac で Valgrind
Valgrind の次期バージョンである 3.5 から Mac 環境をサポートするそうだ.
まだリリースはされていないけど,svn の trunk には既にきている.
以下,NEWS から引用
* Mac OS X is now supported. (Note that Mac OS X is often called "Darwin" because that is the name of the OS core.) Supported machines: - x86 machines are supported fairly well. - AMD64 (a.k.a. x86-64) are supported, but not as well. - Older PowerPC machines are not supported. - It requires Mac OS X 10.5 Leopard or later. Porting to 10.4 is not planned because it would require work and 10.4 is only becoming less common. Things that don't work: - Objective-C garbage collection - --db-attach=yes - Messages like the following indicate a mismatch between Valgrind's memory map and the kernel. Occasional failures are expected in multithreaded programs. If the failure repeats for the same address range, then there may be a problem causing false errors or crashes. sync check at ...: FAILED - If you have Rogue Amoeba's "Instant Hijack" program installed, Valgrind will fail with a SIGTRAP at start-up. This is apparently Instant Hijack's fault. See https://bugs.kde.org/show_bug.cgi?id=193917 for details and a simple work-around. Many thanks to Greg Parker for developing this port over several years.
x86 の Leopard ならよく動くようなので,早速インストールしてみた.
特につまづくところもなく,./autogen.sh && ./configure -C --prefix=/usr/local && make -j4 && make check && sudo make install で終了.
適当な短いサンプルで試したところ,どうやらうまく動いているようだった.
memcheck, chachegrind, callgrind, helgrind といった主要な tool は動く模様.
/usr/local/lib/valgrind には drd-x86-darwin, exp-ptrcheck-x86-darwin もあるけど,どちらも "doesn't work on Darwin yet, sorry." とのこと.
これで Mac でのデバッグも多少は楽になるかもしれませんね.
あとは ltrace とか strace があれば…! DTrace はイマイチよくわからん.