updated the assert macro to send SIGINT to the process (to break into the debugger) and also to be used on macos

This commit is contained in:
Arvid Norberg
2007-09-17 02:32:51 +00:00
parent 33add5bb91
commit 8e899fa9fd
3 changed files with 15 additions and 7 deletions

View File

@@ -34,7 +34,10 @@ POSSIBILITY OF SUCH DAMAGE.
#include <stdlib.h>
#include <stdio.h>
#include <signal.h>
#if defined __linux__ && defined __GNUC__
#include <execinfo.h>
#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