1
0
Fork 0

fix assertions in non-maintainer mode

This commit is contained in:
Jan Steemann 2016-03-02 11:04:29 +01:00
parent 318cdb8365
commit 2a63d04289
3 changed files with 32 additions and 4 deletions

View File

@ -177,22 +177,23 @@ static inline uint32_t TRI_64to32(uint64_t x) {
/// @brief asserts /// @brief asserts
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#ifndef TRI_ASSERT
#ifdef ARANGODB_ENABLE_MAINTAINER_MODE #ifdef ARANGODB_ENABLE_MAINTAINER_MODE
#ifndef TRI_ASSERT
#define TRI_ASSERT(expr) \ #define TRI_ASSERT(expr) \
do { \ do { \
if (!(expr)) { \ if (!(expr)) { \
TRI_FlushDebugging(__FILE__, __LINE__, #expr); \
TRI_PrintBacktrace(); \ TRI_PrintBacktrace(); \
assert(expr); \ std::abort(); \
} \ } \
} while (0) } while (0)
#endif
#else #else
#ifndef TRI_ASSERT
#define TRI_ASSERT(expr) do { } while (0) #define TRI_ASSERT(expr) do { } while (0)
#endif #endif
#endif #endif

View File

@ -396,3 +396,23 @@ void TRI_PrintBacktrace() {
#endif #endif
#endif #endif
} }
////////////////////////////////////////////////////////////////////////////////
/// @brief flushes the logger and shuts it down
////////////////////////////////////////////////////////////////////////////////
void TRI_FlushDebugging() {
Logger::flush();
Logger::shutdown(true);
}
////////////////////////////////////////////////////////////////////////////////
/// @brief flushes the logger and shuts it down
////////////////////////////////////////////////////////////////////////////////
void TRI_FlushDebugging(char const* file, int line, char const* message) {
LOG(FATAL) << "assertion failed in " << file << ":" << line << ": " << message;
Logger::flush();
Logger::shutdown(true);
}

View File

@ -140,6 +140,13 @@ void TRI_InitializeDebugging(void);
void TRI_ShutdownDebugging(void); void TRI_ShutdownDebugging(void);
////////////////////////////////////////////////////////////////////////////////
/// @brief flushes the logger and shuts it down
////////////////////////////////////////////////////////////////////////////////
void TRI_FlushDebugging();
void TRI_FlushDebugging(char const* file, int line, char const* message);
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief dump vector contents to an ostream /// @brief dump vector contents to an ostream
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////