rtdebug.h 1.9 KB
Newer Older
D
dzzxzz 已提交
1 2 3 4 5 6 7 8 9 10
/*
 * File      : rtdebug.h
 * This file is part of RT-Thread RTOS
 * COPYRIGHT (C) 2006 - 2011, RT-Thread Development Team
 *
 * The license and distribution terms for this file may be
 * found in the file LICENSE in this distribution or at
 * http://www.rt-thread.org/license/LICENSE
 */
 
11 12 13 14 15 16 17 18 19
#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 */
20
#ifndef RT_DEBUG_MEM
21
#define RT_DEBUG_MEM        0
22 23 24
#endif

#ifndef RT_DEBUG_MODULE
25
#define RT_DEBUG_MODULE     0
26 27 28
#endif

#ifndef RT_DEBUG_SCHEDULER
29
#define RT_DEBUG_SCHEDULER  0
30 31 32
#endif

#ifndef RT_DEBUG_SLAB
33
#define RT_DEBUG_SLAB       0
34 35 36
#endif

#ifndef RT_DEBUG_THREAD
37
#define RT_DEBUG_THREAD     0
38 39 40
#endif

#ifndef RT_DEBUG_TIMER
41
#define RT_DEBUG_TIMER      0
42 43 44
#endif

#ifndef RT_DEBUG_IRQ
45
#define RT_DEBUG_IRQ        0
46 47 48
#endif

#ifndef RT_DEBUG_IPC
49
#define RT_DEBUG_IPC        0
50
#endif
51

52 53 54
/* Turn on this to enable context check */
#ifndef RT_DEBUG_CONTEXT_CHECK
#define RT_DEBUG_CONTEXT_CHECK 1
55
#endif
56

D
dzzxzz 已提交
57
#define RT_DEBUG_LOG(type,message)  do { if (type) rt_kprintf message;} while (0)
58

D
dzzxzz 已提交
59
#define RT_ASSERT(EX)   if (!(EX)) {volatile char dummy = 0;\
60
                            rt_kprintf("(%s) assert failed at %s:%d \n", \
D
dzzxzz 已提交
61
                            #EX, __FUNCTION__, __LINE__); while (dummy == 0);}
62

63 64 65
/* Macro to check current context */
#if RT_DEBUG_CONTEXT_CHECK
#define RT_DEBUG_NOT_IN_INTERRUPT do {\
66 67
        rt_base_t level;\
        level = rt_hw_interrupt_disable();\
D
dzzxzz 已提交
68
        if (rt_interrupt_get_nest() != 0){\
69
            rt_kprintf("Function[%s] shall not used in ISR\n", __FUNCTION__);\
70
            RT_ASSERT(0)}\
71 72
        rt_hw_interrupt_enable(level);} while (0)
#endif
73 74 75
#else /* RT_DEBUG */

#define RT_ASSERT(EX)
76
#define RT_DEBUG_LOG(type,message)
77
#define RT_DEBUG_NOT_IN_INTERRUPT
78 79 80 81 82 83

#endif /* RT_DEBUG */



#endif /* __RTDEBUG_H__ */