未验证 提交 244b903e 编写于 作者: mysterywolf's avatar mysterywolf 提交者: GitHub

[debug] 整理debug宏并增加RT_DEBUGING_CONTEXT (#7805)

上级 52d3637f
......@@ -269,7 +269,7 @@ jobs:
- "microchip/same70"
- "smartfusion2"
- "maxim/max32660-evsys"
- "efm32"
# - "efm32"
- RTT_BSP: "mips"
RTT_TOOL_CHAIN: "sourcery-mips"
SUB_RTT_BSP:
......
......@@ -385,7 +385,7 @@ PSOC6 BSP 的制作规范主要分为 3 个方面:工程配置,ENV 配置和
#### 4.1.2 ENV 配置
- 系统心跳统一设置为 1000(宏:RT_TICK_PER_SECOND)
- BSP 中需要打开调试选项中的断言(宏:RT_DEBUG)
- BSP 中需要打开调试选项中的断言(宏:RT_USING_DEBUG)
- 系统空闲线程栈大小统一设置为 256(宏:IDLE_THREAD_STACK_SIZE)
- 开启组件自动初始化(宏:RT_USING_COMPONENTS_INIT)
- 需要开启 user main 选项(宏:RT_USING_USER_MAIN)
......
......@@ -36,7 +36,7 @@ extern int __bss_end__;
/* External function prototypes ----------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
#ifdef RT_DEBUG
#ifdef RT_USING_DEBUG
/***************************************************************************//**
* @brief
* Reports the name of the source file and the source line number where the
......
......@@ -790,7 +790,7 @@ GD32 BSP 的制作规范主要分为 3 个方面:工程配置,ENV 配置和
#### 4.1.2 ENV 配置
- 系统心跳统一设置为 1000(宏:RT_TICK_PER_SECOND)
- BSP 中需要打开调试选项中的断言(宏:RT_DEBUG)
- BSP 中需要打开调试选项中的断言(宏:RT_USING_DEBUG)
- 系统空闲线程栈大小统一设置为 256(宏:IDLE_THREAD_STACK_SIZE)
- 开启组件自动初始化(宏:RT_USING_COMPONENTS_INIT)
- 需要开启 user main 选项(宏:RT_USING_USER_MAIN)
......
......@@ -594,7 +594,7 @@ GD32 BSP 的制作规范主要分为 3 个方面:工程配置,ENV 配置和
#### 4.1.2 ENV 配置
- 系统心跳统一设置为 1000(宏:RT_TICK_PER_SECOND)
- BSP 中需要打开调试选项中的断言(宏:RT_DEBUG)
- BSP 中需要打开调试选项中的断言(宏:RT_USING_DEBUG)
- 系统空闲线程栈大小统一设置为 256(宏:IDLE_THREAD_STACK_SIZE)
- 开启组件自动初始化(宏:RT_USING_COMPONENTS_INIT)
- 需要开启 user main 选项(宏:RT_USING_USER_MAIN)
......
......@@ -237,7 +237,7 @@ i.MX RT BSP 的制作规范主要分为 3 个方面:工程配置,ENV 配置
#### ENV 配置
- 系统心跳统一设置为 1000(宏:RT_TICK_PER_SECOND)
- BSP 中需要打开调试选项中的断言(宏:RT_DEBUG)
- BSP 中需要打开调试选项中的断言(宏:RT_USING_DEBUG)
- 系统空闲线程栈大小统一设置为 256(宏:IDLE_THREAD_STACK_SIZE)
- 开启组件自动初始化(宏:RT_USING_COMPONENTS_INIT)
- 需要开启 user main 选项(宏:RT_USING_USER_MAIN)
......
......@@ -238,7 +238,7 @@ LPC BSP 的制作规范主要分为 3 个方面:工程配置,ENV 配置和 I
#### ENV 配置
- 系统心跳统一设置为 100(宏:RT_TICK_PER_SECOND)
- BSP 中需要打开调试选项中的断言(宏:RT_DEBUG)
- BSP 中需要打开调试选项中的断言(宏:RT_USING_DEBUG)
- 系统空闲线程栈大小统一设置为 256(宏:IDLE_THREAD_STACK_SIZE)
- 开启组件自动初始化(宏:RT_USING_COMPONENTS_INIT)
- 需要开启 user main 选项(宏:RT_USING_USER_MAIN)
......
......@@ -29,7 +29,7 @@
#define RT_KSERVICE_USING_STDLIB
#define RT_KPRINTF_USING_LONGLONG
#define RT_DEBUG
#define RT_USING_DEBUG
/* Inter-Thread communication */
......
......@@ -28,7 +28,7 @@
#define RT_KSERVICE_USING_STDLIB
#define RT_KPRINTF_USING_LONGLONG
#define RT_DEBUG
#define RT_USING_DEBUG
/* Inter-Thread communication */
......
......@@ -29,7 +29,7 @@
#define RT_KSERVICE_USING_STDLIB
#define RT_KPRINTF_USING_LONGLONG
#define RT_DEBUG
#define RT_USING_DEBUG
/* Inter-Thread communication */
......
......@@ -28,7 +28,7 @@
#define RT_KSERVICE_USING_STDLIB
#define RT_KPRINTF_USING_LONGLONG
#define RT_DEBUG
#define RT_USING_DEBUG
/* Inter-Thread communication */
......
......@@ -29,7 +29,7 @@
#define RT_KSERVICE_USING_STDLIB
#define RT_KPRINTF_USING_LONGLONG
#define RT_DEBUG
#define RT_USING_DEBUG
/* Inter-Thread communication */
......
......@@ -28,7 +28,7 @@
#define RT_KSERVICE_USING_STDLIB
#define RT_KPRINTF_USING_LONGLONG
#define RT_DEBUG
#define RT_USING_DEBUG
/* Inter-Thread communication */
......
......@@ -29,7 +29,7 @@
#define RT_KSERVICE_USING_STDLIB
#define RT_KPRINTF_USING_LONGLONG
#define RT_DEBUG
#define RT_USING_DEBUG
/* Inter-Thread communication */
......
......@@ -28,7 +28,7 @@
#define RT_KSERVICE_USING_STDLIB
#define RT_KPRINTF_USING_LONGLONG
#define RT_DEBUG
#define RT_USING_DEBUG
/* Inter-Thread communication */
......
......@@ -362,7 +362,7 @@ The guidelines consist of project configuration, ENV configuration, and IDE conf
#### 4.1.2 ENV Configuration
- The system tick is set as 1000 (The macro: RT_TICK_PER_SECOND)
- Enable asserting in Debug options (The macro: RT_DEBUG)
- Enable asserting in Debug options (The macro: RT_USING_DEBUG)
- The stack size of the system idle thread is set to be 256 (The macro: IDLE_THREAD_STACK_SIZE)
- Enable component auto initialization (The macro: RT_USING_COMPONENTS_INIT)
- Enable the `user main` option (The macro: RT_USING_USER_MAIN)
......
......@@ -367,7 +367,7 @@ RA 的制作规范主要分为 3 个方面:工程配置,ENV 配置和 IDE
#### 4.1.2 ENV 配置
- 系统心跳统一设置为 1000(宏:RT_TICK_PER_SECOND)
- BSP 中需要打开调试选项中的断言(宏:RT_DEBUG)
- BSP 中需要打开调试选项中的断言(宏:RT_USING_DEBUG)
- 系统空闲线程栈大小统一设置为 256(宏:IDLE_THREAD_STACK_SIZE)
- 开启组件自动初始化(宏:RT_USING_COMPONENTS_INIT)
- 需要开启 user main 选项(宏:RT_USING_USER_MAIN)
......
......@@ -217,7 +217,7 @@ The specifications of making STM32 BSP are mainly divided into three aspects: en
#### 4.1.2 ENV configuration
- The system heartbeat is uniformly set to 1000 (Macro: RT_TICK_PER_SECOND)
- The assertion in the debugging option needs to be turned on in the BSP (macro: RT_DEBUG)
- The assertion in the debugging option needs to be turned on in the BSP (macro: RT_USING_DEBUG)
- The system idle thread stack size is uniformly set to 256 (Macro: IDLE_THREAD_STACK_SIZE)
- Turn on automatic component initialization (Macro: RT_USING_COMPONENTS_INIT)
- Need to enable the user main option (Macro: RT_USING_USER_MAIN)
......
......@@ -265,7 +265,7 @@ STM32 BSP 的制作规范主要分为 3 个方面:工程配置,ENV 配置和
#### 4.1.2 ENV 配置
- 系统心跳统一设置为 1000(宏:RT_TICK_PER_SECOND)
- BSP 中需要打开调试选项中的断言(宏:RT_DEBUG)
- BSP 中需要打开调试选项中的断言(宏:RT_USING_DEBUG)
- 系统空闲线程栈大小统一设置为 256(宏:IDLE_THREAD_STACK_SIZE)
- 开启组件自动初始化(宏:RT_USING_COMPONENTS_INIT)
- 需要开启 user main 选项(宏:RT_USING_USER_MAIN)
......
......@@ -27,7 +27,7 @@ INIT_EXPORT(rti_secondary_cpu_end, "7.end");
void rt_dm_secondary_cpu_init(void)
{
#if RT_DEBUG_INIT
#if RT_DEBUGING_INIT
int result;
const struct rt_init_desc *desc;
......@@ -45,7 +45,7 @@ void rt_dm_secondary_cpu_init(void)
{
(*fn_ptr)();
}
#endif /* RT_DEBUG_INIT */
#endif /* RT_DEBUGING_INIT */
}
#endif /* RT_USING_SMP */
......
......@@ -85,7 +85,7 @@ static struct rt_mem_obj mm_page_mapper = {
.hint_free = hint_free,
};
#ifdef RT_DEBUG_PAGE_LEAK
#ifdef RT_DEBUGING_PAGE_LEAK
static volatile int enable;
static rt_page_t _trace_head;
#define TRACE_ALLOC(pg, size) _trace_alloc(pg, __builtin_return_address(0), size)
......@@ -556,7 +556,7 @@ static void *_do_pages_alloc(rt_uint32_t size_bits, size_t flags)
{
alloc_buf = page_to_addr(p);
#ifdef RT_DEBUG_PAGE_LEAK
#ifdef RT_DEBUGING_PAGE_LEAK
level = rt_hw_interrupt_disable();
TRACE_ALLOC(p, size_bits);
rt_hw_interrupt_enable(level);
......
......@@ -34,7 +34,7 @@
#define PAGE_ANY_AVAILABLE 0x1ul
#ifdef RT_DEBUG_PAGE_LEAK
#ifdef RT_DEBUGING_PAGE_LEAK
#define DEBUG_FIELD { \
/* trace list */ \
struct rt_page *tl_next; \
......
......@@ -577,9 +577,9 @@ Configuration is mainly done by modifying the file under project directory - rtc
#define RT_USING_OVERFLOW_CHECK
/* Define this macro to enable debug mode, if not defined, close. */
#define RT_DEBUG
#define RT_USING_DEBUG
/* When debug mode is enabled: Define this macro to enable the print component initialization information, if not defined, close. */
#define RT_DEBUG_INIT
#define RT_DEBUGING_INIT
/* Defining this macro means the use of the hook function is started, if not defined, close. */
#define RT_USING_HOOK
......
......@@ -36,13 +36,13 @@
extern "C" {
#endif
/* the debug log will force enable when RT_DEBUG macro is defined */
#if defined(RT_DEBUG) && !defined(DBG_ENABLE)
/* the debug log will force enable when RT_USING_DEBUG macro is defined */
#if defined(RT_USING_DEBUG) && !defined(DBG_ENABLE)
#define DBG_ENABLE
#endif
/* it will force output color log when RT_DEBUG_COLOR macro is defined */
#if defined(RT_DEBUG_COLOR) && !defined(DBG_COLOR)
/* it will force output color log when RT_DEBUGING_COLOR macro is defined */
#if defined(RT_DEBUGING_COLOR) && !defined(DBG_COLOR)
#define DBG_COLOR
#endif
......
......@@ -271,7 +271,7 @@ typedef __gnuc_va_list va_list;
typedef int (*init_fn_t)(void);
#ifdef _MSC_VER
#pragma section("rti_fn$f",read)
#ifdef RT_DEBUG_INIT
#ifdef RT_DEBUGING_INIT
struct rt_init_desc
{
const char* level;
......@@ -297,7 +297,7 @@ typedef int (*init_fn_t)(void);
{__rti_level_##fn, fn };
#endif
#else
#ifdef RT_DEBUG_INIT
#ifdef RT_DEBUGING_INIT
struct rt_init_desc
{
const char* fn_name;
......
......@@ -18,7 +18,7 @@
* 2021-11-14 Meco Man add rtlegacy.h for compatibility
* 2022-06-04 Meco Man remove strnlen
* 2023-05-20 Bernard add rtatomic.h header file to included files.
* 2023-06-30 ChuShicheng Move RT_DEBUG_CONTEXT_CHECK from the rtdebug.h
* 2023-06-30 ChuShicheng move debug check from the rtdebug.h
*/
#ifndef __RT_THREAD_H__
......@@ -718,24 +718,19 @@ rt_size_t rt_strlen(const char *src);
void rt_show_version(void);
#ifdef RT_DEBUG
#ifdef RT_USING_DEBUG
extern void (*rt_assert_hook)(const char *ex, const char *func, rt_size_t line);
void rt_assert_set_hook(void (*hook)(const char *ex, const char *func, rt_size_t line));
void rt_assert_handler(const char *ex, const char *func, rt_size_t line);
/* 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__); \
}
#ifdef RT_DEBUGING_CONTEXT
/* Macro to check current context */
#if RT_DEBUG_CONTEXT_CHECK
#define RT_DEBUG_NOT_IN_INTERRUPT \
do \
{ \
......@@ -806,19 +801,14 @@ while (0)
#define RT_DEBUG_NOT_IN_INTERRUPT
#define RT_DEBUG_IN_THREAD_CONTEXT
#define RT_DEBUG_SCHEDULER_AVAILABLE(need_check)
#endif
#else /* RT_DEBUG */
#endif /* RT_DEBUGING_CONTEXT */
#else
#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 /* RT_USING_DEBUG */
#ifdef RT_USING_FINSH
#include <finsh.h>
#endif
#endif /* RT_USING_FINSH */
/**@}*/
......@@ -826,4 +816,4 @@ while (0)
}
#endif
#endif
#endif /* __RT_THREAD_H__ */
......@@ -89,18 +89,18 @@ config ARCH_ARM_MMU
depends on ARCH_ARM
if RT_USING_SMART
config KERNEL_VADDR_START
hex "The virtural address of kernel start"
default 0xffff000000000000 if ARCH_ARMV8
default 0xc0000000 if ARCH_ARM
default 0x80000000 if ARCH_RISCV
depends on ARCH_MM_MMU
config RT_IOREMAP_LATE
bool "Support to create IO mapping in the kernel address space after system initlalization."
default n
depends on ARCH_ARM_CORTEX_A
depends on ARCH_MM_MMU
config KERNEL_VADDR_START
hex "The virtural address of kernel start"
default 0xffff000000000000 if ARCH_ARMV8
default 0xc0000000 if ARCH_ARM
default 0x80000000 if ARCH_RISCV
depends on ARCH_MM_MMU
config RT_IOREMAP_LATE
bool "Support to create IO mapping in the kernel address space after system initlalization."
default n
depends on ARCH_ARM_CORTEX_A
depends on ARCH_MM_MMU
endif
config ARCH_ARM_ARM9
......
......@@ -808,8 +808,8 @@ typedef int ER; /* Error code. A signed integer. */
rt_kprintf(fmt,##__VA_ARGS__); \
}while(0)
#define RT_DEBUG
#ifdef RT_DEBUG
#define RT_USING_DEBUG
#ifdef RT_USING_DEBUG
#define DBOUT(fmt,...) \
do \
{ \
......@@ -821,7 +821,7 @@ typedef int ER; /* Error code. A signed integer. */
do{}while(0)
#endif
#ifdef RT_DEBUG
#ifdef RT_USING_DEBUG
#define ASSERT(arg) \
if((arg) == 0) \
{ \
......
......@@ -81,7 +81,7 @@ struct rt_init_tag
{
const char *level;
init_fn_t fn;
#ifdef RT_DEBUG_INIT
#ifdef RT_DEBUGING_INIT
const char *fn_name;
#endif
};
......@@ -114,7 +114,7 @@ static int rt_init_objects_sort(void)
{
table->level = ((struct rt_init_desc *)ptr_begin)->level;
table->fn = ((struct rt_init_desc *)ptr_begin)->fn;
#ifdef RT_DEBUG_INIT
#ifdef RT_DEBUGING_INIT
table->fn_name = ((struct rt_init_desc *)ptr_begin)->fn_name;
#endif
ptr_begin += sizeof(struct rt_init_desc) / sizeof(unsigned int);
......@@ -168,7 +168,7 @@ void rt_components_board_init(void)
{
break;
}
#ifdef RT_DEBUG_INIT
#ifdef RT_DEBUGING_INIT
rt_kprintf("initialize %s", rt_init_table[index_i].fn_name);
result = rt_init_table[index_i].fn();
rt_kprintf(":%d done\n", result);
......@@ -203,7 +203,7 @@ void rt_components_init(void)
{
break;
}
#ifdef RT_DEBUG_INIT
#ifdef RT_DEBUGING_INIT
rt_kprintf("initialize %s", rt_init_table[index_i].fn_name);
result = rt_init_table[index_i].fn();
rt_kprintf(":%d done\n", result);
......
......@@ -374,8 +374,8 @@ typedef int ER; /* Error code. A signed integer. */
rt_kprintf(fmt,##__VA_ARGS__); \
}while(0)
#define RT_DEBUG
#ifdef RT_DEBUG
#define RT_USING_DEBUG
#ifdef RT_USING_DEBUG
#define DBOUT(fmt,...) \
do \
{ \
......@@ -387,7 +387,7 @@ typedef int ER; /* Error code. A signed integer. */
do{}while(0)
#endif
#ifdef RT_DEBUG
#ifdef RT_USING_DEBUG
#define ASSERT(arg) \
if((arg) == 0) \
{ \
......
......@@ -198,28 +198,29 @@ menu "kservice optimization"
endmenu
menuconfig RT_DEBUG
menuconfig RT_USING_DEBUG
bool "Enable debugging features"
default y
if RT_DEBUG
if RT_USING_DEBUG
config RT_DEBUGING_COLOR
bool "Enable color debugging log"
default y
config RT_DEBUG_COLOR
bool "Enable color debugging log"
default n
config RT_DEBUGING_CONTEXT
bool "Enable debugging of environment and context check"
default y
config RT_DEBUG_INIT
bool "Enable debugging of components initialization"
default n
config RT_DEBUGING_INIT
bool "Enable debugging of components initialization"
default y
if ARCH_MM_MMU
config RT_DEBUG_PAGE_LEAK
config RT_DEBUGING_PAGE_LEAK
bool "Enable page leaking tracer"
depends on ARCH_MM_MMU
default n
endif
endif
menu "Inter-Thread communication"
config RT_USING_SEMAPHORE
......@@ -260,17 +261,16 @@ endmenu
menu "Memory Management"
if ARCH_MM_MMU
config RT_PAGE_MAX_ORDER
int "Max order of pages allocatable by page allocator"
default 11
help
For example, A value of 11 means the maximum chunk of contiguous memory
allocatable by page system is 2^(11 + ARCH_PAGE_BITS - 1) Bytes.
Large memory requirement can consume all system resource, and should
consider reserved memory instead to enhance system endurance.
Max order should at least satisfied usage by huge page.
endif
config RT_PAGE_MAX_ORDER
int "Max order of pages allocatable by page allocator"
default 11
depends on ARCH_MM_MMU
help
For example, A value of 11 means the maximum chunk of contiguous memory
allocatable by page system is 2^(11 + ARCH_PAGE_BITS - 1) Bytes.
Large memory requirement can consume all system resource, and should
consider reserved memory instead to enhance system endurance.
Max order should at least satisfied usage by huge page.
config RT_USING_MEMPOOL
bool "Using memory pool"
......
......@@ -84,7 +84,7 @@ INIT_EXPORT(rti_end, "6.end");
*/
void rt_components_board_init(void)
{
#ifdef RT_DEBUG_INIT
#ifdef RT_DEBUGING_INIT
int result;
const struct rt_init_desc *desc;
for (desc = &__rt_init_desc_rti_board_start; desc < &__rt_init_desc_rti_board_end; desc ++)
......@@ -100,7 +100,7 @@ void rt_components_board_init(void)
{
(*fn_ptr)();
}
#endif /* RT_DEBUG_INIT */
#endif /* RT_DEBUGING_INIT */
}
/**
......@@ -108,7 +108,7 @@ void rt_components_board_init(void)
*/
void rt_components_init(void)
{
#ifdef RT_DEBUG_INIT
#ifdef RT_DEBUGING_INIT
int result;
const struct rt_init_desc *desc;
......@@ -126,7 +126,7 @@ void rt_components_init(void)
{
(*fn_ptr)();
}
#endif /* RT_DEBUG_INIT */
#endif /* RT_DEBUGING_INIT */
}
#endif /* RT_USING_COMPONENTS_INIT */
......
......@@ -1987,7 +1987,7 @@ int __rt_ffs(int value)
#define __on_rt_assert_hook(ex, func, line) __ON_HOOK_ARGS(rt_assert_hook, (ex, func, line))
#endif
#ifdef RT_DEBUG
#ifdef RT_USING_DEBUG
/* RT_ASSERT(EX)'s hook */
void (*rt_assert_hook)(const char *ex, const char *func, rt_size_t line);
......@@ -2036,6 +2036,6 @@ void rt_assert_handler(const char *ex_string, const char *func, rt_size_t line)
}
}
RTM_EXPORT(rt_assert_handler);
#endif /* RT_DEBUG */
#endif /* RT_USING_DEBUG */
/**@}*/
......@@ -353,7 +353,7 @@ void rt_object_init(struct rt_object *object,
const char *name)
{
rt_base_t level;
#ifdef RT_DEBUG
#ifdef RT_USING_DEBUG
struct rt_list_node *node = RT_NULL;
#endif
struct rt_object_information *information;
......@@ -365,7 +365,7 @@ void rt_object_init(struct rt_object *object,
information = rt_object_get_information(type);
RT_ASSERT(information != RT_NULL);
#ifdef RT_DEBUG
#ifdef RT_USING_DEBUG
/* check object type to avoid re-initialization */
/* enter critical */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册