Assertions: Identify the running task correctly when dumping task state information. It takes time to switch to the target task after g_readytorun has been modified. If panic/assert happen during this period, the dump will contain the incorrect and confusing information due to the difference between the real running task and the return value of this_task(). This change resolve this problem by adding g_running_task to track the real running task through the context switch.

This commit is contained in:
Xiang Xiao
2018-11-15 07:11:51 -06:00
committed by Gregory Nutt
parent a087df2647
commit dbf01d12b7
27 changed files with 107 additions and 67 deletions
+5 -5
View File
@@ -117,7 +117,7 @@ static void xtensa_assert(int errorcode)
#ifdef CONFIG_BOARD_CRASHDUMP
/* Perform board-specific crash dump */
board_crashdump(up_getsp(), this_task(), filename, lineno);
board_crashdump(up_getsp(), running_task(), filename, lineno);
#endif
/* Flush any buffered SYSLOG data (from the above) */
@@ -126,7 +126,7 @@ static void xtensa_assert(int errorcode)
/* Are we in an interrupt handler or the idle task? */
if (CURRENT_REGS || this_task()->pid == 0)
if (CURRENT_REGS || running_task()->pid == 0)
{
/* Blink the LEDs forever */
@@ -166,7 +166,7 @@ static void xtensa_assert(int errorcode)
void up_assert(const uint8_t *filename, int lineno)
{
#if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT)
struct tcb_s *rtcb = this_task();
struct tcb_s *rtcb = running_task();
#endif
board_autoled_on(LED_ASSERTION);
@@ -211,7 +211,7 @@ void up_assert(const uint8_t *filename, int lineno)
void xtensa_panic(int xptcode, uint32_t *regs)
{
#if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT)
struct tcb_s *rtcb = this_task();
struct tcb_s *rtcb = running_task();
#endif
/* We get here when a un-dispatch-able, irrecoverable exception occurs */
@@ -315,7 +315,7 @@ void xtensa_panic(int xptcode, uint32_t *regs)
void xtensa_user(int exccause, uint32_t *regs)
{
#if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT)
struct tcb_s *rtcb = this_task();
struct tcb_s *rtcb = running_task();
#endif
/* We get here when a un-dispatch-able, irrecoverable exception occurs */
+1 -1
View File
@@ -193,7 +193,7 @@ static inline void xtensa_registerdump(void)
void xtensa_dumpstate(void)
{
struct tcb_s *rtcb = this_task();
struct tcb_s *rtcb = running_task();
uint32_t sp = xtensa_getsp();
uint32_t ustackbase;
uint32_t ustacksize;