rtdebug.h 2.0 KB
Newer Older
D
dzzxzz 已提交
1 2 3
/*
 * File      : rtdebug.h
 * This file is part of RT-Thread RTOS
D
dzzxzz 已提交
4
 * COPYRIGHT (C) 2006 - 2012, RT-Thread Development Team
D
dzzxzz 已提交
5 6 7 8 9 10
 *
 * 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
#endif

24 25 26 27
#ifndef RT_DEBUG_MEMHEAP
#define RT_DEBUG_MEMHEAP	0
#endif

28
#ifndef RT_DEBUG_MODULE
29
#define RT_DEBUG_MODULE     0
30 31 32
#endif

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

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

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

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

#ifndef RT_DEBUG_IRQ
49
#define RT_DEBUG_IRQ        0
50 51 52
#endif

#ifndef RT_DEBUG_IPC
53
#define RT_DEBUG_IPC        0
54
#endif
55

56 57 58
/* Turn on this to enable context check */
#ifndef RT_DEBUG_CONTEXT_CHECK
#define RT_DEBUG_CONTEXT_CHECK 1
59
#endif
60

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

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

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

#define RT_ASSERT(EX)
80
#define RT_DEBUG_LOG(type,message)
81
#define RT_DEBUG_NOT_IN_INTERRUPT
82 83 84 85

#endif /* RT_DEBUG */

#endif /* __RTDEBUG_H__ */