From 4b7d25145c14bec7d4f0e657435753372a463c6c Mon Sep 17 00:00:00 2001 From: Christian Ohm Date: Sat, 26 Jun 2010 19:57:29 +0000 Subject: [PATCH] In our assert macros, raise(SIGTRAP) instead of assert(). Also ignore SIGTRAP, so no crashdump will be generated for it. Makes it possible to continue after an assert while debugging. Closes #1940. git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/branches/qt-trunk@11045 4a71c877-e1ca-e34f-864e-861f7616d084 --- lib/exceptionhandler/exceptionhandler.c | 8 ++++---- lib/framework/debug.h | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/exceptionhandler/exceptionhandler.c b/lib/exceptionhandler/exceptionhandler.c index 8e512e9e0..a8c59083a 100644 --- a/lib/exceptionhandler/exceptionhandler.c +++ b/lib/exceptionhandler/exceptionhandler.c @@ -335,10 +335,6 @@ static void setFatalSignalHandler(SigActionHandler signalHandler) if (oldAction[SIGSYS].sa_handler != SIG_IGN) sigaction(SIGSYS, &new_handler, NULL); - sigaction(SIGTRAP, NULL, &oldAction[SIGTRAP]); - if (oldAction[SIGTRAP].sa_handler != SIG_IGN) - sigaction(SIGTRAP, &new_handler, NULL); - sigaction(SIGXCPU, NULL, &oldAction[SIGXCPU]); if (oldAction[SIGXCPU].sa_handler != SIG_IGN) sigaction(SIGXCPU, &new_handler, NULL); @@ -346,6 +342,10 @@ static void setFatalSignalHandler(SigActionHandler signalHandler) sigaction(SIGXFSZ, NULL, &oldAction[SIGXFSZ]); if (oldAction[SIGXFSZ].sa_handler != SIG_IGN) sigaction(SIGXFSZ, &new_handler, NULL); + + // ignore SIGTRAP + new_handler.sa_handler = SIG_IGN; + sigaction(SIGTRAP, &new_handler, &oldAction[SIGTRAP]); #endif // _XOPEN_UNIX } diff --git a/lib/framework/debug.h b/lib/framework/debug.h index 8de255258..3de6a3d7c 100644 --- a/lib/framework/debug.h +++ b/lib/framework/debug.h @@ -32,6 +32,7 @@ #endif #include +#include #include "macros.h" #include "types.h" @@ -60,7 +61,7 @@ extern bool assertEnabled; (void)_debug(LOG_ERROR, function, __VA_ARGS__), \ (void)_debug(LOG_ERROR, function, "Assert in Warzone: %s (%s), last script event: '%s'", \ location_description, expr_string, last_called_script_event), \ - ( assertEnabled ? assert(expr) : (void)0 )\ + ( assertEnabled ? (void)raise(SIGTRAP) : (void)0 )\ ) /**