diff --git a/include/sys/__assert.h b/include/sys/__assert.h index e0ca1b296af..b24f97ea709 100644 --- a/include/sys/__assert.h +++ b/include/sys/__assert.h @@ -38,6 +38,12 @@ #define __ASSERT_COND_INFO(test) Z_STRINGIFY(test) #endif /* CONFIG_ASSERT_NO_COND_INFO */ +#ifdef CONFIG_ASSERT_NO_MSG_INFO +#define __ASSERT_MSG_INFO(fmt, ...) +#else /* CONFIG_ASSERT_NO_MSG_INFO */ +#define __ASSERT_MSG_INFO(fmt, ...) __ASSERT_PRINT("\t" fmt "\n", ##__VA_ARGS__) +#endif /* CONFIG_ASSERT_NO_MSG_INFO */ + #define __ASSERT_LOC(test) \ __ASSERT_PRINT("ASSERTION FAIL [%s] @ %s:%d\n", \ __ASSERT_COND_INFO(test), \ @@ -75,7 +81,7 @@ void assert_post_action(const char *file, unsigned int line); do { \ if (!(test)) { \ __ASSERT_LOC(test); \ - printk("\t" fmt "\n", ##__VA_ARGS__); \ + __ASSERT_MSG_INFO(fmt, ##__VA_ARGS__); \ assert_post_action(__ASSERT_FILE_INFO, __LINE__); \ } \ } while (false) diff --git a/subsys/debug/Kconfig b/subsys/debug/Kconfig index cae46f0c8dc..3015b8f475f 100644 --- a/subsys/debug/Kconfig +++ b/subsys/debug/Kconfig @@ -206,6 +206,15 @@ config ASSERT_NO_COND_INFO info before disabling file info since the condition can be found in the source using file info. +config ASSERT_NO_MSG_INFO + bool "Disable message for asserts" + help + This option removes the additional message from the printed assert. + Enabling this will save target code space, and thus may be + necessary for tiny targets. It is recommended to disable message + before disabling file info since the message can be found in the + source using file info. + config OBJECT_TRACING bool "Kernel object tracing" help