diff --git a/Jamfile b/Jamfile index c100d6c24..c26881568 100755 --- a/Jamfile +++ b/Jamfile @@ -106,12 +106,12 @@ rule building ( properties * ) { local result ; - if gcc in $(properties) - && linux in $(properties) - && debug in $(properties) + if debug in $(properties) + && ( linux in $(properties) + || darwin in $(properties) ) + && ( gcc in $(properties) + || darwin in $(properties) ) { - # for backtraces in assertion failures - # which only works on ELF targets with gcc result += src/assert.cpp ; } diff --git a/include/libtorrent/assert.hpp b/include/libtorrent/assert.hpp index 62425809e..5c57e1d23 100644 --- a/include/libtorrent/assert.hpp +++ b/include/libtorrent/assert.hpp @@ -33,7 +33,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #ifndef NDEBUG -#if defined __linux__ && defined __GNUC__ +#if (defined __linux__ || defined __MACH__) && defined __GNUC__ #ifdef assert #undef assert #endif diff --git a/src/assert.cpp b/src/assert.cpp index da79a745b..b4f011978 100644 --- a/src/assert.cpp +++ b/src/assert.cpp @@ -34,7 +34,10 @@ POSSIBILITY OF SUCH DAMAGE. #include #include +#include +#if defined __linux__ && defined __GNUC__ #include +#endif void assert_fail(char const* expr, int line, char const* file, char const* function) { @@ -48,6 +51,7 @@ void assert_fail(char const* expr, int line, char const* file, char const* funct "expression: %s\n" "stack:\n", file, line, function, expr); +#if defined __linux__ && defined __GNUC__ void* stack[50]; int size = backtrace(stack, 50); char** symbols = backtrace_symbols(stack, size); @@ -58,7 +62,11 @@ void assert_fail(char const* expr, int line, char const* file, char const* funct } free(symbols); - exit(1); +#endif + // send SIGINT to the current process + // to break into the debugger + raise(SIGINT); + abort(); } #endif