Skip to content

Commit ec1ffc8

Browse files
pfalconandrewboie
authored andcommitted
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 <[email protected]>
1 parent ea1f7fb commit ec1ffc8

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

arch/x86/core/fatal.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ static void unwind_stack(u32_t base_ptr, u16_t cs)
137137
FUNC_NORETURN void z_NanoFatalErrorHandler(unsigned int reason,
138138
const NANO_ESF *pEsf)
139139
{
140+
#ifdef CONFIG_THREAD_NAME
141+
const char *thread_name = k_thread_name_get(k_current_get());
142+
#endif
143+
140144
LOG_PANIC();
141145

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

187-
printk("Current thread ID = %p\n"
191+
printk("Current thread ID = %p"
192+
#ifdef CONFIG_THREAD_NAME
193+
" (%s)"
194+
#endif
195+
"\n"
188196
"eax: 0x%08x, ebx: 0x%08x, ecx: 0x%08x, edx: 0x%08x\n"
189197
"esi: 0x%08x, edi: 0x%08x, ebp: 0x%08x, esp: 0x%08x\n"
190198
"eflags: 0x%08x cs: 0x%04x\n"
@@ -193,6 +201,9 @@ FUNC_NORETURN void z_NanoFatalErrorHandler(unsigned int reason,
193201
#endif
194202
"eip: 0x%08x\n",
195203
k_current_get(),
204+
#ifdef CONFIG_THREAD_NAME
205+
thread_name ? thread_name : "unknown",
206+
#endif
196207
pEsf->eax, pEsf->ebx, pEsf->ecx, pEsf->edx,
197208
pEsf->esi, pEsf->edi, pEsf->ebp, pEsf->esp,
198209
pEsf->eflags, pEsf->cs & 0xFFFFU, pEsf->eip);

0 commit comments

Comments
 (0)