kernel: support log system for fatal errors
We introduce a new z_fatal_print() API and replace all occurrences of exception handling code to use it. This routes messages to the logging subsystem if enabled. Otherwise, messages are sent to printk(). Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
parent
5623637a48
commit
8a9e8e0cd7
15 changed files with 289 additions and 270 deletions
|
@ -8,6 +8,7 @@
|
|||
#define ZEPHYR_INCLUDE_FATAL_H
|
||||
|
||||
#include <arch/cpu.h>
|
||||
#include <toolchain.h>
|
||||
|
||||
enum k_fatal_error_reason {
|
||||
/** Generic CPU exception, not covered by other codes */
|
||||
|
@ -77,4 +78,27 @@ void k_sys_fatal_error_handler(unsigned int reason, const NANO_ESF *esf);
|
|||
*/
|
||||
void z_fatal_error(unsigned int reason, const NANO_ESF *esf);
|
||||
|
||||
/**
|
||||
* Print messages related to an exception
|
||||
*
|
||||
* This ensures the following:
|
||||
* - The log system will enter panic mode if it is not already
|
||||
* - Messages will be sent to printk() or the log subsystem if it is enabled
|
||||
*
|
||||
* Log subsystem filtering is disabled.
|
||||
* To conform with log subsystem semantics, newlines are automatically
|
||||
* appended, invoke this once per line.
|
||||
*
|
||||
* @param fmt Format string
|
||||
* @param ... Optional list of format arguments
|
||||
*
|
||||
* FIXME: Implemented in C file to avoid #include loops, disentangle and
|
||||
* make this a macro
|
||||
*/
|
||||
#if defined(CONFIG_LOG) || defined(CONFIG_PRINTK)
|
||||
__printf_like(1, 2) void z_fatal_print(const char *fmt, ...);
|
||||
#else
|
||||
#define z_fatal_print(...) do { } while (false)
|
||||
#endif
|
||||
|
||||
#endif /* ZEPHYR_INCLUDE_FATAL_H */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue