sched/assert: Don't call running_task more than once
and fix some minor style issue Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
6992a8f4cc
commit
5f99e482b5
1 changed files with 24 additions and 29 deletions
|
|
@ -27,15 +27,16 @@
|
|||
#include <nuttx/arch.h>
|
||||
#include <nuttx/board.h>
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/panic_notifier.h>
|
||||
#include <nuttx/usb/usbdev_trace.h>
|
||||
#include <nuttx/syslog/syslog.h>
|
||||
#include <nuttx/tls.h>
|
||||
|
||||
#include <nuttx/panic_notifier.h>
|
||||
#include <nuttx/syslog/syslog.h>
|
||||
#include <nuttx/usb/usbdev_trace.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "irq/irq.h"
|
||||
#include "sched/sched.h"
|
||||
|
|
@ -97,10 +98,10 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg)
|
|||
#ifdef CONFIG_ARCH_STACKDUMP
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stackdump
|
||||
* Name: stack_dump
|
||||
****************************************************************************/
|
||||
|
||||
static void stackdump(uintptr_t sp, uintptr_t stack_top)
|
||||
static void stack_dump(uintptr_t sp, uintptr_t stack_top)
|
||||
{
|
||||
uintptr_t stack;
|
||||
|
||||
|
|
@ -132,7 +133,7 @@ static void dump_stack(FAR const char *tag, uintptr_t sp,
|
|||
|
||||
if (sp >= base && sp < top)
|
||||
{
|
||||
stackdump(sp, top);
|
||||
stack_dump(sp, top);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -143,8 +144,8 @@ static void dump_stack(FAR const char *tag, uintptr_t sp,
|
|||
#ifdef CONFIG_STACK_COLORATION
|
||||
size_t remain = size - used;
|
||||
|
||||
base += remain;
|
||||
size -= remain;
|
||||
base += remain;
|
||||
size -= remain;
|
||||
#endif
|
||||
|
||||
#if CONFIG_ARCH_STACKDUMP_MAX_LENGTH > 0
|
||||
|
|
@ -154,7 +155,7 @@ static void dump_stack(FAR const char *tag, uintptr_t sp,
|
|||
}
|
||||
#endif
|
||||
|
||||
stackdump(base, base + size);
|
||||
stack_dump(base, base + size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -163,9 +164,8 @@ static void dump_stack(FAR const char *tag, uintptr_t sp,
|
|||
* Name: showstacks
|
||||
****************************************************************************/
|
||||
|
||||
static void showstacks(void)
|
||||
static void show_stacks(FAR struct tcb_s *rtcb)
|
||||
{
|
||||
FAR struct tcb_s *rtcb = running_task();
|
||||
uintptr_t sp = up_getsp();
|
||||
|
||||
/* Get the limits on the interrupt stack memory */
|
||||
|
|
@ -369,8 +369,6 @@ static void dump_task(FAR struct tcb_s *tcb, FAR void *arg)
|
|||
#ifdef CONFIG_SCHED_BACKTRACE
|
||||
static void dump_backtrace(FAR struct tcb_s *tcb, FAR void *arg)
|
||||
{
|
||||
/* Show back trace */
|
||||
|
||||
sched_dumpstack(tcb->pid);
|
||||
}
|
||||
#endif
|
||||
|
|
@ -379,10 +377,9 @@ static void dump_backtrace(FAR struct tcb_s *tcb, FAR void *arg)
|
|||
* Name: showtasks
|
||||
****************************************************************************/
|
||||
|
||||
static void showtasks(void)
|
||||
static void show_tasks(void)
|
||||
{
|
||||
#if CONFIG_ARCH_INTERRUPTSTACK > 0
|
||||
# ifdef CONFIG_STACK_COLORATION
|
||||
#if CONFIG_ARCH_INTERRUPTSTACK > 0 && defined(CONFIG_STACK_COLORATION)
|
||||
size_t stack_used = up_check_intstack();
|
||||
size_t stack_filled = 0;
|
||||
|
||||
|
|
@ -393,7 +390,6 @@ static void showtasks(void)
|
|||
stack_filled = 10 * 100 *
|
||||
stack_used / CONFIG_ARCH_INTERRUPTSTACK;
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Dump interesting properties of each task in the crash environment */
|
||||
|
|
@ -444,7 +440,7 @@ static void showtasks(void)
|
|||
* Name: assert_end
|
||||
****************************************************************************/
|
||||
|
||||
static void assert_end(void)
|
||||
static void assert_end(FAR struct tcb_s *rtcb)
|
||||
{
|
||||
/* Flush any buffered SYSLOG data */
|
||||
|
||||
|
|
@ -452,7 +448,7 @@ static void assert_end(void)
|
|||
|
||||
/* Are we in an interrupt handler or the idle task? */
|
||||
|
||||
if (up_interrupt_context() || running_task()->flink == NULL)
|
||||
if (up_interrupt_context() || rtcb->flink == NULL)
|
||||
{
|
||||
#if CONFIG_BOARD_RESET_ON_ASSERT >= 1
|
||||
board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE);
|
||||
|
|
@ -507,19 +503,18 @@ void _assert(FAR const char *filename, int linenum)
|
|||
#ifdef CONFIG_SMP
|
||||
# if CONFIG_TASK_NAME_SIZE > 0
|
||||
_alert("Assertion failed CPU%d at file: %s:%d task: %s %p\n",
|
||||
up_cpu_index(), filename, linenum, rtcb->name,
|
||||
rtcb->entry.main);
|
||||
up_cpu_index(), filename, linenum, rtcb->name, rtcb->entry.main);
|
||||
# else
|
||||
_alert("Assertion failed CPU%d at file: %s:%d\n",
|
||||
up_cpu_index(), filename, linenum);
|
||||
_alert("Assertion failed CPU%d at file: %s:%d task: %p\n",
|
||||
up_cpu_index(), filename, linenum, rtcb->entry.main);
|
||||
# endif
|
||||
#else
|
||||
# if CONFIG_TASK_NAME_SIZE > 0
|
||||
_alert("Assertion failed at file: %s:%d task: %s %p\n",
|
||||
filename, linenum, rtcb->name, rtcb->entry.main);
|
||||
# else
|
||||
_alert("Assertion failed at file: %s:%d\n",
|
||||
filename, linenum);
|
||||
_alert("Assertion failed at file: %s:%d task: %p\n",
|
||||
filename, linenum, rtcb->entry.main);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
|
@ -546,10 +541,10 @@ void _assert(FAR const char *filename, int linenum)
|
|||
}
|
||||
|
||||
#ifdef CONFIG_ARCH_STACKDUMP
|
||||
showstacks();
|
||||
show_stacks(rtcb);
|
||||
#endif
|
||||
|
||||
showtasks();
|
||||
show_tasks();
|
||||
|
||||
#ifdef CONFIG_ARCH_USBDUMP
|
||||
/* Dump USB trace data */
|
||||
|
|
@ -561,5 +556,5 @@ void _assert(FAR const char *filename, int linenum)
|
|||
board_crashdump(up_getsp(), rtcb, filename, linenum);
|
||||
#endif
|
||||
|
||||
assert_end();
|
||||
assert_end(rtcb);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue