From 8a80c6ab280bbee5379c46ed41f41d2424df157c Mon Sep 17 00:00:00 2001 From: anjiahao Date: Tue, 31 Jan 2023 19:50:22 +0800 Subject: [PATCH] assert:add a Kconfig option to limit binfile size Signed-off-by: anjiahao --- Kconfig | 9 +++++++++ include/assert.h | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/Kconfig b/Kconfig index a66f5ac1625..a4209287fc2 100644 --- a/Kconfig +++ b/Kconfig @@ -631,6 +631,15 @@ config DEBUG_ASSERTIONS set CONFIG_DEBUG_ASSERTIONS=y during debug, but disable the assertions on a final, buckled up system. +config DEBUG_ASSERTIONS_EXPRESSION + bool "Enable Debug Assertions show expression" + default n + depends on DEBUG_ASSERTIONS + ---help--- + This option can display the content information of the ASSERT() + function when it is triggered. This option maybe will take up a lot + of space. + comment "Subsystem Debug Options" config DEBUG_AUDIO diff --git a/include/assert.h b/include/assert.h index 32c760679dc..0291f637c07 100644 --- a/include/assert.h +++ b/include/assert.h @@ -48,8 +48,14 @@ #endif #define PANIC() __assert(__FILE__, __LINE__, "panic") + +#ifdef CONFIG_DEBUG_ASSERTIONS_EXPRESSION #define ASSERT(f) do { if (!(f)) __assert(__FILE__, __LINE__, #f); } while (0) #define VERIFY(f) do { if ((f) < 0) __assert(__FILE__, __LINE__, #f); } while (0) +#else +#define ASSERT(f) do { if (!(f)) __assert(__FILE__, __LINE__, "unknown"); } while (0) +#define VERIFY(f) do { if ((f) < 0) __assert(__FILE__, __LINE__, "unknown"); } while (0) +#endif #ifdef CONFIG_DEBUG_ASSERTIONS # define DEBUGPANIC() PANIC()