diff --git a/common/include/common/debug.h b/common/include/common/debug.h index 855ab643..13e7607c 100644 --- a/common/include/common/debug.h +++ b/common/include/common/debug.h @@ -97,6 +97,23 @@ void printBacktrace(void); abort(); \ } while(0) +#define DEBUG_ASSERT_PRINT(...) DEBUG_ERROR("Assertion failed: %s", #__VA_ARGS__) + +#ifdef NDEBUG + #define DEBUG_ASSERT(...) do { \ + if (!(__VA_ARGS__)) \ + DEBUG_ASSERT_PRINT(__VA_ARGS__); \ + } while (0) +#else + #define DEBUG_ASSERT(...) do { \ + if (!(__VA_ARGS__)) \ + { \ + DEBUG_ASSERT_PRINT(__VA_ARGS__); \ + abort(); \ + } \ + } while (0) +#endif + #if defined(DEBUG_SPICE) | defined(DEBUG_IVSHMEM) #define DEBUG_PROTO(fmt, args...) DEBUG_PRINT("[P]", fmt, ##args) #else