mirror of
https://github.com/apache/nuttx.git
synced 2026-06-04 14:53:47 +08:00
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:
@@ -190,7 +190,7 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg)
|
||||
#ifdef CONFIG_ARCH_STACKDUMP
|
||||
static void up_dumpstate(void)
|
||||
{
|
||||
struct tcb_s *rtcb = this_task();
|
||||
struct tcb_s *rtcb = running_task();
|
||||
uint32_t sp = up_getsp();
|
||||
uint32_t ustackbase;
|
||||
uint32_t ustacksize;
|
||||
@@ -310,7 +310,7 @@ static void _up_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)
|
||||
{
|
||||
(void)up_irq_save();
|
||||
for (; ; )
|
||||
@@ -346,7 +346,7 @@ static void _up_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);
|
||||
@@ -370,7 +370,7 @@ void up_assert(const uint8_t *filename, int lineno)
|
||||
(void)syslog_flush();
|
||||
|
||||
#ifdef CONFIG_BOARD_CRASHDUMP
|
||||
board_crashdump(up_getsp(), this_task(), filename, lineno);
|
||||
board_crashdump(up_getsp(), running_task(), filename, lineno);
|
||||
#endif
|
||||
|
||||
_up_assert(EXIT_FAILURE);
|
||||
|
||||
@@ -227,7 +227,7 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg)
|
||||
#ifdef CONFIG_ARCH_STACKDUMP
|
||||
static void up_dumpstate(void)
|
||||
{
|
||||
struct tcb_s *rtcb = this_task();
|
||||
struct tcb_s *rtcb = running_task();
|
||||
uint32_t sp = up_getsp();
|
||||
uint32_t ustackbase;
|
||||
uint32_t ustacksize;
|
||||
@@ -367,7 +367,7 @@ static void _up_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)
|
||||
{
|
||||
(void)up_irq_save();
|
||||
for (; ; )
|
||||
@@ -403,7 +403,7 @@ static void _up_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);
|
||||
@@ -427,7 +427,7 @@ void up_assert(const uint8_t *filename, int lineno)
|
||||
(void)syslog_flush();
|
||||
|
||||
#ifdef CONFIG_BOARD_CRASHDUMP
|
||||
board_crashdump(up_getsp(), this_task(), filename, lineno);
|
||||
board_crashdump(up_getsp(), running_task(), filename, lineno);
|
||||
#endif
|
||||
|
||||
_up_assert(EXIT_FAILURE);
|
||||
|
||||
@@ -228,7 +228,7 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg)
|
||||
#ifdef CONFIG_ARCH_STACKDUMP
|
||||
static void up_dumpstate(void)
|
||||
{
|
||||
struct tcb_s *rtcb = this_task();
|
||||
struct tcb_s *rtcb = running_task();
|
||||
uint32_t sp = up_getsp();
|
||||
uint32_t ustackbase;
|
||||
uint32_t ustacksize;
|
||||
@@ -395,7 +395,7 @@ static void _up_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)
|
||||
{
|
||||
/* Disable interrupts on this CPU */
|
||||
|
||||
@@ -442,7 +442,7 @@ static void _up_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);
|
||||
@@ -476,7 +476,7 @@ void up_assert(const uint8_t *filename, int lineno)
|
||||
(void)syslog_flush();
|
||||
|
||||
#ifdef CONFIG_BOARD_CRASHDUMP
|
||||
board_crashdump(up_getsp(), this_task(), filename, lineno);
|
||||
board_crashdump(up_getsp(), running_task(), filename, lineno);
|
||||
#endif
|
||||
|
||||
_up_assert(EXIT_FAILURE);
|
||||
|
||||
@@ -235,7 +235,7 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg)
|
||||
#ifdef CONFIG_ARCH_STACKDUMP
|
||||
static void up_dumpstate(void)
|
||||
{
|
||||
struct tcb_s *rtcb = this_task();
|
||||
struct tcb_s *rtcb = running_task();
|
||||
uint32_t sp = up_getsp();
|
||||
uint32_t ustackbase;
|
||||
uint32_t ustacksize;
|
||||
@@ -389,7 +389,7 @@ static void _up_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)
|
||||
{
|
||||
(void)up_irq_save();
|
||||
for (; ; )
|
||||
@@ -431,7 +431,7 @@ static void _up_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);
|
||||
@@ -465,7 +465,7 @@ void up_assert(const uint8_t *filename, int lineno)
|
||||
(void)syslog_flush();
|
||||
|
||||
#ifdef CONFIG_BOARD_CRASHDUMP
|
||||
board_crashdump(up_getsp(), this_task(), filename, lineno);
|
||||
board_crashdump(up_getsp(), running_task(), filename, lineno);
|
||||
#endif
|
||||
|
||||
_up_assert(EXIT_FAILURE);
|
||||
|
||||
@@ -224,7 +224,7 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg)
|
||||
#ifdef CONFIG_ARCH_STACKDUMP
|
||||
static void up_dumpstate(void)
|
||||
{
|
||||
struct tcb_s *rtcb = this_task();
|
||||
struct tcb_s *rtcb = running_task();
|
||||
uint32_t sp = up_getsp();
|
||||
uint32_t ustackbase;
|
||||
uint32_t ustacksize;
|
||||
@@ -374,7 +374,7 @@ static void _up_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)
|
||||
{
|
||||
(void)up_irq_save();
|
||||
for (; ; )
|
||||
@@ -410,7 +410,7 @@ static void _up_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);
|
||||
@@ -434,7 +434,7 @@ void up_assert(const uint8_t *filename, int lineno)
|
||||
(void)syslog_flush();
|
||||
|
||||
#ifdef CONFIG_BOARD_CRASHDUMP
|
||||
board_crashdump(up_getsp(), this_task(), filename, lineno);
|
||||
board_crashdump(up_getsp(), running_task(), filename, lineno);
|
||||
#endif
|
||||
|
||||
_up_assert(EXIT_FAILURE);
|
||||
|
||||
@@ -160,7 +160,7 @@ static inline void up_registerdump(void)
|
||||
|
||||
void up_dumpstate(void)
|
||||
{
|
||||
struct tcb_s *rtcb = this_task();
|
||||
struct tcb_s *rtcb = running_task();
|
||||
uint16_t sp = up_getsp();
|
||||
uint16_t ustackbase;
|
||||
uint16_t ustacksize;
|
||||
|
||||
@@ -126,7 +126,7 @@ static inline void up_registerdump(void)
|
||||
|
||||
void up_dumpstate(void)
|
||||
{
|
||||
struct tcb_s *rtcb = this_task();
|
||||
struct tcb_s *rtcb = running_task();
|
||||
uint32_t sp = up_getsp();
|
||||
uint32_t ustackbase;
|
||||
uint32_t ustacksize;
|
||||
|
||||
@@ -87,7 +87,7 @@ static void _up_assert(int errorcode)
|
||||
|
||||
/* Are we in an interrupt handler or the idle task? */
|
||||
|
||||
if (g_current_regs || this_task()->pid == 0)
|
||||
if (g_current_regs || running_task()->pid == 0)
|
||||
{
|
||||
(void)up_irq_save();
|
||||
for (; ; )
|
||||
@@ -148,7 +148,7 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg)
|
||||
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);
|
||||
@@ -172,7 +172,7 @@ void up_assert(const uint8_t *filename, int lineno)
|
||||
(void)syslog_flush();
|
||||
|
||||
#ifdef CONFIG_BOARD_CRASHDUMP
|
||||
board_crashdump(up_getsp(), this_task(), filename, lineno);
|
||||
board_crashdump(up_getsp(), running_task(), filename, lineno);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ARCH_USBDUMP
|
||||
|
||||
@@ -184,7 +184,7 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg)
|
||||
#ifdef CONFIG_ARCH_STACKDUMP
|
||||
static void up_dumpstate(void)
|
||||
{
|
||||
struct tcb_s *rtcb = this_task();
|
||||
struct tcb_s *rtcb = running_task();
|
||||
uint16_t sp = up_getsp();
|
||||
uint16_t ustackbase;
|
||||
uint16_t ustacksize;
|
||||
@@ -294,7 +294,7 @@ static void _up_assert(int errorcode)
|
||||
|
||||
/* Are we in an interrupt handler or the idle task? */
|
||||
|
||||
if (g_current_regs || (this_task())->pid == 0)
|
||||
if (g_current_regs || (running_task())->pid == 0)
|
||||
{
|
||||
(void)up_irq_save();
|
||||
for (;;)
|
||||
@@ -330,7 +330,7 @@ static void _up_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);
|
||||
@@ -354,7 +354,7 @@ void up_assert(const uint8_t *filename, int lineno)
|
||||
(void)syslog_flush();
|
||||
|
||||
#ifdef CONFIG_BOARD_CRASHDUMP
|
||||
board_crashdump(up_getsp(), this_task(), filename, lineno);
|
||||
board_crashdump(up_getsp(), running_task(), filename, lineno);
|
||||
#endif
|
||||
|
||||
_up_assert(EXIT_FAILURE);
|
||||
|
||||
@@ -86,7 +86,7 @@ static void _up_assert(int errorcode)
|
||||
|
||||
/* Are we in an interrupt handler or the idle task? */
|
||||
|
||||
if (g_current_regs || this_task()->pid == 0)
|
||||
if (g_current_regs || running_task()->pid == 0)
|
||||
{
|
||||
(void)up_irq_save();
|
||||
for (; ; )
|
||||
@@ -147,7 +147,7 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg)
|
||||
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);
|
||||
@@ -177,7 +177,7 @@ void up_assert(const uint8_t *filename, int lineno)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BOARD_CRASHDUMP
|
||||
board_crashdump(up_getsp(), this_task(), filename, lineno);
|
||||
board_crashdump(up_getsp(), running_task(), filename, lineno);
|
||||
#endif
|
||||
|
||||
_up_assert(EXIT_FAILURE);
|
||||
|
||||
@@ -139,7 +139,7 @@ static inline void up_registerdump(void)
|
||||
|
||||
void up_dumpstate(void)
|
||||
{
|
||||
struct tcb_s *rtcb = this_task();
|
||||
struct tcb_s *rtcb = running_task();
|
||||
uint32_t sp = up_getsp();
|
||||
uint32_t ustackbase;
|
||||
uint32_t ustacksize;
|
||||
|
||||
@@ -87,7 +87,7 @@ static void _up_assert(int errorcode)
|
||||
|
||||
/* Are we in an interrupt handler or the idle task? */
|
||||
|
||||
if (g_current_regs || this_task()->pid == 0)
|
||||
if (g_current_regs || running_task()->pid == 0)
|
||||
{
|
||||
(void)up_irq_save();
|
||||
for (; ; )
|
||||
@@ -148,7 +148,7 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg)
|
||||
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);
|
||||
@@ -178,7 +178,7 @@ void up_assert(const uint8_t *filename, int lineno)
|
||||
(void)syslog_flush();
|
||||
|
||||
#ifdef CONFIG_BOARD_CRASHDUMP
|
||||
board_crashdump(up_getsp(), this_task(), filename, lineno);
|
||||
board_crashdump(up_getsp(), running_task(), filename, lineno);
|
||||
#endif
|
||||
|
||||
_up_assert(EXIT_FAILURE);
|
||||
|
||||
@@ -135,7 +135,7 @@ static inline void up_registerdump(void)
|
||||
|
||||
void lm32_dumpstate(void)
|
||||
{
|
||||
struct tcb_s *rtcb = this_task();
|
||||
struct tcb_s *rtcb = running_task();
|
||||
uint32_t sp = up_getsp();
|
||||
uint32_t ustackbase;
|
||||
uint32_t ustacksize;
|
||||
|
||||
@@ -232,7 +232,7 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg)
|
||||
#ifdef CONFIG_ARCH_STACKDUMP
|
||||
static void up_dumpstate(void)
|
||||
{
|
||||
struct tcb_s *rtcb = this_task();
|
||||
struct tcb_s *rtcb = running_task();
|
||||
uint32_t sp = up_getsp();
|
||||
uint32_t ustackbase;
|
||||
uint32_t ustacksize;
|
||||
@@ -372,7 +372,7 @@ static void _up_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)
|
||||
{
|
||||
(void)up_irq_save();
|
||||
for (; ; )
|
||||
@@ -408,7 +408,7 @@ static void _up_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);
|
||||
@@ -432,7 +432,7 @@ void up_assert(const uint8_t *filename, int lineno)
|
||||
(void)syslog_flush();
|
||||
|
||||
#ifdef CONFIG_BOARD_CRASHDUMP
|
||||
board_crashdump(up_getsp(), this_task(), filename, lineno);
|
||||
board_crashdump(up_getsp(), running_task(), filename, lineno);
|
||||
#endif
|
||||
|
||||
_up_assert(EXIT_FAILURE);
|
||||
|
||||
@@ -88,7 +88,7 @@ static void _up_assert(int errorcode)
|
||||
|
||||
/* Are we in an interrupt handler or the idle task? */
|
||||
|
||||
if (g_current_regs || this_task()->pid == 0)
|
||||
if (g_current_regs || running_task()->pid == 0)
|
||||
{
|
||||
(void)up_irq_save();
|
||||
for (;;)
|
||||
@@ -149,7 +149,7 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg)
|
||||
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);
|
||||
@@ -179,7 +179,7 @@ void up_assert(const uint8_t *filename, int lineno)
|
||||
(void)syslog_flush();
|
||||
|
||||
#ifdef CONFIG_BOARD_CRASHDUMP
|
||||
board_crashdump(up_getsp(), this_task(), filename, lineno);
|
||||
board_crashdump(up_getsp(), running_task(), filename, lineno);
|
||||
#endif
|
||||
|
||||
_up_assert(EXIT_FAILURE);
|
||||
|
||||
@@ -151,7 +151,7 @@ static inline void m16c_registerdump(void)
|
||||
|
||||
void up_dumpstate(void)
|
||||
{
|
||||
struct tcb_s *rtcb = this_task();
|
||||
struct tcb_s *rtcb = running_task();
|
||||
uint16_t sp = m16c_getsp();
|
||||
uint16_t ustackbase;
|
||||
uint16_t ustacksize;
|
||||
|
||||
@@ -141,7 +141,7 @@ static inline void sh1_registerdump(void)
|
||||
|
||||
void up_dumpstate(void)
|
||||
{
|
||||
struct tcb_s *rtcb = this_task();
|
||||
struct tcb_s *rtcb = running_task();
|
||||
uint32_t sp = sh1_getsp();
|
||||
uint32_t ustackbase;
|
||||
uint32_t ustacksize;
|
||||
|
||||
@@ -87,7 +87,7 @@ static void _up_assert(int errorcode)
|
||||
|
||||
/* Are we in an interrupt handler or the idle task? */
|
||||
|
||||
if (g_current_regs || this_task()->pid == 0)
|
||||
if (g_current_regs || running_task()->pid == 0)
|
||||
{
|
||||
(void)up_irq_save();
|
||||
for (; ; )
|
||||
@@ -148,7 +148,7 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg)
|
||||
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);
|
||||
@@ -178,7 +178,7 @@ void up_assert(const uint8_t *filename, int lineno)
|
||||
(void)syslog_flush();
|
||||
|
||||
#ifdef CONFIG_BOARD_CRASHDUMP
|
||||
board_crashdump(up_getsp(), this_task(), filename, lineno);
|
||||
board_crashdump(up_getsp(), running_task(), filename, lineno);
|
||||
#endif
|
||||
|
||||
_up_assert(EXIT_FAILURE);
|
||||
|
||||
@@ -144,7 +144,7 @@ static inline void up_registerdump(void)
|
||||
|
||||
void up_dumpstate(void)
|
||||
{
|
||||
struct tcb_s *rtcb = this_task();
|
||||
struct tcb_s *rtcb = running_task();
|
||||
uint32_t sp = up_getsp();
|
||||
uint32_t ustackbase;
|
||||
uint32_t ustacksize;
|
||||
|
||||
@@ -135,7 +135,7 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg)
|
||||
#ifdef CONFIG_ARCH_STACKDUMP
|
||||
static void up_dumpstate(void)
|
||||
{
|
||||
struct tcb_s *rtcb = this_task();
|
||||
struct tcb_s *rtcb = running_task();
|
||||
uint32_t sp = up_getsp();
|
||||
uint32_t ustackbase;
|
||||
uint32_t ustacksize;
|
||||
@@ -255,7 +255,7 @@ static void _up_assert(int errorcode)
|
||||
|
||||
/* Are we in an interrupt handler or the idle task? */
|
||||
|
||||
if (g_current_regs || (this_task())->pid == 0)
|
||||
if (g_current_regs || (running_task())->pid == 0)
|
||||
{
|
||||
(void)up_irq_save();
|
||||
for (;;)
|
||||
@@ -291,7 +291,7 @@ static void _up_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);
|
||||
@@ -315,7 +315,7 @@ void up_assert(const uint8_t *filename, int lineno)
|
||||
(void)syslog_flush();
|
||||
|
||||
#ifdef CONFIG_BOARD_CRASHDUMP
|
||||
board_crashdump(up_getsp(), this_task(), filename, lineno);
|
||||
board_crashdump(up_getsp(), running_task(), filename, lineno);
|
||||
#endif
|
||||
|
||||
_up_assert(EXIT_FAILURE);
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -87,7 +87,7 @@ static void _up_assert(int errorcode) /* noreturn_function */
|
||||
|
||||
/* Are we in an interrupt handler or the idle task? */
|
||||
|
||||
if (up_interrupt_context() || this_task()->pid == 0)
|
||||
if (up_interrupt_context() || running_task()->pid == 0)
|
||||
{
|
||||
(void)up_irq_save();
|
||||
for (;;)
|
||||
@@ -152,7 +152,7 @@ void up_assert(void)
|
||||
#endif
|
||||
{
|
||||
#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);
|
||||
@@ -191,7 +191,7 @@ void up_assert(void)
|
||||
(void)syslog_flush();
|
||||
|
||||
#ifdef CONFIG_BOARD_CRASHDUMP
|
||||
board_crashdump(up_getsp(), this_task(), filename, lineno);
|
||||
board_crashdump(up_getsp(), running_task(), filename, lineno);
|
||||
#endif
|
||||
|
||||
_up_assert(EXIT_FAILURE);
|
||||
|
||||
@@ -86,7 +86,7 @@ static void _up_assert(int errorcode) /* noreturn_function */
|
||||
|
||||
/* Are we in an interrupt handler or the idle task? */
|
||||
|
||||
if (up_interrupt_context() || this_task()->pid == 0)
|
||||
if (up_interrupt_context() || running_task()->pid == 0)
|
||||
{
|
||||
(void)up_irq_save();
|
||||
for (;;)
|
||||
@@ -151,7 +151,7 @@ void up_assert(void)
|
||||
#endif
|
||||
{
|
||||
#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);
|
||||
@@ -190,7 +190,7 @@ void up_assert(void)
|
||||
(void)syslog_flush();
|
||||
|
||||
#ifdef CONFIG_BOARD_CRASHDUMP
|
||||
board_crashdump(up_getsp(), this_task(), filename, lineno);
|
||||
board_crashdump(up_getsp(), running_task(), filename, lineno);
|
||||
#endif
|
||||
|
||||
_up_assert(EXIT_FAILURE);
|
||||
|
||||
+16
-1
@@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* sched/init/os_start.c
|
||||
*
|
||||
* Copyright (C) 2007-2014, 2016 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007-2014, 2016, 2018 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -140,6 +140,17 @@ volatile dq_queue_t g_readytorun;
|
||||
*/
|
||||
|
||||
volatile dq_queue_t g_assignedtasks[CONFIG_SMP_NCPUS];
|
||||
|
||||
/* g_running_tasks[] holds a references to the running task for each cpu.
|
||||
* It is valid only when up_interrupt_context() returns true.
|
||||
*/
|
||||
|
||||
FAR struct tcb_s *g_running_tasks[CONFIG_SMP_NCPUS];
|
||||
|
||||
#else
|
||||
|
||||
FAR struct tcb_s *g_running_tasks[1];
|
||||
|
||||
#endif
|
||||
|
||||
/* This is the list of all tasks that are ready-to-run, but cannot be placed
|
||||
@@ -546,6 +557,10 @@ void os_start(void)
|
||||
#endif
|
||||
dq_addfirst((FAR dq_entry_t *)&g_idletcb[cpu], tasklist);
|
||||
|
||||
/* Mark the idle task as the running task */
|
||||
|
||||
g_running_tasks[cpu] = &g_idletcb[cpu].cmn;
|
||||
|
||||
/* Initialize the processor-specific portion of the TCB */
|
||||
|
||||
up_initial_state(&g_idletcb[cpu].cmn);
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
|
||||
#include "irq/irq.h"
|
||||
#include "clock/clock.h"
|
||||
#include "sched/sched.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
@@ -159,4 +160,10 @@ void irq_dispatch(int irq, FAR void *context)
|
||||
|
||||
CALL_VECTOR(ndx, vector, irq, context, arg);
|
||||
UNUSED(ndx);
|
||||
|
||||
/* Record the new "running" task. g_running_tasks[] is only used by
|
||||
* assertion logic for reporting crashes.
|
||||
*/
|
||||
|
||||
g_running_tasks[this_cpu()] = this_task();
|
||||
}
|
||||
|
||||
@@ -89,6 +89,13 @@
|
||||
# define this_task() (current_task(this_cpu()))
|
||||
#endif
|
||||
|
||||
/* This macro returns the running task which may different from this_task()
|
||||
* during interrupt level context switches.
|
||||
*/
|
||||
|
||||
#define running_task() \
|
||||
(up_interrupt_context() ? g_running_tasks[this_cpu()] : this_task())
|
||||
|
||||
/* List attribute flags */
|
||||
|
||||
#define TLIST_ATTR_PRIORITIZED (1 << 0) /* Bit 0: List is prioritized */
|
||||
@@ -201,6 +208,17 @@ extern volatile dq_queue_t g_readytorun;
|
||||
*/
|
||||
|
||||
extern volatile dq_queue_t g_assignedtasks[CONFIG_SMP_NCPUS];
|
||||
|
||||
/* g_running_tasks[] holds a references to the running task for each cpu.
|
||||
* It is valid only when up_interrupt_context() returns true.
|
||||
*/
|
||||
|
||||
extern FAR struct tcb_s *g_running_tasks[CONFIG_SMP_NCPUS];
|
||||
|
||||
#else
|
||||
|
||||
extern FAR struct tcb_s *g_running_tasks[1];
|
||||
|
||||
#endif
|
||||
|
||||
/* This is the list of all tasks that are ready-to-run, but cannot be placed
|
||||
|
||||
Reference in New Issue
Block a user