Electric Fence && Leopard (Mac OS X 10.5.x) && CMake

You can get Electric Fence from http://perens.com/works/software/ElectricFence/

Comment out line #33 of file.c

$ make CFLAGS="-g -DPAGE_PROTECTION_VIOLATED_SIGNAL=SIGBUS"
# make install

You will have a libefence compiled and installed in your Mac OS X system.

Now add the library to your main target in your CMakeLists.txt

# Add efence link
find_library(EFENCE_LIBRARY "libefence.a")
target_link_libraries(YOUR_MAIN_TARGET ${EFENCE_LIBRARY})

cmake and make (or build or whatever you are generating)

$ gdb /path/to/executable
(gdb) r
(gdb) bt

And useful debug info and an electric fence will appear :)

Have fun!