diff --git a/include/sys/__assert.h b/include/sys/__assert.h index 1b28dcecc4f..e0ca1b296af 100644 --- a/include/sys/__assert.h +++ b/include/sys/__assert.h @@ -20,6 +20,12 @@ #define __ASSERT_ON 0 #endif +#if defined(CONFIG_ASSERT_VERBOSE) +#define __ASSERT_PRINT(fmt, ...) printk(fmt, ##__VA_ARGS__) +#else /* CONFIG_ASSERT_VERBOSE */ +#define __ASSERT_PRINT(fmt, ...) +#endif /* CONFIG_ASSERT_VERBOSE */ + #ifdef CONFIG_ASSERT_NO_FILE_INFO #define __ASSERT_FILE_INFO "" #else /* CONFIG_ASSERT_NO_FILE_INFO */ @@ -33,7 +39,7 @@ #endif /* CONFIG_ASSERT_NO_COND_INFO */ #define __ASSERT_LOC(test) \ - printk("ASSERTION FAIL [%s] @ %s:%d\n", \ + __ASSERT_PRINT("ASSERTION FAIL [%s] @ %s:%d\n", \ __ASSERT_COND_INFO(test), \ __ASSERT_FILE_INFO, \ __LINE__) \ diff --git a/subsys/debug/Kconfig b/subsys/debug/Kconfig index 57d74e48c9d..cae46f0c8dc 100644 --- a/subsys/debug/Kconfig +++ b/subsys/debug/Kconfig @@ -181,6 +181,15 @@ config FORCE_NO_ASSERT CFLAGS and not Kconfig. Added solely to be able to work around compiler bugs for specific tests. +config ASSERT_VERBOSE + bool "Enable verbose assertions" + default y + help + This option enables printing an assert message with information about + the assertion that occurred. This includes printing the location, + the conditional expression and additional message specific to the + assert. + config ASSERT_NO_FILE_INFO bool "Disable file info for asserts" help