sna: Generate a backtrace on assertion failures

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
Chris Wilson 2014-12-01 10:00:32 +00:00
parent e12ec452a9
commit ddf5feba78
1 changed files with 8 additions and 2 deletions

View File

@ -33,9 +33,15 @@
#ifndef NDEBUG
#include <os.h>
#include "compiler.h"
#if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(1,6,0,0,0)
#define xorg_backtrace()
#endif
#undef assert
#define assert(E) do { \
if (unlikely(!(E))) FatalError("%s:%d assertion '%s' failed\n", __func__, __LINE__, #E); \
#define assert(E) do if (unlikely(!(E))) { \
xorg_backtrace(); \
FatalError("%s:%d assertion '%s' failed\n", __func__, __LINE__, #E); \
} while (0)
#endif