os/include: Add DEBUGASSERT_INFO macro for descriptive debug outputs in case of DEBUGASSERT
DEBUGASSERT_INFO gives out a descriptive output similar to ASSERT_INFO in case of DEBUGASSERTs
@@ -103,6 +103,14 @@ extern char assert_info_str[CONFIG_STDIO_BUFFER_SIZE];
#ifdef CONFIG_DEBUG
+#define DEBUGASSERT_INFO(f, fmt, ...) \
+ { \
+ if (!(f)) { \
+ snprintf(assert_info_str, CONFIG_STDIO_BUFFER_SIZE, fmt, ##__VA_ARGS__); \
+ up_assert((const uint8_t *)__FILE__, (int)__LINE__); \
+ } \
+ }
+
#define DEBUGASSERT(f) \
{ if (!(f)) up_assert((const uint8_t *)__FILE__, (int)__LINE__); }
@@ -114,6 +122,7 @@ extern char assert_info_str[CONFIG_STDIO_BUFFER_SIZE];
#else
+#define DEBUGASSERT_INFO(f, fmt, ...)
#define DEBUGASSERT(f)
#define DEBUGVERIFY(f) ((void)(f))
#define DEBUGPANIC()
@@ -157,6 +166,13 @@ extern char assert_info_str[CONFIG_STDIO_BUFFER_SIZE];
#ifdef CONFIG_DEBUG
+#define DEBUGASSERT_INFO(f, fmt, ...) \
+ { \
+ if (!(f)) { \
+ snprintf(assert_info_str, CONFIG_STDIO_BUFFER_SIZE, fmt, ##__VA_ARGS__): \
+ up_assert(); \
+ } \
+ }
/**
* @brief Like ASSERT, but only if CONFIG_DEBUG is defined
*
@@ -186,6 +202,7 @@ extern char assert_info_str[CONFIG_STDIO_BUFFER_SIZE];
#else
+#define DEBUGASSERT_INFO(f, fmt, ...)
#define DEBUGASSERT(f)
#define DEBUGVERIFY(f) ((void)(f))
#define DEBUGPANIC()
