kernel: fatal: show faulting CPU

Doing this in common code since we have an API for it.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
Andrew Boie 2019-11-06 13:03:38 -08:00 committed by Andrew Boie
commit 91468b5a04

View file

@ -81,6 +81,15 @@ FUNC_NORETURN void k_fatal_halt(unsigned int reason)
} }
/* LCOV_EXCL_STOP */ /* 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) void z_fatal_error(unsigned int reason, const z_arch_esf_t *esf)
{ {
struct k_thread *thread = k_current_get(); 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 /* sanitycheck looks for the "ZEPHYR FATAL ERROR" string, don't
* change it without also updating sanitycheck * 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. /* FIXME: This doesn't seem to work as expected on all arches.
* Need a reliable way to determine whether the fault happened when * Need a reliable way to determine whether the fault happened when