diff --git a/core/include/debug.h b/core/include/debug.h index 06abdbe9f2..39ec14a6c8 100644 --- a/core/include/debug.h +++ b/core/include/debug.h @@ -24,8 +24,24 @@ #include +#if DEVELHELP +#include "sched.h" +#include "cpu-conf.h" +#define DEBUG_PRINT(...) \ + do { \ + if (active_thread->stack_size > KERNEL_CONF_STACKSIZE_PRINTF) { \ + printf(__VA_ARGS__); \ + } \ + else { \ + puts("Cannot debug, stack too small"); \ + } \ + } while (0) +#else +#define DEBUG_PRINT(...) printf(__VA_ARGS__) +#endif + #if ENABLE_DEBUG -#define DEBUG(...) printf(__VA_ARGS__) +#define DEBUG(...) DEBUG_PRINT(__VA_ARGS__) #undef ENABLE_DEBUG #else #define DEBUG(...)