diff --git a/include/sys/__assert.h b/include/sys/__assert.h index 40565d5ad20..918b4ca8a21 100644 --- a/include/sys/__assert.h +++ b/include/sys/__assert.h @@ -26,6 +26,12 @@ #define __ASSERT_FILE_INFO __FILE__ #endif /* CONFIG_ASSERT_NO_FILE_INFO */ +#ifdef CONFIG_ASSERT_NO_COND_INFO +#define __ASSERT_COND_INFO(test) "" +#else /* CONFIG_ASSERT_NO_COND_INFO */ +#define __ASSERT_COND_INFO(test) Z_STRINGIFY(test) +#endif /* CONFIG_ASSERT_NO_COND_INFO */ + #ifdef __ASSERT_ON #if (__ASSERT_ON < 0) || (__ASSERT_ON > 2) #error "Invalid __ASSERT() level: must be between 0 and 2" @@ -47,7 +53,7 @@ void assert_post_action(const char *file, unsigned int line); #define __ASSERT_LOC(test) \ printk("ASSERTION FAIL [%s] @ %s:%d\n", \ - Z_STRINGIFY(test), \ + __ASSERT_COND_INFO(test), \ __ASSERT_FILE_INFO, \ __LINE__) \ diff --git a/subsys/debug/Kconfig b/subsys/debug/Kconfig index 86b6251c5b0..57d74e48c9d 100644 --- a/subsys/debug/Kconfig +++ b/subsys/debug/Kconfig @@ -188,6 +188,15 @@ config ASSERT_NO_FILE_INFO in which the assertion occurred. Enabling this will save target code space, and thus may be necessary for tiny targets. +config ASSERT_NO_COND_INFO + bool "Disable condition info for asserts" + help + This option removes the assert condition from the printed assert + message. Enabling this will save target code space, and thus may be + necessary for tiny targets. It is recommended to disable condition + info before disabling file info since the condition can be found in + the source using file info. + config OBJECT_TRACING bool "Kernel object tracing" help