fix: 修复risc-v异常时,异常信息混乱且backtrace无法输出的问题
1.修复risc-v backtrace无法输出的问题 异常时未将fp传入,且backtrace校验不足,容易导致再次异常 2.优化task 输出信息格式 3.shell中task命令代码重复 4.OSBackTraceInit 拼写有误 Close #I4BPHX:riscv32_virt 异常时无法输出backtrace信息 Signed-off-by: zhushengle <zhushengle@huawei.com> Change-Id: I141d5e7808fc967d846f425422f5dcf2ac01d1d1
This commit is contained in:
@@ -218,41 +218,21 @@ LITE_OS_SEC_TEXT UINT32 HalHwiDelete(HWI_HANDLE_T hwiNum)
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC VOID DisplayTaskInfo(VOID)
|
||||
STATIC VOID ExcBackTrace(UINTPTR fp)
|
||||
{
|
||||
TSK_INFO_S taskInfo;
|
||||
UINT32 index;
|
||||
UINT32 ret;
|
||||
|
||||
PRINTK("ID Pri Status name \n\r");
|
||||
PRINTK("-- --- --------- ----\n\r");
|
||||
|
||||
for (index = 0; index < LOSCFG_BASE_CORE_TSK_LIMIT; index++) {
|
||||
ret = LOS_TaskInfoGet(index, &taskInfo);
|
||||
if (ret != LOS_OK) {
|
||||
continue;
|
||||
}
|
||||
PRINTK("%d %d %s %s \n\r",
|
||||
taskInfo.uwTaskID, taskInfo.usTaskPrio, OsConvertTskStatus(taskInfo.usTaskStatus), taskInfo.acName);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
STATIC VOID ExcBackTrace(VOID)
|
||||
{
|
||||
UINTPTR LR[LOSCFG_BACKTRACE_DEPTH] = {0};
|
||||
UINTPTR LR[LOSCFG_BACKTRACE_DEPTH] = { 0 };
|
||||
UINT32 index;
|
||||
|
||||
OsBackTraceHookCall(LR, LOSCFG_BACKTRACE_DEPTH, 1, 0); /* 1: Ignore the one layer call relationship within the function. */
|
||||
OsBackTraceHookCall(LR, LOSCFG_BACKTRACE_DEPTH, 0, fp);
|
||||
|
||||
PRINTK("----- traceback start -----\r\n");
|
||||
PRINTK("----- traceback start -----\n");
|
||||
for (index = 0; index < LOSCFG_BACKTRACE_DEPTH; index++) {
|
||||
if (LR[index] == 0) {
|
||||
break;
|
||||
}
|
||||
PRINTK("traceback %d -- lr = 0x%x\r\n", index, LR[index]);
|
||||
PRINTK("traceback %d -- lr = 0x%x\n", index, LR[index]);
|
||||
}
|
||||
PRINTK("----- traceback end -----\r\n");
|
||||
PRINTK("----- traceback end -----\n");
|
||||
}
|
||||
|
||||
STATIC VOID ExcInfoDisplayContext(const LosExcInfo *exc)
|
||||
@@ -295,29 +275,33 @@ STATIC VOID ExcInfoDisplayContext(const LosExcInfo *exc)
|
||||
PRINTK("t5 = 0x%x\n", taskContext->t5);
|
||||
PRINTK("t6 = 0x%x\n", taskContext->t6);
|
||||
|
||||
ExcBackTrace();
|
||||
ExcBackTrace(taskContext->s0);
|
||||
}
|
||||
|
||||
STATIC VOID ExcInfoDisplay(const LosExcContext *excBufAddr)
|
||||
{
|
||||
PRINTK("\r\nException Information \n\r");
|
||||
PRINTK("\nException Information \n");
|
||||
|
||||
if (g_excInfo.type < RISCV_EXC_TYPE_NUM) {
|
||||
PRINTK("Exc type : Oops - %s\n\r", g_excInformation[g_excInfo.type]);
|
||||
PRINTK("Exc type : Oops - %s\n", g_excInformation[g_excInfo.type]);
|
||||
} else {
|
||||
PRINTK("Exc type : Oops - Invalid\n\r");
|
||||
PRINTK("Exc type : Oops - Invalid\n");
|
||||
}
|
||||
|
||||
PRINTK("taskName = %s\n\r", g_losTask.runTask->taskName);
|
||||
PRINTK("taskID = %u\n\r", g_losTask.runTask->taskID);
|
||||
PRINTK("system mem addr:0x%x\n\r", (UINTPTR)LOSCFG_SYS_HEAP_ADDR);
|
||||
if (LOS_TaskIsRunning()) {
|
||||
PRINTK("taskName = %s\n", g_losTask.runTask->taskName);
|
||||
PRINTK("taskID = %u\n", g_losTask.runTask->taskID);
|
||||
} else {
|
||||
PRINTK("The exception occurs during system startup!\n");
|
||||
}
|
||||
PRINTK("system mem addr:0x%x\n", (UINTPTR)LOSCFG_SYS_HEAP_ADDR);
|
||||
ExcInfoDisplayContext(&g_excInfo);
|
||||
}
|
||||
|
||||
WEAK UINT32 HalUnalignedAccessFix(UINTPTR mcause, UINTPTR mepc, UINTPTR mtval, VOID *sp)
|
||||
{
|
||||
/* Unaligned access fixes are not supported by default */
|
||||
PRINTK("Unaligned access fixes are not supported by default!\n\r");
|
||||
PRINTK("Unaligned access fixes are not supported by default!\n");
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
@@ -327,7 +311,7 @@ VOID HalExcEntry(const LosExcContext *excBufAddr)
|
||||
g_excInfo.type = excBufAddr->mcause & 0x1FF;
|
||||
g_excInfo.context = (LosExcContext *)excBufAddr;
|
||||
if (g_excInfo.nestCnt > 2) { /* 2: Number of layers of exception nesting */
|
||||
PRINTK("hard fault!\n\r");
|
||||
PRINTK("hard fault!\n");
|
||||
goto SYSTEM_DEATH;
|
||||
}
|
||||
|
||||
@@ -342,8 +326,10 @@ VOID HalExcEntry(const LosExcContext *excBufAddr)
|
||||
|
||||
ExcInfoDisplay(excBufAddr);
|
||||
|
||||
PRINTK("----------------All Task infomation ------------\n\r");
|
||||
DisplayTaskInfo();
|
||||
if (LOS_TaskIsRunning()) {
|
||||
PRINTK("----------------All Task infomation ------------\n");
|
||||
OsGetAllTskInfo();
|
||||
}
|
||||
|
||||
SYSTEM_DEATH:
|
||||
OsDoExcHook(EXC_INTERRUPT);
|
||||
|
||||
@@ -483,7 +483,7 @@ extern UINT8 *m_aucSysMem0;
|
||||
* Configuration memory leak detection
|
||||
* @attention
|
||||
* Need to enable backtrace module synchronously by configuration LOSCFG_BACKTRACE_TYPE,
|
||||
* and call OSBackTraceInit 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
|
||||
|
||||
@@ -121,7 +121,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_KernelInit(VOID)
|
||||
PRINTK("entering kernel init...\n");
|
||||
|
||||
#if (LOSCFG_BACKTRACE_TYPE != 0)
|
||||
OSBackTraceInit();
|
||||
OsBackTraceInit();
|
||||
#endif
|
||||
|
||||
OsRegister();
|
||||
|
||||
@@ -288,18 +288,17 @@ LITE_OS_SEC_TEXT_MINOR UINT32 OsGetAllTskCpupInfo(CPUP_INFO_S **cpuLessOneSec,
|
||||
|
||||
LITE_OS_SEC_TEXT_MINOR VOID OsPrintAllTskInfoHeader()
|
||||
{
|
||||
PRINTK("\r\nTID Priority Status "
|
||||
"StackSize WaterLine StackPoint TopOfStack EventMask SemID");
|
||||
PRINTK("\r\n TID Priority Status StackSize WaterLine StackPoint TopOfStack EventMask SemID");
|
||||
#if (LOSCFG_BASE_CORE_CPUP == 1)
|
||||
PRINTK(" CPUUSE CPUUSE10s CPUUSE1s ");
|
||||
PRINTK(" CPUUSE CPUUSE10s CPUUSE1s ");
|
||||
#endif /* LOSCFG_BASE_CORE_CPUP */
|
||||
PRINTK(" name\n");
|
||||
PRINTK("--- -------- -------- ");
|
||||
PRINTK("--------- ---------- ---------- ---------- --------- -----");
|
||||
PRINTK("name\n");
|
||||
PRINTK(" --- -------- -------- ");
|
||||
PRINTK("--------- --------- ---------- ---------- --------- ------ ");
|
||||
#if (LOSCFG_BASE_CORE_CPUP == 1)
|
||||
PRINTK(" ------- --------- ---------");
|
||||
PRINTK("------- --------- -------- ");
|
||||
#endif /* LOSCFG_BASE_CORE_CPUP */
|
||||
PRINTK(" ----\n");
|
||||
PRINTK("----\n");
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
@@ -335,16 +334,14 @@ LITE_OS_SEC_TEXT_MINOR UINT32 OsGetAllTskInfo(VOID)
|
||||
continue;
|
||||
}
|
||||
|
||||
PRINTK("%d %d %s 0x%x 0x%x 0x%x 0x%x 0x%x ",
|
||||
semID = (taskCB->taskSem == NULL) ? OS_NULL_SHORT : (((LosSemCB *)taskCB->taskSem)->semID);
|
||||
PRINTK("%4u%9u%10s%#10x%#10x%#11x%#11x%#10x%#7x",
|
||||
taskCB->taskID, taskCB->priority, OsConvertTskStatus(taskCB->taskStatus),
|
||||
taskCB->stackSize, OsGetTaskWaterLine(taskCB->taskID),
|
||||
(UINT32)(UINTPTR)taskCB->stackPointer, taskCB->topOfStack, taskCB->eventMask);
|
||||
|
||||
semID = (taskCB->taskSem == NULL) ? OS_NULL_SHORT : (((LosSemCB *)taskCB->taskSem)->semID);
|
||||
PRINTK("0x%x ", semID);
|
||||
(UINT32)(UINTPTR)taskCB->stackPointer, taskCB->topOfStack, taskCB->eventMask, semID);
|
||||
|
||||
#if (LOSCFG_BASE_CORE_CPUP == 1)
|
||||
PRINTK("%d.%d %d.%d %d.%d ",
|
||||
PRINTK("%6u.%-2u%7u.%-2u%6u.%-2u ",
|
||||
cpuLessOneSec[taskCB->taskID].uwUsage / LOS_CPUP_PRECISION_MULT,
|
||||
cpuLessOneSec[taskCB->taskID].uwUsage % LOS_CPUP_PRECISION_MULT,
|
||||
cpuTenSec[taskCB->taskID].uwUsage / LOS_CPUP_PRECISION_MULT,
|
||||
@@ -352,7 +349,7 @@ LITE_OS_SEC_TEXT_MINOR UINT32 OsGetAllTskInfo(VOID)
|
||||
cpuOneSec[taskCB->taskID].uwUsage / LOS_CPUP_PRECISION_MULT,
|
||||
cpuOneSec[taskCB->taskID].uwUsage % LOS_CPUP_PRECISION_MULT);
|
||||
#endif /* LOSCFG_BASE_CORE_CPUP */
|
||||
PRINTK("%s\n", taskCB->taskName);
|
||||
PRINTK("%-32s\n", taskCB->taskName);
|
||||
}
|
||||
|
||||
#if (LOSCFG_BASE_CORE_CPUP == 1)
|
||||
|
||||
Reference in New Issue
Block a user