From d5481055f2b767911af60f246a089087ec33792b Mon Sep 17 00:00:00 2001 From: Ioannis Glaropoulos Date: Mon, 20 May 2019 10:43:37 +0200 Subject: [PATCH] arch: arm: print thread name in z_NanoFatalErrorHandler() In z_NanoFatalErrorHandler() we want to print the name of the thread that has faulted, when building with CONFIG_THREAD_NAME. This commit adds this functionality for the Arm architecture. Signed-off-by: Ioannis Glaropoulos --- arch/arm/core/fatal.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/arch/arm/core/fatal.c b/arch/arm/core/fatal.c index 8692771f811..64ce0e4a934 100644 --- a/arch/arm/core/fatal.c +++ b/arch/arm/core/fatal.c @@ -47,6 +47,10 @@ 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(); switch (reason) { @@ -77,9 +81,17 @@ void z_NanoFatalErrorHandler(unsigned int reason, printk("**** Unknown Fatal Error %d! ****\n", reason); break; } - printk("Current thread ID = %p\n" + printk("Current thread ID = %p" +#ifdef CONFIG_THREAD_NAME + " (%s)" +#endif + "\n" "Faulting instruction address = 0x%x\n", - k_current_get(), pEsf->basic.pc); + k_current_get(), +#ifdef CONFIG_THREAD_NAME + thread_name ? thread_name : "unknown", +#endif + pEsf->basic.pc); /* * Now that the error has been reported, call the user implemented