task: use get_task_name where possible

Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
This commit is contained in:
xuxingliang
2024-08-28 16:28:46 +08:00
committed by Xiang Xiao
parent 01bba4542a
commit 7044b10c88
24 changed files with 118 additions and 287 deletions
+11 -13
View File
@@ -100,19 +100,17 @@ typedef enum
typedef struct typedef struct
{ {
struct timespec ts; /* timestamp */ struct timespec ts; /* timestamp */
fault_flags_t flags; /* What is in the dump */ fault_flags_t flags; /* What is in the dump */
uintptr_t current_regs; /* Used to validate the dump */ uintptr_t current_regs; /* Used to validate the dump */
int lineno; /* __LINE__ to up_assert */ int lineno; /* __LINE__ to up_assert */
pid_t pid; /* Process ID */ pid_t pid; /* Process ID */
uint32_t regs[XCPTCONTEXT_REGS]; /* Interrupt register save area */ uint32_t regs[XCPTCONTEXT_REGS]; /* Interrupt register save area */
crash_stack_t stacks; /* Stack info */ crash_stack_t stacks; /* Stack info */
#if CONFIG_TASK_NAME_SIZE > 0 char name[CONFIG_TASK_NAME_SIZE + 1]; /* Task name (with NULL
char name[CONFIG_TASK_NAME_SIZE + 1]; /* Task name (with NULL * terminator) */
* terminator) */ char filename[MAX_FILE_PATH_LENGTH]; /* the Last of chars in
#endif * __FILE__ to up_assert */
char filename[MAX_FILE_PATH_LENGTH]; /* the Last of chars in
* __FILE__ to up_assert */
} info_t; } info_t;
typedef struct typedef struct
+3 -10
View File
@@ -99,28 +99,21 @@ __cyg_profile_func_enter(void *this_fn, void *call_site)
if (sp < stack_base) if (sp < stack_base)
{ {
#if CONFIG_TASK_NAME_SIZE > 0
struct tcb_s *rtcb; struct tcb_s *rtcb;
#endif
__asm volatile("csrc mstatus, 8"); __asm volatile("csrc mstatus, 8");
__asm__("li s11, 0"); __asm__("li s11, 0");
#if CONFIG_TASK_NAME_SIZE > 0
/* get current task */ /* get current task */
rtcb = running_task(); rtcb = running_task();
syslog(LOG_EMERG, syslog(LOG_EMERG,
"task %s stack overflow detected! base:0x%x >= sp:0x%x\n", "task %s stack overflow detected! base:0x%x >= sp:0x%x\n",
rtcb->name, get_task_name(rtcb),
stack_base, stack_base,
sp); sp);
#else
syslog(LOG_EMERG,
"stack overflow detected! base:0x%x >= sp:0x%x\n",
stack_base,
sp);
#endif
/* PANIC(); */ /* PANIC(); */
while (1) while (1)
+2 -5
View File
@@ -103,11 +103,8 @@ int riscv_exception(int mcause, void *regs, void *args)
#ifdef CONFIG_ARCH_KERNEL_STACK #ifdef CONFIG_ARCH_KERNEL_STACK
if ((tcb->flags & TCB_FLAG_TTYPE_MASK) != TCB_FLAG_TTYPE_KERNEL) if ((tcb->flags & TCB_FLAG_TTYPE_MASK) != TCB_FLAG_TTYPE_KERNEL)
{ {
# if CONFIG_TASK_NAME_SIZE > 0 _alert("Segmentation fault in PID %d: %s\n",
_alert("Segmentation fault in PID %d: %s\n", tcb->pid, tcb->name); tcb->pid, get_task_name(tcb));
# else
_alert("Segmentation fault in PID %d\n", tcb->pid);
# endif
tcb->flags |= TCB_FLAG_FORCED_CANCEL; tcb->flags |= TCB_FLAG_FORCED_CANCEL;
+3 -10
View File
@@ -75,11 +75,8 @@ void xtensa_panic(int xptcode, uint32_t *regs)
syslog_flush(); syslog_flush();
#if CONFIG_TASK_NAME_SIZE > 0 _alert("Unhandled Exception %d task: %s\n", xptcode,
_alert("Unhandled Exception %d task: %s\n", xptcode, running_task()->name); get_task_name(running_task()));
#else
_alert("Unhandled Exception %d\n", xptcode);
#endif
PANIC_WITH_REGS("panic", regs); /* Should not return */ PANIC_WITH_REGS("panic", regs); /* Should not return */
for (; ; ); for (; ; );
@@ -177,12 +174,8 @@ void xtensa_user_panic(int exccause, uint32_t *regs)
syslog_flush(); syslog_flush();
#if CONFIG_TASK_NAME_SIZE > 0
_alert("User Exception: EXCCAUSE=%04x task: %s\n", _alert("User Exception: EXCCAUSE=%04x task: %s\n",
exccause, running_task()->name); exccause, get_task_name(running_task()));
#else
_alert("User Exception: EXCCAUSE=%04x\n", exccause);
#endif
PANIC_WITH_REGS("user panic", regs); /* Should not return */ PANIC_WITH_REGS("user panic", regs); /* Should not return */
for (; ; ); for (; ; );
+2 -2
View File
@@ -248,11 +248,11 @@ static void elf_emit_tcb_note(FAR struct elf_dumpinfo_s *cinfo,
elf_emit(cinfo, &nhdr, sizeof(nhdr)); elf_emit(cinfo, &nhdr, sizeof(nhdr));
strlcpy(name, tcb->name, sizeof(name)); strlcpy(name, get_task_name(tcb), sizeof(name));
elf_emit(cinfo, name, sizeof(name)); elf_emit(cinfo, name, sizeof(name));
info.pr_pid = tcb->pid; info.pr_pid = tcb->pid;
strlcpy(info.pr_fname, tcb->name, sizeof(info.pr_fname)); strlcpy(info.pr_fname, get_task_name(tcb), sizeof(info.pr_fname));
elf_emit(cinfo, &info, sizeof(info)); elf_emit(cinfo, &info, sizeof(info));
/* Fill Process status */ /* Fill Process status */
@@ -149,9 +149,7 @@ void board_crashdump(uintptr_t sp, struct tcb_s *tcb,
/* Save Context */ /* Save Context */
#if CONFIG_TASK_NAME_SIZE > 0 strlcpy(pdump->info.name, get_task_name(tcb), sizeof(pdump->info.name));
strlcpy(pdump->info.name, tcb->name, sizeof(pdump->info.name));
#endif
pdump->info.pid = tcb->pid; pdump->info.pid = tcb->pid;
@@ -232,18 +232,16 @@ typedef enum
typedef struct typedef struct
{ {
fault_flags_t flags; /* What is in the dump */ fault_flags_t flags; /* What is in the dump */
uintptr_t current_regs; /* Used to validate the dump */ uintptr_t current_regs; /* Used to validate the dump */
int lineno; /* __LINE__ to up_assert */ int lineno; /* __LINE__ to up_assert */
pid_t pid; /* Process ID */ pid_t pid; /* Process ID */
uint32_t regs[XCPTCONTEXT_REGS]; /* Interrupt register save area */ uint32_t regs[XCPTCONTEXT_REGS]; /* Interrupt register save area */
stacks_t stacks; /* Stack info */ stack_t stacks; /* Stack info */
#if CONFIG_TASK_NAME_SIZE > 0 char name[CONFIG_TASK_NAME_SIZE + 1]; /* Task name (with NULL
char name[CONFIG_TASK_NAME_SIZE + 1]; /* Task name (with NULL * terminator) */
* terminator) */ char filename[MAX_FILE_PATH_LENGTH]; /* the Last of chars in
#endif * __FILE__ to up_assert */
char filename[MAX_FILE_PATH_LENGTH]; /* the Last of chars in
* __FILE__ to up_assert */
} info_t; } info_t;
typedef struct typedef struct
@@ -420,9 +418,7 @@ void board_crashdump(uintptr_t sp, struct tcb_s *tcb,
/* Save Context */ /* Save Context */
#if CONFIG_TASK_NAME_SIZE > 0 strlcpy(pdump->info.name, get_task_name(tcb), sizeof(pdump->info.name));
strlcpy(pdump->info.name, tcb->name, sizeof(pdump->info.name));
#endif
pdump->info.pid = tcb->pid; pdump->info.pid = tcb->pid;
@@ -232,18 +232,16 @@ typedef enum
typedef struct typedef struct
{ {
fault_flags_t flags; /* What is in the dump */ fault_flags_t flags; /* What is in the dump */
uintptr_t current_regs; /* Used to validate the dump */ uintptr_t current_regs; /* Used to validate the dump */
int lineno; /* __LINE__ to up_assert */ int lineno; /* __LINE__ to up_assert */
int pid; /* Process ID */ int pid; /* Process ID */
uint32_t regs[XCPTCONTEXT_REGS]; /* Interrupt register save area */ uint32_t regs[XCPTCONTEXT_REGS]; /* Interrupt register save area */
stacks_t stacks; /* Stack info */ stack_t stacks; /* Stack info */
#if CONFIG_TASK_NAME_SIZE > 0 char name[CONFIG_TASK_NAME_SIZE + 1]; /* Task name (with NULL
char name[CONFIG_TASK_NAME_SIZE + 1]; /* Task name (with NULL * terminator) */
* terminator) */ char filename[MAX_FILE_PATH_LENGTH]; /* the Last of chars in
#endif * __FILE__ to up_assert */
char filename[MAX_FILE_PATH_LENGTH]; /* the Last of chars in
* __FILE__ to up_assert */
} info_t; } info_t;
typedef struct typedef struct
@@ -420,9 +418,7 @@ void board_crashdump(uintptr_t sp, struct tcb_s *tcb,
/* Save Context */ /* Save Context */
#if CONFIG_TASK_NAME_SIZE > 0 strlcpy(pdump->info.name, get_task_name(tcb), sizeof(pdump->info.name));
strlcpy(pdump->info.name, tcb->name, sizeof(pdump->info.name));
#endif
pdump->info.pid = tcb->pid; pdump->info.pid = tcb->pid;
@@ -181,18 +181,16 @@ typedef enum
typedef struct typedef struct
{ {
fault_flags_t flags; /* What is in the dump */ fault_flags_t flags; /* What is in the dump */
uintptr_t current_regs; /* Used to validate the dump */ uintptr_t current_regs; /* Used to validate the dump */
int lineno; /* __LINE__ to up_assert */ int lineno; /* __LINE__ to up_assert */
pid_t pid; /* Process ID */ pid_t pid; /* Process ID */
uint32_t regs[XCPTCONTEXT_REGS]; /* Interrupt register save area */ uint32_t regs[XCPTCONTEXT_REGS]; /* Interrupt register save area */
stack_t stacks; /* Stack info */ stack_t stacks; /* Stack info */
#if CONFIG_TASK_NAME_SIZE > 0 char name[CONFIG_TASK_NAME_SIZE + 1]; /* Task name (with NULL
char name[CONFIG_TASK_NAME_SIZE + 1]; /* Task name (with NULL * terminator) */
* terminator) */ char filename[MAX_FILE_PATH_LENGTH]; /* the Last of chars in
#endif * __FILE__ to up_assert */
char filename[MAX_FILE_PATH_LENGTH]; /* the Last of chars in
* __FILE__ to up_assert */
} info_t; } info_t;
struct fullcontext struct fullcontext
@@ -374,9 +372,7 @@ void board_crashdump(uintptr_t sp, struct tcb_s *tcb,
/* Save Context */ /* Save Context */
#if CONFIG_TASK_NAME_SIZE > 0 strlcpy(pdump->info.name, get_task_name(tcb), sizeof(pdump->info.name));
strlcpy(pdump->info.name, tcb->name, sizeof(pdump->info.name));
#endif
pdump->info.pid = tcb->pid; pdump->info.pid = tcb->pid;
@@ -181,18 +181,16 @@ typedef enum
typedef struct typedef struct
{ {
fault_flags_t flags; /* What is in the dump */ fault_flags_t flags; /* What is in the dump */
uintptr_t current_regs; /* Used to validate the dump */ uintptr_t current_regs; /* Used to validate the dump */
int lineno; /* __LINE__ to up_assert */ int lineno; /* __LINE__ to up_assert */
pid_t pid; /* Process ID */ pid_t pid; /* Process ID */
uint32_t regs[XCPTCONTEXT_REGS]; /* Interrupt register save area */ uint32_t regs[XCPTCONTEXT_REGS]; /* Interrupt register save area */
stack_t stacks; /* Stack info */ stack_t stacks; /* Stack info */
#if CONFIG_TASK_NAME_SIZE > 0 char name[CONFIG_TASK_NAME_SIZE + 1]; /* Task name (with NULL
char name[CONFIG_TASK_NAME_SIZE + 1]; /* Task name (with NULL * terminator) */
* terminator) */ char filename[MAX_FILE_PATH_LENGTH]; /* the Last of chars in
#endif * __FILE__ to up_assert */
char filename[MAX_FILE_PATH_LENGTH]; /* the Last of chars in
* __FILE__ to up_assert */
} info_t; } info_t;
struct fullcontext struct fullcontext
@@ -372,9 +370,7 @@ void board_crashdump(uintptr_t sp, struct tcb_s *tcb,
/* Save Context */ /* Save Context */
#if CONFIG_TASK_NAME_SIZE > 0 strlcpy(pdump->info.name, get_task_name(tcb), sizeof(pdump->info.name));
strlcpy(pdump->info.name, tcb->name, sizeof(pdump->info.name));
#endif
pdump->info.pid = tcb->pid; pdump->info.pid = tcb->pid;
-1
View File
@@ -2007,4 +2007,3 @@ int note_driver_register(FAR struct note_driver_s *driver)
return -ENOMEM; return -ENOMEM;
} }
+20 -120
View File
@@ -149,21 +149,11 @@ static void notelog_start(FAR struct note_driver_s *drv,
FAR struct tcb_s *tcb) FAR struct tcb_s *tcb)
{ {
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
#if CONFIG_TASK_NAME_SIZE > 0
syslog(LOG_INFO, "CPU%d: Start %s, TCB@%p, state=%d\n", syslog(LOG_INFO, "CPU%d: Start %s, TCB@%p, state=%d\n",
tcb->cpu, tcb->name, tcb, tcb->task_state); tcb->cpu, get_task_name(tcb), tcb, tcb->task_state);
#else #else
syslog(LOG_INFO, "CPU%d: Start TCB@%p, state=%d\n"
tcb->cpu, tcb, tcb->task_state);
#endif
#else
#if CONFIG_TASK_NAME_SIZE > 0
syslog(LOG_INFO, "Start %s, TCB@%p, state=%d\n", syslog(LOG_INFO, "Start %s, TCB@%p, state=%d\n",
tcb->name, tcb, tcb->task_state); get_task_name(tcb), tcb, tcb->task_state);
#else
syslog(LOG_INFO, "Start TCB@%p, state=%d\n",
tcb, tcb->task_state);
#endif
#endif #endif
} }
@@ -171,21 +161,11 @@ static void notelog_stop(FAR struct note_driver_s *drv,
FAR struct tcb_s *tcb) FAR struct tcb_s *tcb)
{ {
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
#if CONFIG_TASK_NAME_SIZE > 0
syslog(LOG_INFO, "CPU%d: Stop %s, TCB@%p, state=%d\n", syslog(LOG_INFO, "CPU%d: Stop %s, TCB@%p, state=%d\n",
tcb->cpu, tcb->name, tcb, tcb->task_state); tcb->cpu, get_task_name(tcb), tcb, tcb->task_state);
#else #else
syslog(LOG_INFO, "CPU%d: Stop TCB@%p, state=%d\n",
tcb->cpu, tcb, tcb->task_state);
#endif
#else
#if CONFIG_TASK_NAME_SIZE > 0
syslog(LOG_INFO, "Stop %s, TCB@%p, state=%d\n", syslog(LOG_INFO, "Stop %s, TCB@%p, state=%d\n",
tcb->name, tcb, tcb->task_state); get_task_name(tcb), tcb, tcb->task_state);
#else
syslog(LOG_INFO, "Stop TCB@%p, state=%d\n",
tcb, tcb->task_state);
#endif
#endif #endif
} }
@@ -194,21 +174,11 @@ static void notelog_suspend(FAR struct note_driver_s *drv,
FAR struct tcb_s *tcb) FAR struct tcb_s *tcb)
{ {
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
#if CONFIG_TASK_NAME_SIZE > 0
syslog(LOG_INFO, "CPU%d: Suspend %s, TCB@%p, state=%d\n", syslog(LOG_INFO, "CPU%d: Suspend %s, TCB@%p, state=%d\n",
tcb->cpu, tcb->name, tcb, tcb->task_state); tcb->cpu, get_task_name(tcb), tcb, tcb->task_state);
#else #else
syslog(LOG_INFO, "CPU%d: Suspend TCB@%p, state=%d\n",
tcb->cpu, tcb, tcb->task_state);
#endif
#else
#if CONFIG_TASK_NAME_SIZE > 0
syslog(LOG_INFO, "Suspend %s, TCB@%p, state=%d\n", syslog(LOG_INFO, "Suspend %s, TCB@%p, state=%d\n",
tcb->name, tcb, tcb->task_state); get_task_name(tcb), tcb, tcb->task_state);
#else
syslog(LOG_INFO, "Suspend TCB@%p, state=%d\n",
tcb, tcb->task_state);
#endif
#endif #endif
} }
@@ -216,21 +186,11 @@ static void notelog_resume(FAR struct note_driver_s *drv,
FAR struct tcb_s *tcb) FAR struct tcb_s *tcb)
{ {
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
#if CONFIG_TASK_NAME_SIZE > 0
syslog(LOG_INFO, "CPU%d: Resume %s, TCB@%p, state=%d\n", syslog(LOG_INFO, "CPU%d: Resume %s, TCB@%p, state=%d\n",
tcb->cpu, tcb->name, tcb, tcb->task_state); tcb->cpu, get_task_name(tcb), tcb, tcb->task_state);
#else #else
syslog(LOG_INFO, "CPU%d: Resume TCB@%p, state=%d\n",
tcb->cpu, tcb, tcb->task_state);
#endif
#else
#if CONFIG_TASK_NAME_SIZE > 0
syslog(LOG_INFO, "Resume %s, TCB@%p, state=%d\n", syslog(LOG_INFO, "Resume %s, TCB@%p, state=%d\n",
tcb->name, tcb, tcb->task_state); get_task_name(tcb), tcb, tcb->task_state);
#else
syslog(LOG_INFO, "Resume TCB@%p, state=%d\n",
tcb, tcb->task_state);
#endif
#endif #endif
} }
#endif #endif
@@ -239,74 +199,44 @@ static void notelog_resume(FAR struct note_driver_s *drv,
static void notelog_cpu_start(FAR struct note_driver_s *drv, static void notelog_cpu_start(FAR struct note_driver_s *drv,
FAR struct tcb_s *tcb, int cpu) FAR struct tcb_s *tcb, int cpu)
{ {
#if CONFIG_TASK_NAME_SIZE > 0
syslog(LOG_INFO, "CPU%d: Task %s TCB@%p CPU%d START\n", syslog(LOG_INFO, "CPU%d: Task %s TCB@%p CPU%d START\n",
tcb->cpu, tcb->name, tcb, cpu); tcb->cpu, get_task_name(tcb), tcb, cpu);
#else
syslog(LOG_INFO, "CPU%d: TCB@%p CPU%d START\n",
tcb->cpu, tcb, cpu);
#endif
} }
static void notelog_cpu_started(FAR struct note_driver_s *drv, static void notelog_cpu_started(FAR struct note_driver_s *drv,
FAR struct tcb_s *tcb) FAR struct tcb_s *tcb)
{ {
#if CONFIG_TASK_NAME_SIZE > 0
syslog(LOG_INFO, "CPU%d: Task %s TCB@%p CPU%d STARTED\n", syslog(LOG_INFO, "CPU%d: Task %s TCB@%p CPU%d STARTED\n",
tcb->cpu, tcb->name, tcb, tcb->cpu); tcb->cpu, get_task_name(tcb), tcb, tcb->cpu);
#else
syslog(LOG_INFO, "CPU%d: TCB@%p CPU%d STARTED\n",
tcb->cpu, tcb, tcb->cpu);
#endif
} }
#ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH #ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH
static void notelog_cpu_pause(FAR struct note_driver_s *drv, static void notelog_cpu_pause(FAR struct note_driver_s *drv,
FAR struct tcb_s *tcb, int cpu) FAR struct tcb_s *tcb, int cpu)
{ {
#if CONFIG_TASK_NAME_SIZE > 0
syslog(LOG_INFO, "CPU%d: Task %s TCB@%p CPU%d PAUSE\n", syslog(LOG_INFO, "CPU%d: Task %s TCB@%p CPU%d PAUSE\n",
tcb->cpu, tcb->name, tcb, cpu); tcb->cpu, get_task_name(tcb), tcb, cpu);
#else
syslog(LOG_INFO, "CPU%d: TCB@%p CPU%d PAUSE\n",
tcb->cpu, tcb, cpu);
#endif
} }
static void notelog_cpu_paused(FAR struct note_driver_s *drv, static void notelog_cpu_paused(FAR struct note_driver_s *drv,
FAR struct tcb_s *tcb) FAR struct tcb_s *tcb)
{ {
#if CONFIG_TASK_NAME_SIZE > 0
syslog(LOG_INFO, "CPU%d: Task %s TCB@%p CPU%d PAUSED\n", syslog(LOG_INFO, "CPU%d: Task %s TCB@%p CPU%d PAUSED\n",
tcb->cpu, tcb->name, tcb, tcb->cpu); tcb->cpu, get_task_name(tcb), tcb, tcb->cpu);
#else
syslog(LOG_INFO, "CPU%d: TCB@%p CPU%d PAUSED\n",
tcb->cpu, tcb, tcb->cpu);
#endif
} }
static void notelog_cpu_resume(FAR struct note_driver_s *drv, static void notelog_cpu_resume(FAR struct note_driver_s *drv,
FAR struct tcb_s *tcb, int cpu) FAR struct tcb_s *tcb, int cpu)
{ {
#if CONFIG_TASK_NAME_SIZE > 0
syslog(LOG_INFO, "CPU%d: Task %s TCB@%p CPU%d RESUME\n", syslog(LOG_INFO, "CPU%d: Task %s TCB@%p CPU%d RESUME\n",
tcb->cpu, tcb->name, tcb, cpu); tcb->cpu, get_task_name(tcb), tcb, cpu);
#else
syslog(LOG_INFO, "CPU%d: TCB@%p CPU%d RESUME\n",
tcb->cpu, tcb, cpu);
#endif
} }
static void notelog_cpu_resumed(FAR struct note_driver_s *drv, static void notelog_cpu_resumed(FAR struct note_driver_s *drv,
FAR struct tcb_s *tcb) FAR struct tcb_s *tcb)
{ {
#if CONFIG_TASK_NAME_SIZE > 0
syslog(LOG_INFO, "CPU%d: Task %s TCB@%p CPU%d RESUMED\n", syslog(LOG_INFO, "CPU%d: Task %s TCB@%p CPU%d RESUMED\n",
tcb->cpu, tcb->name, tcb, tcb->cpu); tcb->cpu, get_task_name(tcb), tcb, tcb->cpu);
#else
syslog(LOG_INFO, "CPU%d: TCB@%p CPU%d RESUMED\n",
tcb->cpu, tcb, tcb->cpu);
#endif
} }
#endif #endif
#endif #endif
@@ -316,21 +246,11 @@ static void notelog_premption(FAR struct note_driver_s *drv,
FAR struct tcb_s *tcb, bool locked) FAR struct tcb_s *tcb, bool locked)
{ {
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
#if CONFIG_TASK_NAME_SIZE > 0
syslog(LOG_INFO, "CPU%d: Task %s TCB@%p preemption %s\n", syslog(LOG_INFO, "CPU%d: Task %s TCB@%p preemption %s\n",
tcb->cpu, tcb->name, tcb, locked ? "LOCKED" : "UNLOCKED"); tcb->cpu, get_task_name(tcb), tcb, locked ? "LOCKED" : "UNLOCKED");
#else #else
syslog(LOG_INFO, "CPU%d: TCB@%p preemption %s\n",
tcb->cpu, tcb, locked ? "LOCKED" : "UNLOCKED");
#endif
#else
#if CONFIG_TASK_NAME_SIZE > 0
syslog(LOG_INFO, "Task %s, TCB@%p preemption %s\n", syslog(LOG_INFO, "Task %s, TCB@%p preemption %s\n",
tcb->name, tcb, locked ? "LOCKED" : "UNLOCKED"); get_task_name(tcb), tcb, locked ? "LOCKED" : "UNLOCKED");
#else
syslog(LOG_INFO, "TCB@%p preemption %s\n",
tcb, locked ? "LOCKED" : "UNLOCKED");
#endif
#endif #endif
} }
#endif #endif
@@ -340,21 +260,11 @@ static void notelog_csection(FAR struct note_driver_s *drv,
FAR struct tcb_s *tcb, bool enter) FAR struct tcb_s *tcb, bool enter)
{ {
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
#if CONFIG_TASK_NAME_SIZE > 0
syslog(LOG_INFO, "CPU%d: Task %s TCB@%p critical section %s\n", syslog(LOG_INFO, "CPU%d: Task %s TCB@%p critical section %s\n",
tcb->cpu, tcb->name, tcb, enter ? "ENTER" : "LEAVE"); tcb->cpu, get_task_name(tcb), tcb, enter ? "ENTER" : "LEAVE");
#else #else
syslog(LOG_INFO, "CPU%d: TCB@%p critical section %s\n",
tcb->cpu, tcb, enter ? "ENTER" : "LEAVE");
#endif
#else
#if CONFIG_TASK_NAME_SIZE > 0
syslog(LOG_INFO, "Task %s, TCB@%p critical section %s\n", syslog(LOG_INFO, "Task %s, TCB@%p critical section %s\n",
tcb->name, tcb, enter ? "ENTER" : "LEAVE"); get_task_name(tcb), tcb, enter ? "ENTER" : "LEAVE");
#else
syslog(LOG_INFO, "TCB@%p critical section %s\n",
tcb, enter ? "ENTER" : "LEAVE");
#endif
#endif #endif
} }
#endif #endif
@@ -376,21 +286,11 @@ static void note_spinlock(FAR struct note_driver_s *drv,
FAR const char * msg = tmp[type - NOTE_SPINLOCK_LOCK]; FAR const char * msg = tmp[type - NOTE_SPINLOCK_LOCK];
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
#if CONFIG_TASK_NAME_SIZE > 0
syslog(LOG_INFO, "CPU%d: Task %s TCB@%p spinlock@%p %s\n", syslog(LOG_INFO, "CPU%d: Task %s TCB@%p spinlock@%p %s\n",
tcb->cpu, tcb->name, tcb, spinlock, msg); tcb->cpu, get_task_name(tcb), tcb, spinlock, msg);
#else #else
syslog(LOG_INFO, "CPU%d: TCB@%p spinlock@%p %s\n",
tcb->cpu, tcb, spinlock, msg);
#endif
#else
#if CONFIG_TASK_NAME_SIZE > 0
syslog(LOG_INFO, "Task %s TCB@%p spinlock@%p %s\n", syslog(LOG_INFO, "Task %s TCB@%p spinlock@%p %s\n",
tcb->name, tcb, spinlock, msg); get_task_name(tcb), tcb, spinlock, msg);
#else
syslog(LOG_INFO, "TCB@%p spinlock@%p %s\n",
tcb, spinlock, msg);
#endif
#endif #endif
} }
#endif #endif
+6 -6
View File
@@ -624,7 +624,7 @@ static void noteram_dump_init_context(FAR struct noteram_dump_context_s *ctx)
* Name: get_task_name * Name: get_task_name
****************************************************************************/ ****************************************************************************/
static FAR const char *get_task_name(pid_t pid) static const char *get_taskname(pid_t pid)
{ {
FAR const char *taskname; FAR const char *taskname;
@@ -658,7 +658,7 @@ static int noteram_dump_header(FAR struct lib_outstream_s *s,
#endif #endif
ret = lib_sprintf(s, "%8s-%-3u [%d] %3" PRIu32 ".%09" PRIu32 ": ", ret = lib_sprintf(s, "%8s-%-3u [%d] %3" PRIu32 ".%09" PRIu32 ": ",
get_task_name(pid), get_pid(pid), cpu, sec, nsec); get_taskname(pid), get_pid(pid), cpu, sec, nsec);
return ret; return ret;
} }
@@ -694,9 +694,9 @@ static int noteram_dump_sched_switch(FAR struct lib_outstream_s *s,
ret = lib_sprintf(s, "sched_switch: prev_comm=%s prev_pid=%u " ret = lib_sprintf(s, "sched_switch: prev_comm=%s prev_pid=%u "
"prev_prio=%u prev_state=%c ==> " "prev_prio=%u prev_state=%c ==> "
"next_comm=%s next_pid=%u next_prio=%u\n", "next_comm=%s next_pid=%u next_prio=%u\n",
get_task_name(current_pid), get_pid(current_pid), get_taskname(current_pid), get_pid(current_pid),
current_priority, get_task_state(cctx->current_state), current_priority, get_task_state(cctx->current_state),
get_task_name(next_pid), get_pid(next_pid), get_taskname(next_pid), get_pid(next_pid),
next_priority); next_priority);
cctx->current_pid = cctx->next_pid; cctx->current_pid = cctx->next_pid;
@@ -740,7 +740,7 @@ static int noteram_dump_one(FAR uint8_t *p, FAR struct lib_outstream_s *s,
ret += noteram_dump_header(s, note, ctx); ret += noteram_dump_header(s, note, ctx);
ret += lib_sprintf(s, "sched_wakeup_new: comm=%s pid=%d " ret += lib_sprintf(s, "sched_wakeup_new: comm=%s pid=%d "
"target_cpu=%d\n", "target_cpu=%d\n",
get_task_name(pid), get_pid(pid), cpu); get_taskname(pid), get_pid(pid), cpu);
} }
break; break;
@@ -794,7 +794,7 @@ static int noteram_dump_one(FAR uint8_t *p, FAR struct lib_outstream_s *s,
ret += noteram_dump_header(s, note, ctx); ret += noteram_dump_header(s, note, ctx);
ret += lib_sprintf(s, "sched_waking: comm=%s " ret += lib_sprintf(s, "sched_waking: comm=%s "
"pid=%d target_cpu=%d\n", "pid=%d target_cpu=%d\n",
get_task_name(cctx->next_pid), get_taskname(cctx->next_pid),
get_pid(cctx->next_pid), cpu); get_pid(cctx->next_pid), cpu);
cctx->pendingswitch = true; cctx->pendingswitch = true;
} }
+1 -5
View File
@@ -135,11 +135,7 @@ static void note_sysview_send_taskinfo(FAR struct tcb_s *tcb)
SEGGER_SYSVIEW_TASKINFO info; SEGGER_SYSVIEW_TASKINFO info;
info.TaskID = tcb->pid; info.TaskID = tcb->pid;
#if CONFIG_TASK_NAME_SIZE > 0 info.sName = get_task_name(tcb);
info.sName = tcb->name;
#else
info.sName = "<noname>";
#endif
info.Prio = tcb->sched_priority; info.Prio = tcb->sched_priority;
info.StackBase = (uintptr_t)tcb->stack_base_ptr; info.StackBase = (uintptr_t)tcb->stack_base_ptr;
info.StackSize = tcb->adj_stack_size; info.StackSize = tcb->adj_stack_size;
+2 -2
View File
@@ -1804,9 +1804,9 @@ static int uart_unlink(FAR struct inode *inode)
static void uart_launch_foreach(FAR struct tcb_s *tcb, FAR void *arg) static void uart_launch_foreach(FAR struct tcb_s *tcb, FAR void *arg)
{ {
#ifdef CONFIG_TTY_LAUNCH_ENTRY #ifdef CONFIG_TTY_LAUNCH_ENTRY
if (!strcmp(tcb->name, CONFIG_TTY_LAUNCH_ENTRYNAME)) if (!strcmp(get_task_name(tcb), CONFIG_TTY_LAUNCH_ENTRYNAME))
#else #else
if (!strcmp(tcb->name, CONFIG_TTY_LAUNCH_FILEPATH)) if (!strcmp(get_task_name(tcb), CONFIG_TTY_LAUNCH_FILEPATH))
#endif #endif
{ {
*(FAR int *)arg = 1; *(FAR int *)arg = 1;
+1
View File
@@ -153,6 +153,7 @@ config SYSLOG_PRIORITY
config SYSLOG_PROCESS_NAME config SYSLOG_PROCESS_NAME
bool "Prepend process name to syslog message" bool "Prepend process name to syslog message"
default n default n
depends on TASK_NAME_SIZE > 0
---help--- ---help---
Prepend Process name to syslog message. Prepend Process name to syslog message.
+4 -4
View File
@@ -83,7 +83,7 @@ int nx_vsyslog(int priority, FAR const IPTR char *fmt, FAR va_list *ap)
{ {
struct lib_syslograwstream_s stream; struct lib_syslograwstream_s stream;
int ret = 0; int ret = 0;
#if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_SYSLOG_PROCESS_NAME) #ifdef CONFIG_SYSLOG_PROCESS_NAME
FAR struct tcb_s *tcb = nxsched_get_tcb(nxsched_gettid()); FAR struct tcb_s *tcb = nxsched_get_tcb(nxsched_gettid());
#endif #endif
#ifdef CONFIG_SYSLOG_TIMESTAMP #ifdef CONFIG_SYSLOG_TIMESTAMP
@@ -196,7 +196,7 @@ int nx_vsyslog(int priority, FAR const IPTR char *fmt, FAR va_list *ap)
"[%s] " "[%s] "
#endif #endif
#if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_SYSLOG_PROCESS_NAME) #ifdef CONFIG_SYSLOG_PROCESS_NAME
/* Prepend the thread name */ /* Prepend the thread name */
"%s: " "%s: "
@@ -242,10 +242,10 @@ int nx_vsyslog(int priority, FAR const IPTR char *fmt, FAR va_list *ap)
, CONFIG_SYSLOG_PREFIX_STRING , CONFIG_SYSLOG_PREFIX_STRING
#endif #endif
#if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_SYSLOG_PROCESS_NAME) #ifdef CONFIG_SYSLOG_PROCESS_NAME
/* Prepend the thread name */ /* Prepend the thread name */
, tcb != NULL ? tcb->name : "(null)" , get_task_name(tcb)
#endif #endif
); );
+2 -10
View File
@@ -486,11 +486,7 @@ static ssize_t proc_status(FAR struct proc_file_s *procfile,
/* Show the task name */ /* Show the task name */
#if CONFIG_TASK_NAME_SIZE > 0 name = get_task_name(tcb);
name = tcb->name;
#else
name = "<noname>";
#endif
linesize = procfs_snprintf(procfile->line, STATUS_LINELEN, linesize = procfs_snprintf(procfile->line, STATUS_LINELEN,
"%-12s%.18s\n", "Name:", name); "%-12s%.18s\n", "Name:", name);
copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining, copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining,
@@ -670,11 +666,7 @@ static ssize_t proc_cmdline(FAR struct proc_file_s *procfile,
/* Show the task name */ /* Show the task name */
#if CONFIG_TASK_NAME_SIZE > 0 name = get_task_name(tcb);
name = tcb->name;
#else
name = "<noname>";
#endif
linesize = strlen(name); linesize = strlen(name);
memcpy(procfile->line, name, linesize); memcpy(procfile->line, name, linesize);
copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining, copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining,
+8
View File
@@ -222,6 +222,14 @@
#define get_current_mm() (get_group_mm(nxsched_self()->group)) #define get_current_mm() (get_group_mm(nxsched_self()->group))
/* Get task name from tcb */
#if CONFIG_TASK_NAME_SIZE > 0
# define get_task_name(tcb) ((tcb)->name)
#else
# define get_task_name(tcb) "<noname>"
#endif
/* These are macros to access the current CPU and the current task on a CPU. /* These are macros to access the current CPU and the current task on a CPU.
* These macros are intended to support a future SMP implementation. * These macros are intended to support a future SMP implementation.
*/ */
+1 -9
View File
@@ -1251,17 +1251,10 @@ static int gdb_query(FAR struct gdb_state_s *state)
} }
nxsched_get_stateinfo(tcb, thread_state, sizeof(thread_state)); nxsched_get_stateinfo(tcb, thread_state, sizeof(thread_state));
#if CONFIG_TASK_NAME_SIZE > 0
snprintf(thread_info, sizeof(thread_info), snprintf(thread_info, sizeof(thread_info),
"Name: %s, State: %s, Priority: %d, Stack: %zu", "Name: %s, State: %s, Priority: %d, Stack: %zu",
tcb->name, thread_state, tcb->sched_priority, get_task_name(tcb), thread_state, tcb->sched_priority,
tcb->adj_stack_size); tcb->adj_stack_size);
#else
snprintf(thread_info, sizeof(thread_info),
"State: %s, Priority: %d, Stack: %zu",
thread_state, tcb->sched_priority,
tcb->adj_stack_size);
#endif
ret = gdb_bin2hex(state->pkt_buf, sizeof(state->pkt_buf), ret = gdb_bin2hex(state->pkt_buf, sizeof(state->pkt_buf),
thread_info, strlen(thread_info)); thread_info, strlen(thread_info));
@@ -1968,4 +1961,3 @@ out:
state->last_stopaddr = stopaddr; state->last_stopaddr = stopaddr;
return ret; return ret;
} }
+3 -15
View File
@@ -415,11 +415,7 @@ static void dump_task(FAR struct tcb_s *tcb, FAR void *arg)
#ifndef CONFIG_SCHED_CPULOAD_NONE #ifndef CONFIG_SCHED_CPULOAD_NONE
, intpart, fracpart , intpart, fracpart
#endif #endif
#if CONFIG_TASK_NAME_SIZE > 0 , get_task_name(tcb)
, tcb->name
#else
, "<noname>"
#endif
, args , args
); );
} }
@@ -630,18 +626,14 @@ static void dump_assert_info(FAR struct tcb_s *rtcb,
FAR const char *filename, int linenum, FAR const char *filename, int linenum,
FAR const char *msg, FAR void *regs) FAR const char *msg, FAR void *regs)
{ {
#if CONFIG_TASK_NAME_SIZE > 0
FAR struct tcb_s *ptcb = NULL; FAR struct tcb_s *ptcb = NULL;
#endif
struct utsname name; struct utsname name;
#if CONFIG_TASK_NAME_SIZE > 0
if (rtcb->group && if (rtcb->group &&
(rtcb->flags & TCB_FLAG_TTYPE_MASK) != TCB_FLAG_TTYPE_KERNEL) (rtcb->flags & TCB_FLAG_TTYPE_MASK) != TCB_FLAG_TTYPE_KERNEL)
{ {
ptcb = nxsched_get_tcb(rtcb->group->tg_pid); ptcb = nxsched_get_tcb(rtcb->group->tg_pid);
} }
#endif
uname(&name); uname(&name);
_alert("Current Version: %s %s %s %s %s\n", _alert("Current Version: %s %s %s %s %s\n",
@@ -653,20 +645,16 @@ static void dump_assert_info(FAR struct tcb_s *rtcb,
"(CPU%d)" "(CPU%d)"
#endif #endif
": " ": "
#if CONFIG_TASK_NAME_SIZE > 0
"%s " "%s "
"process: %s " "process: %s "
#endif
"%p\n", "%p\n",
msg ? msg : "", msg ? msg : "",
filename ? filename : "", linenum, filename ? filename : "", linenum,
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
this_cpu(), this_cpu(),
#endif #endif
#if CONFIG_TASK_NAME_SIZE > 0 get_task_name(rtcb),
rtcb->name, ptcb ? get_task_name(ptcb) : "Kernel",
ptcb ? ptcb->name : "Kernel",
#endif
rtcb->entry.main); rtcb->entry.main);
/* Dump current CPU registers, running task stack and backtrace. */ /* Dump current CPU registers, running task stack and backtrace. */
+2 -2
View File
@@ -57,8 +57,8 @@ static void dumphandler(FAR struct tcb_s *tcb, FAR void *arg)
syslog(LOG_INFO, "tcb=%p name=%s, pid:%d, priority=%d state=%d " syslog(LOG_INFO, "tcb=%p name=%s, pid:%d, priority=%d state=%d "
"stack_alloc_ptr: %p, adj_stack_size: %zu\n", "stack_alloc_ptr: %p, adj_stack_size: %zu\n",
tcb, tcb->name, tcb->pid, tcb->sched_priority, tcb->task_state, tcb, get_task_name(tcb), tcb->pid, tcb->sched_priority,
tcb->stack_alloc_ptr, tcb->adj_stack_size); tcb->task_state, tcb->stack_alloc_ptr, tcb->adj_stack_size);
filelist = &tcb->group->tg_filelist; filelist = &tcb->group->tg_filelist;
files_dumplist(filelist); files_dumplist(filelist);
+1 -5
View File
@@ -86,11 +86,7 @@ void nxtask_activate(FAR struct tcb_s *tcb)
nxsched_remove_blocked(tcb); nxsched_remove_blocked(tcb);
#if CONFIG_TASK_NAME_SIZE > 0 sinfo("%s pid=%d,TCB=%p\n", get_task_name(tcb),
sinfo("%s pid=%d,TCB=%p\n", tcb->name,
#else
sinfo("pid=%d,TCB=%p\n",
#endif
tcb->pid, tcb); tcb->pid, tcb);
/* Add the task to ready-to-run task list, and /* Add the task to ready-to-run task list, and
+1 -5
View File
@@ -91,11 +91,7 @@ int nxtask_exit(void)
dtcb = this_task(); dtcb = this_task();
#endif #endif
#if CONFIG_TASK_NAME_SIZE > 0 sinfo("%s pid=%d,TCB=%p\n", get_task_name(dtcb),
sinfo("%s pid=%d,TCB=%p\n", dtcb->name,
#else
sinfo("pid=%d,TCB=%p\n",
#endif
dtcb->pid, dtcb); dtcb->pid, dtcb);
/* Update scheduler parameters */ /* Update scheduler parameters */