From a0a32188ffe7b7b9b6b4df2fe01fd84f95bdf045 Mon Sep 17 00:00:00 2001 From: kenneth <459864689@qq.com> Date: Tue, 15 Jun 2021 14:29:13 +0800 Subject: [PATCH] update: rename LOS_BackTraceInit change function name LOS_BackTraceInit and involve it in los_init.c when macro is not set to 0 close https://gitee.com/openharmony/kernel_liteos_m/issues/I3SYQQ Signed-off-by: kenneth <459864689@qq.com> --- components/backtrace/los_backtrace.c | 2 +- components/backtrace/los_backtrace.h | 2 +- kernel/BUILD.gn | 1 + kernel/include/los_config.h | 5 ++++- kernel/src/los_init.c | 8 ++++++++ utils/los_debug.c | 2 +- 6 files changed, 16 insertions(+), 4 deletions(-) diff --git a/components/backtrace/los_backtrace.c b/components/backtrace/los_backtrace.c index 1910be60..649da6da 100644 --- a/components/backtrace/los_backtrace.c +++ b/components/backtrace/los_backtrace.c @@ -407,7 +407,7 @@ VOID LOS_BackTrace(VOID) PRINTK("----- traceback end -----\r\n"); } -VOID LOS_BackTraceInit(VOID) +VOID OSBackTraceInit(VOID) { OsBackTraceHookSet(LOS_RecordLR); } diff --git a/components/backtrace/los_backtrace.h b/components/backtrace/los_backtrace.h index b9d1886e..a38c1899 100644 --- a/components/backtrace/los_backtrace.h +++ b/components/backtrace/los_backtrace.h @@ -153,7 +153,7 @@ STATIC INLINE BOOL OsStackDataIsCodeAddr(UINTPTR value) /* This function is currently used to register the memory leak check hook, other uses do not need to be called temporarily. */ -VOID LOS_BackTraceInit(VOID); +VOID OSBackTraceInit(VOID); /* This function is used to print the function call stack. */ VOID LOS_BackTrace(VOID); diff --git a/kernel/BUILD.gn b/kernel/BUILD.gn index 0eb0b54c..7d7d7e64 100644 --- a/kernel/BUILD.gn +++ b/kernel/BUILD.gn @@ -48,6 +48,7 @@ static_library("kernel") { "arch/include", "../components/cpup", "../components/exchook", + "../components/backtrace", "../utils", "//third_party/bounds_checking_function/include", ] diff --git a/kernel/include/los_config.h b/kernel/include/los_config.h index e3f200ef..6c73b2ea 100644 --- a/kernel/include/los_config.h +++ b/kernel/include/los_config.h @@ -459,10 +459,13 @@ extern UINT8 *m_aucSysMem0; * Configuration memory leak detection * @attention * Need to enable backtrace module synchronously by configuration LOSCFG_BACKTRACE_TYPE, - * and call LOS_BackTraceInit to complete initialization before the memory pool is initialized. + * and call OSBackTraceInit to complete initialization before the memory pool is initialized. */ #ifndef LOSCFG_MEM_LEAKCHECK #define LOSCFG_MEM_LEAKCHECK 0 +#if (LOSCFG_BACKTRACE_TYPE == 0) + #error "Backtrace module should be enabled by setting LOSCFG_BACKTRACE_TYPE to not 0 in target_config.h" +#endif #endif /** diff --git a/kernel/src/los_init.c b/kernel/src/los_init.c index dfdf499c..a363db47 100644 --- a/kernel/src/los_init.c +++ b/kernel/src/los_init.c @@ -58,6 +58,10 @@ #include "los_exc_info.h" #endif +#if (LOSCFG_BACKTRACE_TYPE != 0) +#include "los_backtrace.h" +#endif + /***************************************************************************** Function : LOS_Reboot @@ -113,6 +117,10 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_KernelInit(VOID) UINT32 ret; PRINTK("entering kernel init...\n"); +#if (LOSCFG_BACKTRACE_TYPE != 0) + OSBackTraceInit(); +#endif + OsRegister(); ret = OsMemSystemInit(); if (ret != LOS_OK) { diff --git a/utils/los_debug.c b/utils/los_debug.c index fbd78865..aa61c4cf 100644 --- a/utils/los_debug.c +++ b/utils/los_debug.c @@ -61,7 +61,7 @@ VOID OsBackTraceHookCall(UINTPTR *LR, UINT32 LRSize, UINT32 jumpCount, UINTPTR S g_backTraceHook(LR, LRSize, jumpCount, SP); } else { PRINT_ERR("Record LR failed, because of g_backTraceHook is not registered, " - "should call LOS_BackTraceInit firstly\n"); + "should call OSBackTraceInit firstly\n"); } }