rtdebug.h 1.6 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 43 44
/* Turn on this to enable context check */
#ifndef RT_DEBUG_CONTEXT_CHECK
#define RT_DEBUG_CONTEXT_CHECK 1
45
#endif
46 47 48 49 50 51 52

#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);}

53 54 55
/* Macro to check current context */
#if RT_DEBUG_CONTEXT_CHECK
#define RT_DEBUG_NOT_IN_INTERRUPT do {\
56 57
        rt_base_t level;\
        level = rt_hw_interrupt_disable();\
58 59
        if(rt_interrupt_get_nest() != 0){\
            rt_kprintf("Function[%s] shall not used in ISR\n", __FUNCTION__);\
60
            RT_ASSERT(0)}\
61 62
        rt_hw_interrupt_enable(level);} while (0)
#endif
63 64 65
#else /* RT_DEBUG */

#define RT_ASSERT(EX)
66
#define RT_DEBUG_LOG(type,message)
67
#define RT_DEBUG_NOT_IN_INTERRUPT
68 69 70 71 72 73

#endif /* RT_DEBUG */



#endif /* __RTDEBUG_H__ */