From a98a9e12e9a30a8596b0d9bde0a9c0e78a1ffcd2 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Wed, 20 Nov 2019 19:09:47 +0100 Subject: [PATCH] core: debug: introduce DEBUG_PUTS() The DEBUG() function requires a minimal stack size for printf(). This is not always availiable. To still allow static debug messages, introduce DEBUG_PUTS() that gets resolved to puts() and does not carry such stack size requirements. --- core/include/debug.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/core/include/debug.h b/core/include/debug.h index 7d7d062470..f46bc5da7c 100644 --- a/core/include/debug.h +++ b/core/include/debug.h @@ -56,7 +56,7 @@ extern "C" { printf(__VA_ARGS__); \ } \ else { \ - puts("Cannot debug, stack too small"); \ + puts("Cannot debug, stack too small. Consider using DEBUG_PUTS()."); \ } \ } while (0) #else @@ -95,6 +95,14 @@ extern "C" { * @note Another name for ::DEBUG_PRINT */ #define DEBUG(...) if (ENABLE_DEBUG) DEBUG_PRINT(__VA_ARGS__) + +/** + * @def DEBUG_PUTS + * + * @brief Print debug information to stdout using puts(), so no stack size + * restrictions do apply. + */ +#define DEBUG_PUTS(str) if (ENABLE_DEBUG) puts(str) /** @} */ /**