From 91468b5a0460e3e209a25a54d450d731c371a215 Mon Sep 17 00:00:00 2001 From: Andrew Boie Date: Wed, 6 Nov 2019 13:03:38 -0800 Subject: [PATCH] kernel: fatal: show faulting CPU Doing this in common code since we have an API for it. Signed-off-by: Andrew Boie --- kernel/fatal.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/kernel/fatal.c b/kernel/fatal.c index 65daa38d93c..ca44f7b652b 100644 --- a/kernel/fatal.c +++ b/kernel/fatal.c @@ -81,6 +81,15 @@ FUNC_NORETURN void k_fatal_halt(unsigned int reason) } /* LCOV_EXCL_STOP */ +static inline int get_cpu(void) +{ +#if defined(CONFIG_SMP) + return z_arch_curr_cpu()->id; +#else + return 0; +#endif +} + void z_fatal_error(unsigned int reason, const z_arch_esf_t *esf) { struct k_thread *thread = k_current_get(); @@ -88,7 +97,8 @@ void z_fatal_error(unsigned int reason, const z_arch_esf_t *esf) /* sanitycheck looks for the "ZEPHYR FATAL ERROR" string, don't * change it without also updating sanitycheck */ - LOG_ERR(">>> ZEPHYR FATAL ERROR %d: %s", reason, reason_to_str(reason)); + LOG_ERR(">>> ZEPHYR FATAL ERROR %d: %s on CPU %d", reason, + reason_to_str(reason), get_cpu()); /* FIXME: This doesn't seem to work as expected on all arches. * Need a reliable way to determine whether the fault happened when