2011-09-23 13:57:31 +08:00
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2011-06-12 18:01:48 +08:00
|
|
|
#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 */
|
2011-06-13 10:40:24 +08:00
|
|
|
#ifndef RT_DEBUG_MEM
|
2011-06-12 18:01:48 +08:00
|
|
|
#define RT_DEBUG_MEM 0
|
2011-06-13 10:40:24 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef RT_DEBUG_MODULE
|
2011-06-12 18:01:48 +08:00
|
|
|
#define RT_DEBUG_MODULE 0
|
2011-06-13 10:40:24 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef RT_DEBUG_SCHEDULER
|
2011-06-12 18:01:48 +08:00
|
|
|
#define RT_DEBUG_SCHEDULER 0
|
2011-06-13 10:40:24 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef RT_DEBUG_SLAB
|
2011-06-12 18:01:48 +08:00
|
|
|
#define RT_DEBUG_SLAB 0
|
2011-06-13 10:40:24 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef RT_DEBUG_THREAD
|
2011-06-12 18:01:48 +08:00
|
|
|
#define RT_DEBUG_THREAD 0
|
2011-06-13 10:40:24 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef RT_DEBUG_TIMER
|
2011-06-12 18:01:48 +08:00
|
|
|
#define RT_DEBUG_TIMER 0
|
2011-06-13 10:40:24 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef RT_DEBUG_IRQ
|
2011-06-12 18:01:48 +08:00
|
|
|
#define RT_DEBUG_IRQ 0
|
2011-06-13 10:40:24 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef RT_DEBUG_IPC
|
2011-06-12 18:01:48 +08:00
|
|
|
#define RT_DEBUG_IPC 0
|
2011-06-13 10:40:24 +08:00
|
|
|
#endif
|
2011-06-12 18:01:48 +08:00
|
|
|
|
2011-06-15 07:59:42 +08:00
|
|
|
/* Turn on this to enable context check */
|
|
|
|
#ifndef RT_DEBUG_CONTEXT_CHECK
|
|
|
|
#define RT_DEBUG_CONTEXT_CHECK 1
|
2011-06-13 10:40:24 +08:00
|
|
|
#endif
|
2011-06-12 18:01:48 +08:00
|
|
|
|
2011-09-23 13:57:31 +08:00
|
|
|
#define RT_DEBUG_LOG(type,message) do { if (type) rt_kprintf message;} while (0)
|
2011-06-12 18:01:48 +08:00
|
|
|
|
2011-09-23 13:57:31 +08:00
|
|
|
#define RT_ASSERT(EX) if (!(EX)) {volatile char dummy = 0;\
|
2011-06-12 18:01:48 +08:00
|
|
|
rt_kprintf("(%s) assert failed at %s:%d \n", \
|
2011-09-23 13:57:31 +08:00
|
|
|
#EX, __FUNCTION__, __LINE__); while (dummy == 0);}
|
2011-06-12 18:01:48 +08:00
|
|
|
|
2011-06-15 07:59:42 +08:00
|
|
|
/* Macro to check current context */
|
|
|
|
#if RT_DEBUG_CONTEXT_CHECK
|
|
|
|
#define RT_DEBUG_NOT_IN_INTERRUPT do {\
|
2011-06-12 18:01:48 +08:00
|
|
|
rt_base_t level;\
|
|
|
|
level = rt_hw_interrupt_disable();\
|
2011-09-23 13:57:31 +08:00
|
|
|
if (rt_interrupt_get_nest() != 0){\
|
2011-06-15 07:59:42 +08:00
|
|
|
rt_kprintf("Function[%s] shall not used in ISR\n", __FUNCTION__);\
|
2011-06-12 18:01:48 +08:00
|
|
|
RT_ASSERT(0)}\
|
2011-06-15 07:59:42 +08:00
|
|
|
rt_hw_interrupt_enable(level);} while (0)
|
|
|
|
#endif
|
2011-06-12 18:01:48 +08:00
|
|
|
#else /* RT_DEBUG */
|
|
|
|
|
|
|
|
#define RT_ASSERT(EX)
|
2011-06-13 10:40:24 +08:00
|
|
|
#define RT_DEBUG_LOG(type,message)
|
2011-06-15 07:59:42 +08:00
|
|
|
#define RT_DEBUG_NOT_IN_INTERRUPT
|
2011-06-12 18:01:48 +08:00
|
|
|
|
|
|
|
#endif /* RT_DEBUG */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* __RTDEBUG_H__ */
|