enh: speed assert in release mode
This commit is contained in:
parent
adbc11f8e4
commit
2cbbc88937
|
@ -83,9 +83,14 @@ void taosPrintLongString(const char *flags, ELogLevel level, int32_t dflag, cons
|
|||
#endif
|
||||
;
|
||||
|
||||
bool taosAssert(bool condition, const char *file, int32_t line, const char *format, ...);
|
||||
#define ASSERTS(condition, ...) taosAssert(condition, __FILE__, __LINE__, __VA_ARGS__)
|
||||
#define ASSERT(condition) ASSERTS(condition, "assert info not provided")
|
||||
bool taosAssertDebug(bool condition, const char *file, int32_t line, const char *format, ...);
|
||||
bool taosAssertRelease(bool condition);
|
||||
#define ASSERTS(condition, ...) taosAssertDebug(condition, __FILE__, __LINE__, __VA_ARGS__)
|
||||
#ifdef NDEBUG
|
||||
#define ASSERT(condition) taosAssertRelease(condition)
|
||||
#else
|
||||
#define ASSERT(condition) taosAssertDebug(condition, __FILE__, __LINE__, "assert info not provided")
|
||||
#endif
|
||||
|
||||
// clang-format off
|
||||
#define uFatal(...) { if (uDebugFlag & DEBUG_FATAL) { taosPrintLog("UTL FATAL", DEBUG_FATAL, tsLogEmbedded ? 255 : uDebugFlag, __VA_ARGS__); }}
|
||||
|
|
|
@ -790,7 +790,7 @@ cmp_end:
|
|||
return ret;
|
||||
}
|
||||
|
||||
bool taosAssert(bool condition, const char *file, int32_t line, const char *format, ...) {
|
||||
bool taosAssertDebug(bool condition, const char *file, int32_t line, const char *format, ...) {
|
||||
if (condition) return false;
|
||||
|
||||
const char *flags = "UTL FATAL ";
|
||||
|
@ -822,4 +822,24 @@ bool taosAssert(bool condition, const char *file, int32_t line, const char *form
|
|||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef NDEBUG
|
||||
bool taosAssertRelease(bool condition) {
|
||||
if (condition) return false;
|
||||
|
||||
const char *flags = "UTL FATAL ";
|
||||
ELogLevel level = DEBUG_FATAL;
|
||||
int32_t dflag = 255; // tsLogEmbedded ? 255 : uDebugFlag
|
||||
|
||||
taosPrintLog(flags, level, dflag, "tAssert called in release mode, exit:%d", tsAssert);
|
||||
taosPrintTrace(flags, level, dflag);
|
||||
|
||||
if (tsAssert) {
|
||||
taosMsleep(300);
|
||||
abort();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
Loading…
Reference in New Issue