00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef PED_DEBUG_H_INCLUDED
00021 #define PED_DEBUG_H_INCLUDED
00022
00023 #include <config.h>
00024
00025 #include <stdarg.h>
00026
00027 #ifdef DEBUG
00028
00029 typedef void (PedDebugHandler) ( const int level, const char* file, int line,
00030 const char* function, const char* msg );
00031
00032 extern void ped_debug_set_handler (PedDebugHandler* handler);
00033 extern void ped_debug ( const int level, const char* file, int line,
00034 const char* function, const char* msg, ... );
00035
00036 extern int ped_assert ( int cond, const char* cond_text,
00037 const char* file, int line, const char* function );
00038
00039 #if defined(__GNUC__) && !defined(__JSFTRACE__)
00040
00041 #define PED_DEBUG(level, ...) \
00042 ped_debug ( level, __FILE__, __LINE__, __PRETTY_FUNCTION__, \
00043 __VA_ARGS__ );
00044
00045 #define PED_ASSERT(cond, action) \
00046 do { \
00047 if (!ped_assert ( cond, \
00048 #cond, \
00049 __FILE__, \
00050 __LINE__, \
00051 __PRETTY_FUNCTION__ )) \
00052 { \
00053 action; \
00054 } \
00055 } while (0)
00056
00057 #else
00058
00059
00060 static void PED_DEBUG (int level, ...)
00061 {
00062 va_list va_args;
00063
00064 va_start (va_args, level);
00065 ped_debug ( level, "unknown file", 0, "unknown function", va_args );
00066 va_end (va_args);
00067 }
00068
00069 #define PED_ASSERT(cond, action) \
00070 do { \
00071 if (!ped_assert ( cond, \
00072 #cond, \
00073 "unknown", \
00074 0, \
00075 "unknown" )) \
00076 { \
00077 action; \
00078 } \
00079 } while (0)
00080
00081 #endif
00082
00083 #else
00084
00085 #define PED_ASSERT(cond, action) while (0) {}
00086 #define PED_DEBUG(level, ...) while (0) {}
00087
00088
00089 #endif
00090
00091 #endif
00092