Skip to content
Permalink
Browse files

arch: x86: fatal: If possible, print thread name in crash dump

It's relatively hard to figure out what thread a crash happens in
from the crash dump. E.g, it's usually not immediately possible to
find it out from linker map due to the fact that static symbols are
not there (https://sourceware.org/bugzilla/show_bug.cgi?id=16566).

So, try to do it as easy if possible, by just printing thread name
in a dump, if thread names are enabled at all.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
  • Loading branch information...
pfalcon authored and andrewboie committed Mar 7, 2019
1 parent ea1f7fb commit ec1ffc8bcf4ffb91458a9f31ab9a0768fc78be91
Showing with 12 additions and 1 deletion.
  1. +12 −1 arch/x86/core/fatal.c
@@ -137,6 +137,10 @@ static void unwind_stack(u32_t base_ptr, u16_t cs)
FUNC_NORETURN void z_NanoFatalErrorHandler(unsigned int reason,
const NANO_ESF *pEsf)
{
#ifdef CONFIG_THREAD_NAME
const char *thread_name = k_thread_name_get(k_current_get());
#endif

LOG_PANIC();

z_debug_fatal_hook(pEsf);
@@ -184,7 +188,11 @@ FUNC_NORETURN void z_NanoFatalErrorHandler(unsigned int reason,
break;
}

printk("Current thread ID = %p\n"
printk("Current thread ID = %p"
#ifdef CONFIG_THREAD_NAME
" (%s)"
#endif
"\n"
"eax: 0x%08x, ebx: 0x%08x, ecx: 0x%08x, edx: 0x%08x\n"
"esi: 0x%08x, edi: 0x%08x, ebp: 0x%08x, esp: 0x%08x\n"
"eflags: 0x%08x cs: 0x%04x\n"
@@ -193,6 +201,9 @@ FUNC_NORETURN void z_NanoFatalErrorHandler(unsigned int reason,
#endif
"eip: 0x%08x\n",
k_current_get(),
#ifdef CONFIG_THREAD_NAME
thread_name ? thread_name : "unknown",
#endif
pEsf->eax, pEsf->ebx, pEsf->ecx, pEsf->edx,
pEsf->esi, pEsf->edi, pEsf->ebp, pEsf->esp,
pEsf->eflags, pEsf->cs & 0xFFFFU, pEsf->eip);

0 comments on commit ec1ffc8

Please sign in to comment.
You can’t perform that action at this time.