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
master
Christian Ohm 2010-06-26 19:57:29 +00:00 committed by Git SVN Gateway
parent a8b029d700
commit 4b7d25145c
2 changed files with 6 additions and 5 deletions

View File

@ -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
}

View File

@ -32,6 +32,7 @@
#endif
#include <assert.h>
#include <signal.h>
#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 )\
)
/**