debug.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #ifndef __DEBUG_h__
00042 #define __DEBUG_h__
00043
00044 #ifdef __GNUC__
00045 #define FUNCTION_SIGNATURE __FUNCTION__
00046 #else
00047 #define FUNCTION_SIGNATURE __FUNCSIG__
00048 #endif
00049
00050 #include "logging/logging.h"
00051
00052 #ifdef FAMOUSO_DEBUG_DISABLE
00053 LOGGING_DISABLE_LEVEL(::logging::Trace);
00054 LOGGING_DISABLE_LEVEL(::logging::Info);
00055 #endif
00056
00057 #define TRACE_FUNCTION do { \
00058 ::logging::log::emit< ::logging::Trace>() \
00059 << '"' << FUNCTION_SIGNATURE << '"' \
00060 << PROGMEMSTRING(" -> "__FILE__":" __TOSTR__(__LINE__)" ") \
00061 << ::logging::log::endl; \
00062 } while(0)
00063
00064
00065 #if !defined(ASSERT_FAILED_HANDLER)
00066
00067 #include <stdlib.h>
00068
00077 template<typename ExprT, typename FileT, typename LineT> static inline
00078 void __famouso_assert_failed_handler(ExprT expr, FileT file, LineT line) {
00079 using ::logging::log;
00080 log::emit() << file << ':' << line
00081 << PROGMEMSTRING(": Assertion '") << expr
00082 << PROGMEMSTRING("' failed.") << log::endl;
00083 abort();
00084 }
00085
00092 #define FAMOUSO_ASSERT_FAILED_HANDLER ::__famouso_assert_failed_handler
00093
00094 #endif
00095
00096 #if defined(NDEBUG)
00097 #define FAMOUSO_ASSERT(expr)
00098 #define FOR_FAMOUSO_ASSERT_ONLY(code)
00099 #else
00100
00122 #define FAMOUSO_ASSERT(expr) ((expr) ? ((void)0) : \
00123 FAMOUSO_ASSERT_FAILED_HANDLER(PROGMEMSTRING(#expr), \
00124 PROGMEMSTRING(__FILE__), \
00125 PROGMEMSTRING(__TOSTR__(__LINE__))))
00126
00139 #define FOR_FAMOUSO_ASSERT_ONLY(code) code
00140
00141 #endif
00142
00143
00144 #endif