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
|
#endif
|
||||||
;
|
;
|
||||||
|
|
||||||
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, ...);
|
||||||
#define ASSERTS(condition, ...) taosAssert(condition, __FILE__, __LINE__, __VA_ARGS__)
|
bool taosAssertRelease(bool condition);
|
||||||
#define ASSERT(condition) ASSERTS(condition, "assert info not provided")
|
#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
|
// clang-format off
|
||||||
#define uFatal(...) { if (uDebugFlag & DEBUG_FATAL) { taosPrintLog("UTL FATAL", DEBUG_FATAL, tsLogEmbedded ? 255 : uDebugFlag, __VA_ARGS__); }}
|
#define uFatal(...) { if (uDebugFlag & DEBUG_FATAL) { taosPrintLog("UTL FATAL", DEBUG_FATAL, tsLogEmbedded ? 255 : uDebugFlag, __VA_ARGS__); }}
|
||||||
|
|
|
@ -790,7 +790,7 @@ cmp_end:
|
||||||
return ret;
|
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;
|
if (condition) return false;
|
||||||
|
|
||||||
const char *flags = "UTL FATAL ";
|
const char *flags = "UTL FATAL ";
|
||||||
|
@ -823,3 +823,23 @@ bool taosAssert(bool condition, const char *file, int32_t line, const char *form
|
||||||
|
|
||||||
return true;
|
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