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

This commit is contained in:
Man, Jianting (Meco)
2023-07-21 22:36:42 -04:00
committed by GitHub
parent 52d3637fba
commit 244b903e5d
34 changed files with 92 additions and 102 deletions

View File

@@ -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

View File

@@ -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;

View File

@@ -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__ */