Skip to content

Commit

Permalink
sched/assert.c: Print process name in assert dump
Browse files Browse the repository at this point in the history
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().)
  • Loading branch information
pussuw committed Oct 9, 2023
1 parent 071fb18 commit 9c3ca9a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions sched/misc/assert.c
Original file line number Diff line number Diff line change
Expand Up @@ -555,11 +555,21 @@ void _assert(FAR const char *filename, int linenum,
FAR const char *msg, FAR void *regs)
{
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 utsname name;
bool fatal = true;
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();

sched_lock();
Expand Down Expand Up @@ -607,6 +617,7 @@ void _assert(FAR const char *filename, int linenum,
": "
#if CONFIG_TASK_NAME_SIZE > 0
"%s "
"process: %s "
#endif
"%p\n",
msg ? msg : "",
Expand All @@ -616,6 +627,7 @@ void _assert(FAR const char *filename, int linenum,
#endif
#if CONFIG_TASK_NAME_SIZE > 0
rtcb->name,
ptcb ? ptcb->name : "Kernel",
#endif
rtcb->entry.main);

Expand Down

0 comments on commit 9c3ca9a

Please sign in to comment.