fix:LR value is incorrectly parsed when the user mode exception stack is backtracked

This commit is contained in:
zhangfanfan2 2021-04-23 11:53:06 +08:00 committed by Gitee
parent e93ff481bb
commit 9ab63a41b3
1 changed files with 4 additions and 2 deletions

View File

@ -663,6 +663,7 @@ VOID BackTraceSub(UINTPTR regFP)
UINTPTR backFP = regFP; UINTPTR backFP = regFP;
UINT32 count = 0; UINT32 count = 0;
VADDR_T kvaddr; VADDR_T kvaddr;
LosProcessCB *runProcess = OsCurrProcessGet();
if (FindSuitableStack(regFP, &stackStart, &stackEnd, &kvaddr) == FALSE) { if (FindSuitableStack(regFP, &stackStart, &stackEnd, &kvaddr) == FALSE) {
PrintExcInfo("traceback error fp = 0x%x\n", regFP); PrintExcInfo("traceback error fp = 0x%x\n", regFP);
@ -701,11 +702,12 @@ VOID BackTraceSub(UINTPTR regFP)
#ifdef LOSCFG_KERNEL_VM #ifdef LOSCFG_KERNEL_VM
LosVmMapRegion *region = NULL; LosVmMapRegion *region = NULL;
if (LOS_IsUserAddress((VADDR_T)backLR) == TRUE) { if (LOS_IsUserAddress((VADDR_T)backLR) == TRUE) {
region = LOS_RegionFind(OsCurrProcessGet()->vmSpace, (VADDR_T)backLR); region = LOS_RegionFind(runProcess->vmSpace, (VADDR_T)backLR);
} }
if (region != NULL) { if (region != NULL) {
PrintExcInfo("traceback %u -- lr = 0x%x fp = 0x%x lr in %s --> 0x%x\n", count, backLR, backFP, PrintExcInfo("traceback %u -- lr = 0x%x fp = 0x%x lr in %s --> 0x%x\n", count, backLR, backFP,
OsGetRegionNameOrFilePath(region), backLR - region->range.base); OsGetRegionNameOrFilePath(region),
backLR - OsGetTextRegionBase(region, runProcess));
region = NULL; region = NULL;
} else } else
#endif #endif