debug.h

Go to the documentation of this file.
00001 
00013 #ifndef _DEBUG_H_
00014 #define _DEBUG_H_
00015 
00021 //#define SCHEDULER_DEBUG
00022 //#define THREAD_DEBUG
00023 //#define QUEUE_DEBUG
00024 //#define EXCEPTION_DEBUG
00025 //#define MUTEX_DEBUG
00026 //#define SEM_DEBUG
00027 //#define TIMER_DEBUG
00030 #define NDEBUG
00031 
00032 #ifndef NDEBUG
00033         #define DEBUG
00034 #endif /*NDEBUG*/
00035         
00037 #define ___trace_on()                           \
00038         __asm__ __volatile__ (                  \
00039         "       .insn                   \n"     \
00040         "       .word   0x39            \n"     \
00041         )
00042 
00043 
00045 #define ___trace_off()                          \
00046         __asm__ __volatile__ (                  \
00047         "       .insn                   \n"     \
00048         "       .word   0x3d            \n"     \
00049         )
00050 
00051 
00053 #define ___reg_view()                           \
00054         __asm__ __volatile__ (                  \
00055         "       .insn                   \n"     \
00056         "       .word   0x37            \n"     \
00057         )
00058 
00059 
00061 #define ___halt()                               \
00062         __asm__ __volatile__ (                  \
00063         "       .insn                   \n"     \
00064         "       .word   0x28            \n"     \
00065         )
00066 
00067 
00069 #define ___stop()                               \
00070         __asm__ __volatile__ (                  \
00071         "       .insn                   \n"     \
00072         "       .word   0x29            \n"     \
00073         )
00074         
00082 #ifdef NDEBUG
00083 #define ASSERT(EXPR) 
00084 #else
00085 #define ASSERT(EXPR)    \
00086                         if (!(EXPR)) {  \
00087                                 panic("Assertion failed: function %s, %s:%d, expression %s\n",  __func__ , __FILE__, __LINE__, #EXPR); \
00088                         }
00089 #endif
00090         
00098 #ifdef NDEBUG
00099 #define assert(expr)          do {} while (0)
00100 #else
00101 #define assert(expr)                                            \
00102         if (! (expr))                                           \
00103         {                                                       \
00104                 panic ("Assertion failed in %s() at %s:%d: %s\n",       \
00105                 __FUNCTION__, __FILE__, __LINE__, #expr);               \
00106         }
00107 #endif
00108 
00117 #ifdef NDEBUG
00118         #define dprintk(ARGS) 
00119         #define dprintk1(ARGS, A1)
00120         #define dprintk2(ARGS, A1, A2)
00121         #define dprintk3(ARGS, A1, A2, A3)
00122         #define dprintk4(ARGS, A1, A2, A3, A4)
00123 #else
00124         #define dprintk(ARGS)  printk("     Debug: function %s, line %d: ", __FUNCTION__, __LINE__); printk(ARGS);
00125         #define dprintk1(ARGS, A1)  printk("     Debug: function %s, line %d: ", __FUNCTION__, __LINE__); printk(ARGS, A1);
00126         #define dprintk2(ARGS, A1, A2)  printk("     Debug: function %s, line %d: ", __FUNCTION__, __LINE__); printk(ARGS, A1, A2);
00127         #define dprintk3(ARGS, A1, A2, A3)  printk("     Debug: function %s, line %d: ", __FUNCTION__, __LINE__); printk(ARGS, A1, A2, A3);
00128         #define dprintk4(ARGS, A1, A2, A3, A4)  printk("     Debug: function %s, line %d: ", __FUNCTION__, __LINE__); printk(ARGS, A1, A2, A3, A4);     
00129 #endif
00130 
00132 void panic(const char* format, ...);
00133 
00134 
00135 #endif /* _DEBUG_H_ */

Generated on Wed Nov 15 17:25:43 2006 for Kalisto by  doxygen 1.4.7