sched/assert.c: Print process name in assert dump

In addition to printing out the thread name (task name in flat mode),
print the parent process's name as well.

It is quite useful to know which process is the parent of a faulting
thread, although this information can be read from the assert dump, in
some cases the dump might be incomplete (due to e.g. stack corruption,
which causes another exception and PANIC().)
This commit is contained in:
Ville Juven 2023-10-02 17:36:18 +03:00 committed by Xiang Xiao
parent 28dee592a3
commit d72de58aa8
1 changed files with 12 additions and 0 deletions

View File

@ -555,11 +555,21 @@ void _assert(FAR const char *filename, int linenum,
FAR const char *msg, FAR void *regs) FAR const char *msg, FAR void *regs)
{ {
FAR struct tcb_s *rtcb = running_task(); FAR struct tcb_s *rtcb = running_task();
#if CONFIG_TASK_NAME_SIZE > 0
FAR struct tcb_s *ptcb = NULL;
#endif
struct panic_notifier_s notifier_data; struct panic_notifier_s notifier_data;
struct utsname name; struct utsname name;
bool fatal = true; bool fatal = true;
int flags; int flags;
#if CONFIG_TASK_NAME_SIZE > 0
if (rtcb->group && !(rtcb->flags & TCB_FLAG_TTYPE_KERNEL))
{
ptcb = nxsched_get_tcb(rtcb->group->tg_pid);
}
#endif
flags = enter_critical_section(); flags = enter_critical_section();
sched_lock(); sched_lock();
@ -607,6 +617,7 @@ void _assert(FAR const char *filename, int linenum,
": " ": "
#if CONFIG_TASK_NAME_SIZE > 0 #if CONFIG_TASK_NAME_SIZE > 0
"%s " "%s "
"process: %s "
#endif #endif
"%p\n", "%p\n",
msg ? msg : "", msg ? msg : "",
@ -616,6 +627,7 @@ void _assert(FAR const char *filename, int linenum,
#endif #endif
#if CONFIG_TASK_NAME_SIZE > 0 #if CONFIG_TASK_NAME_SIZE > 0
rtcb->name, rtcb->name,
ptcb ? ptcb->name : "Kernel",
#endif #endif
rtcb->entry.main); rtcb->entry.main);