diff options
Diffstat (limited to 'include/rtdebug.h')
| -rw-r--r-- | include/rtdebug.h | 112 |
1 files changed, 0 insertions, 112 deletions
diff --git a/include/rtdebug.h b/include/rtdebug.h deleted file mode 100644 index 0246ad0fa5..0000000000 --- a/include/rtdebug.h +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2006-2021, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - */ - -#ifndef __RTDEBUG_H__ -#define __RTDEBUG_H__ - -#include <rtconfig.h> - -/* Using this macro to control all kernel debug features. */ -#ifdef RT_DEBUG - -/* Turn on this to enable context check */ -#ifndef RT_DEBUG_CONTEXT_CHECK -#define RT_DEBUG_CONTEXT_CHECK 1 -#endif - -#define RT_ASSERT(EX) \ -if (!(EX)) \ -{ \ - rt_assert_handler(#EX, __FUNCTION__, __LINE__); \ -} - -/* Macro to check current context */ -#if RT_DEBUG_CONTEXT_CHECK -#define RT_DEBUG_NOT_IN_INTERRUPT \ -do \ -{ \ - rt_base_t level; \ - level = rt_hw_interrupt_disable(); \ - if (rt_interrupt_get_nest() != 0) \ - { \ - rt_kprintf("Function[%s] shall not be used in ISR\n", __FUNCTION__); \ - RT_ASSERT(0) \ - } \ - rt_hw_interrupt_enable(level); \ -} \ -while (0) - -/* "In thread context" means: - * 1) the scheduler has been started - * 2) not in interrupt context. - */ -#define RT_DEBUG_IN_THREAD_CONTEXT \ -do \ -{ \ - rt_base_t level; \ - level = rt_hw_interrupt_disable(); \ - if (rt_thread_self() == RT_NULL) \ - { \ - rt_kprintf("Function[%s] shall not be used before scheduler start\n", \ - __FUNCTION__); \ - RT_ASSERT(0) \ - } \ - RT_DEBUG_NOT_IN_INTERRUPT; \ - rt_hw_interrupt_enable(level); \ -} \ -while (0) - -/* "scheduler available" means: - * 1) the scheduler has been started. - * 2) not in interrupt context. - * 3) scheduler is not locked. - * 4) interrupt is not disabled. - */ -#define RT_DEBUG_SCHEDULER_AVAILABLE(need_check) \ -do \ -{ \ - if (need_check) \ - { \ - rt_bool_t interrupt_disabled; \ - rt_base_t level; \ - interrupt_disabled = rt_hw_interrupt_is_disabled(); \ - level = rt_hw_interrupt_disable(); \ - if (rt_critical_level() != 0) \ - { \ - rt_kprintf("Function[%s]: scheduler is not available\n", \ - __FUNCTION__); \ - RT_ASSERT(0) \ - } \ - if (interrupt_disabled == RT_TRUE) \ - { \ - rt_kprintf("Function[%s]: interrupt is disabled\n", \ - __FUNCTION__); \ - RT_ASSERT(0) \ - } \ - RT_DEBUG_IN_THREAD_CONTEXT; \ - rt_hw_interrupt_enable(level); \ - } \ -} \ -while (0) -#else -#define RT_DEBUG_NOT_IN_INTERRUPT -#define RT_DEBUG_IN_THREAD_CONTEXT -#define RT_DEBUG_SCHEDULER_AVAILABLE(need_check) -#endif - -#else /* RT_DEBUG */ - -#define RT_ASSERT(EX) -#define RT_DEBUG_NOT_IN_INTERRUPT -#define RT_DEBUG_IN_THREAD_CONTEXT -#define RT_DEBUG_SCHEDULER_AVAILABLE(need_check) - -#endif /* RT_DEBUG */ - -#endif /* __RTDEBUG_H__ */ |
