From 9547133e6488d65e8a2ebf365a3411b861d14718 Mon Sep 17 00:00:00 2001 From: Haryslee Date: Thu, 15 Jul 2021 19:19:56 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E4=BF=AE=E5=A4=8Dllvm=E7=BC=96?= =?UTF-8?q?=E8=AF=91=E7=8E=AF=E5=A2=83=E4=B8=8B=E5=86=85=E6=A0=B8=E6=80=81?= =?UTF-8?q?=E5=86=85=E5=AD=98=E8=B0=83=E6=B5=8B=E8=B0=83=E7=94=A8=E6=A0=88?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E8=A7=A3=E6=9E=90=E6=9C=89=E8=AF=AF=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 背景:内核态内存调测调用栈信息在gcc编译环境下是准确的,但是llvm 编译环境下是错误的,分析知,gcc和llvm编译环境下fp和lr的对应关系 是有区别的。 修复:增加llvm编译环境下对lr解析的逻辑,并用编译宏控制。 close #I40TQS Signed-off-by: Haryslee Change-Id: If2a7b7a286d91e78dcff2bdeb136fda71e656a79 --- arch/arm/arm/src/los_exc.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/arch/arm/arm/src/los_exc.c b/arch/arm/arm/src/los_exc.c index c90f591f..297a061b 100644 --- a/arch/arm/arm/src/los_exc.c +++ b/arch/arm/arm/src/los_exc.c @@ -721,7 +721,7 @@ VOID BackTraceSub(UINTPTR regFP) while (IsValidFP(backFP, stackStart, stackEnd, &kvaddr) == TRUE) { tmpFP = backFP; #ifdef LOSCFG_COMPILER_CLANG_LLVM - backFP = *(UINTPTR *)(UINTPTR)kvaddr; + backFP = *(UINTPTR *)(UINTPTR)kvaddr; if (IsValidFP(tmpFP + POINTER_SIZE, stackStart, stackEnd, &kvaddr) == FALSE) { PrintExcInfo("traceback backLR check failed, backLP: 0x%x\n", tmpFP + POINTER_SIZE); return; @@ -1215,7 +1215,11 @@ VOID LOS_RecordLR(UINTPTR *LR, UINT32 LRSize, UINT32 recordCount, UINT32 jumpCou framePtr = Get_Fp(); while ((framePtr > stackStart) && (framePtr < stackEnd) && IS_ALIGNED(framePtr, sizeof(CHAR *))) { tmpFramePtr = framePtr; +#ifdef LOSCFG_COMPILER_CLANG_LLVM + linkReg = *(UINTPTR *)(tmpFramePtr + sizeof(UINTPTR)); +#else linkReg = *(UINTPTR *)framePtr; +#endif if (index >= jumpCount) { LR[count++] = linkReg; if (count == recordCount) { @@ -1223,7 +1227,11 @@ VOID LOS_RecordLR(UINTPTR *LR, UINT32 LRSize, UINT32 recordCount, UINT32 jumpCou } } index++; +#ifdef LOSCFG_COMPILER_CLANG_LLVM + framePtr = *(UINTPTR *)framePtr; +#else framePtr = *(UINTPTR *)(tmpFramePtr - sizeof(UINTPTR)); +#endif } /* if linkReg is not enough,clean up the last of the effective LR as the end. */