rtdebug.h 2.1 KB
Newer Older
1 2 3 4 5 6 7 8 9
#ifndef __RTDEBUG_H__
#define __RTDEBUG_H__

#include <rtconfig.h>

/* Using this macro to control all kernel debug features. */
#ifdef RT_DEBUG

/* Turn on some of these (set to non-zero) to debug kernel */
10
#ifndef RT_DEBUG_MEM
11
#define RT_DEBUG_MEM        0
12 13 14
#endif

#ifndef RT_DEBUG_MODULE
15
#define RT_DEBUG_MODULE     0
16 17 18
#endif

#ifndef RT_DEBUG_SCHEDULER
19
#define RT_DEBUG_SCHEDULER  0
20 21 22
#endif

#ifndef RT_DEBUG_SLAB
23
#define RT_DEBUG_SLAB       0
24 25 26
#endif

#ifndef RT_DEBUG_THREAD
27
#define RT_DEBUG_THREAD     0
28 29 30
#endif

#ifndef RT_DEBUG_TIMER
31
#define RT_DEBUG_TIMER      0
32 33 34
#endif

#ifndef RT_DEBUG_IRQ
35
#define RT_DEBUG_IRQ        0
36 37 38
#endif

#ifndef RT_DEBUG_IPC
39
#define RT_DEBUG_IPC        0
40
#endif
41 42

/* Turn on this to enable reentrance check */
43
#ifndef RT_DEBUG_REENT_CHK
44
#define RT_DEBUG_REENT_CHK  1
45
#endif
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81

#define RT_DEBUG_LOG(type,message)  do{ if(type) rt_kprintf message;}while(0)

#define RT_ASSERT(EX)   if (!(EX)) {volatile char dummy=0;\
                            rt_kprintf("(%s) assert failed at %s:%d \n", \
                            #EX, __FUNCTION__, __LINE__); while (dummy==0);}

/* Reentrance check */
/* counter */
extern rt_uint8_t rt_debug_reent_cnt;

#define RT_DEBUG_REENT_IN if(RT_DEBUG_REENT_CHK){\
        rt_base_t level;\
        level = rt_hw_interrupt_disable();\
        rt_debug_reent_cnt++;\
        rt_hw_interrupt_enable(level);}

#define RT_DEBUG_REENT_OUT if(RT_DEBUG_REENT_CHK){\
        rt_base_t level;\
        level = rt_hw_interrupt_disable();\
        rt_debug_reent_cnt--;\
        rt_hw_interrupt_enable(level);}

/* Mark those non-reentrant functions with this macro */
#define RT_DEBUG_NOT_REENT if(RT_DEBUG_REENT_CHK){\
        rt_base_t level;\
        level = rt_hw_interrupt_disable();\
        if(rt_debug_reent_cnt != 0){\
            rt_kprintf("Non-reentrant function used in critical area!\n");\
            RT_ASSERT(0)}\
        rt_hw_interrupt_enable(level);}


#else /* RT_DEBUG */

#define RT_ASSERT(EX)
82
#define RT_DEBUG_LOG(type,message)
83 84 85 86 87 88 89 90 91
#define RT_DEBUG_REENT_IN
#define RT_DEBUG_REENT_OUT
#define RT_DEBUG_NOT_REENT

#endif /* RT_DEBUG */



#endif /* __RTDEBUG_H__ */